use the pedantically correct compiler for preprocessing
[oweals/busybox.git] / loadacm.c
index 81b973b026f8dc6b88f131f2ae2c5bf237df4cdd..3fb4e7665121a854350edcd654a7157d6ecfe40b 100644 (file)
--- a/loadacm.c
+++ b/loadacm.c
 typedef unsigned short unicode;
 
 static long int ctoi(unsigned char *s, int *is_unicode);
-int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
-int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
-unicode utf8_to_ucs2(char *buf);
-int screen_map_load(int fd, FILE * fp);
+static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
+static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
+static unicode utf8_to_ucs2(char *buf);
+static int screen_map_load(int fd, FILE * fp);
 
 int loadacm_main(int argc, char **argv)
 {
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
                show_usage();
        }
 
-       fd = open("/dev/tty", O_RDWR);
+       fd = open(CURRENT_VC, O_RDWR);
        if (fd < 0) {
-               perror_msg_and_die("Error opening /dev/tty1");
+               perror_msg_and_die("Error opening " CURRENT_VC);
        }
 
        if (screen_map_load(fd, stdin)) {
@@ -51,7 +51,7 @@ int loadacm_main(int argc, char **argv)
        return EXIT_SUCCESS;
 }
 
-int screen_map_load(int fd, FILE * fp)
+static int screen_map_load(int fd, FILE * fp)
 {
        struct stat stbuf;
        unicode wbuf[E_TABSZ];
@@ -141,7 +141,7 @@ int screen_map_load(int fd, FILE * fp)
  *
  * FIXME: ignores everything after second word
  */
-int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
+static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
 {
        char buffer[256];                       /* line buffer reading file */
        char *p, *q;                            /* 1st + 2nd words in line */
@@ -149,7 +149,7 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
        int tmp_is_unicode;                     /* tmp for is_unicode calculation */
        int i;                                          /* loop index - result holder */
        int ret_code = 0;                       /* return code */
-       sigset_t sigset, old_sigset;
+       sigset_t acmsigset, old_sigset;
 
        assert(is_unicode);
 
@@ -163,9 +163,9 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
                buf[i] = 0xfffd;
 
        /* block SIGCHLD */
-       sigemptyset(&sigset);
-       sigaddset(&sigset, SIGCHLD);
-       sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
+       sigemptyset(&acmsigset);
+       sigaddset(&acmsigset, SIGCHLD);
+       sigprocmask(SIG_BLOCK, &acmsigset, &old_sigset);
 
        do {
                if (NULL == fgets(buffer, sizeof(buffer), fp)) {
@@ -213,7 +213,7 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
 }
 
 
-int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
+static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
 {
        char buffer[256];
        int in, on;
@@ -255,7 +255,7 @@ int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
  *
  * CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
  */
-long int ctoi(unsigned char *s, int *is_unicode)
+static long int ctoi(unsigned char *s, int *is_unicode)
 {
        int i;
        size_t ls;
@@ -302,42 +302,7 @@ long int ctoi(unsigned char *s, int *is_unicode)
 }
 
 
-void saveoldmap(int fd, char *omfil)
-{
-       FILE *fp;
-       char buf[E_TABSZ];
-
-#ifdef GIO_UNISCRNMAP
-       unicode xbuf[E_TABSZ];
-       int is_old_map = 0;
-
-       if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
-               perror_msg("GIO_UNISCRNMAP ioctl error");
-#endif
-               if (ioctl(fd, GIO_SCRNMAP, buf))
-                       perror_msg_and_die("GIO_SCRNMAP ioctl error");
-               else
-                       is_old_map = 1;
-#ifdef GIO_UNISCRNMAP
-       }
-#endif
-
-       fp = xfopen(omfil, "w");
-#ifdef GIO_UNISCRNMAP
-       if (is_old_map) {
-#endif
-               if (fwrite(buf, E_TABSZ, 1, fp) != 1)
-                       perror_msg_and_die("Error writing map to file");
-#ifdef GIO_UNISCRNMAP
-       } else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
-               perror_msg_and_die("Error writing map to file");
-       }
-#endif
-
-       fclose(fp);
-}
-
-unicode utf8_to_ucs2(char *buf)
+static unicode utf8_to_ucs2(char *buf)
 {
        int utf_count = 0;
        long utf_char = 0;