--- console-tools-0.3.3/lib/cfont/fontstruct.c.jj Fri Feb 25 18:19:16 2000 +++ console-tools-0.3.3/lib/cfont/fontstruct.c Fri Feb 25 19:37:42 2000 @@ -60,6 +60,7 @@ simple_font* read_simple_font (FILE* fon filesize = -1; /* cannot know, so say we don't know */ } + if (0) fprintf (stderr, "Format: %u\n", font_format); /* --- console-tools-0.3.3/lib/console/acm.c.jj Tue Sep 21 19:18:39 1999 +++ console-tools-0.3.3/lib/console/acm.c Fri Feb 25 19:34:48 2000 @@ -33,16 +33,7 @@ int acm_load(int fd, FILE *fp) if (fstat(fp->_fileno, &stbuf)) perror(_("Cannot stat ACM file")), exit(1); - /* first try a wg15-charmap (glibc) file format */ - if (-1 != glibc_acm_read (fp, wbuf, False)) - { - if (ioctl(fd,PIO_UNISCRNMAP,wbuf)) - perror(_("PIO_UNISCRNMAP ioctl")), exit(1); - else - return 0; - } - - /* next try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */ + /* Try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */ if (!(parse_failed = (-1 == acm_read_ascii(fp,wbuf,&is_unicode))) || (S_ISREG(stbuf.st_mode) && (stbuf.st_size == (sizeof(unicode) * E_TABSZ)))) /* test for binary UTF map by size */ @@ -122,91 +113,8 @@ int acm_load(int fd, FILE *fp) } -/* Reads a charmap file from /usr/share/i18n/charmaps as a SFM file - * - * - returns -1 on error. - * - returns it in `unicode' in an E_TABSZ-elements array. - * (ie. real 16-bit) mapping. - * - * FIXME: This is very fragile and depends on the precise syntax of the file. - * Works for usual files; probably a yacc grammar would be better - */ -int glibc_acm_read (FILE *fp, unicode buf[], lct_boolean fail_on_error) -{ - char linebuf [256]; /* line buffer */ - char *p; - int in_int, out_int, i; - char *in, *out, *skip; - int charmap_section = 0, linenum = 0; - sigset_t sigset, old_sigset; - - /* first 128 codes defaults to ASCII */ - for (i=0; i<128; i++) buf[i] = i; - /* remaining defaults to replacement char (usually E_TABSZ = 256) */ - for ( ; i"); - if (!in || !out) - { - if (fail_on_error) - fprintf (stderr,_("Couldn't parse line %d\n"),linenum); - /* restore sig mask */ - sigprocmask (SIG_SETMASK, &old_sigset, NULL); - return -1; - } - sscanf (in,"%x",&in_int); - sscanf (out+1, "%x", &out_int); - buf [in_int] = out_int; - } - } while (1); - - /* restore sig mask */ - sigprocmask (SIG_SETMASK, &old_sigset, NULL); - - return 0; -} - - /* - * - reads `fp' as a 16-bit ASCII SFM file. + * - reads `fp' as a 16-bit ASCII ACM file or wg-15 (glibc) file. * - returns -1 on error. * - returns it in `unicode' in an E_TABSZ-elements array. * - sets `*is_unicode' flagiff there were any non-8-bit @@ -223,6 +131,8 @@ int acm_read_ascii(FILE *fp, unicode buf int i; /* loop index - result holder */ int ret_code = 0; /* return code */ sigset_t sigset, old_sigset; + int charmap_section = 0, linenum = 0; + char *inp, *outp; assert (is_unicode); @@ -254,10 +164,44 @@ int acm_read_ascii(FILE *fp, unicode buf /* get "charset-relative charcode", stripping leading spaces */ p = strtok(buffer," \t\n"); + linenum++; + /* skip empty lines and comments */ - if (!p || *p == '#') + if (!p || *p == '#' || *p == '%') continue; + if (charmap_section) + { + if (*p != '<') + continue; + strtok (NULL, "x"); + inp = strtok (NULL, "<"); + outp = strtok (NULL, ">"); + if (!inp || !outp) + { + /* restore sig mask */ + sigprocmask (SIG_SETMASK, &old_sigset, NULL); + return -1; + } + sscanf (inp,"%x",&in); + sscanf (outp+1, "%x", &on); + buf [in] = on; + continue; + } + + if (!strcmp (p, "CHARMAP")) + { + charmap_section = 1; + ret_code = 0; + *is_unicode = True; + /* Reinitialize buf because wg-15 (glibc) format starts here. */ + /* first 128 codes defaults to ASCII */ + for (i=0; i<128; i++) buf[i] = i; + /* remaining defaults to replacement char (usually E_TABSZ = 256) */ + for ( ; i 255) { ret_code = -1; - break; + continue; } on = ctoi(q, &tmp_is_unicode); if (in < 0 && on > 65535) { ret_code = -1; - break; + continue; } *is_unicode |= tmp_is_unicode; @@ -282,7 +226,7 @@ int acm_read_ascii(FILE *fp, unicode buf else { ret_code = -1; - break; + continue; } } while (1); /* terminated by break on feof() */ --- console-tools-0.3.3/include/lct/console.h.jj Thu Aug 26 00:00:55 1999 +++ console-tools-0.3.3/include/lct/console.h Fri Feb 25 18:46:09 2000 @@ -28,7 +28,6 @@ void acm_save (int fd, char* omfil); int acm_load(int fd, FILE *fp); int fcm_read_ascii(FILE *fp, unsigned char buf[]); int acm_read_ascii(FILE *fp, unicode buf[], lct_boolean* is_unicode); -int glibc_acm_read (FILE *fp, unicode buf[], lct_boolean fail_on_error); /* unimap-misc.c */ int set_kernel_sfm(int fd, struct unimapdesc *); --- console-tools-0.3.3/CREDITS.jj Thu Aug 26 00:14:53 1999 +++ console-tools-0.3.3/CREDITS Fri Feb 25 19:03:57 2000 @@ -50,8 +50,8 @@ N: Joel Hoffman E: joel@wam.umd.edu N: Jakub Jelinek -E: jj@sunsite.ms.mff.cuni.cz -S: Czech Republic ? +E: jakub@redhat.com +S: Czech Republic N: Risto Kankkunen D: Original author of dumpkeys and loadkeys