From 51702635af8445431054291c86aaace7c30b0970 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 7 May 1997 15:31:21 +0000 Subject: Update. * locale/categories.def: Change type of _NL_CTYPE_CLASS_NAMES and _NL_CTYPE_MAP_NAMES field to stringlist. Change name of _NL_CTYPE_CODESET_NAME to "charmap". * locale/localeinfo.h (enum value_type): Add stringlist. * locale/programs/locale.c (show_info): Handle stringlist. * locale/programs/charmap.c (charmap_read): If charmap file is not using the given name try to find it by looking through all available charmap files and compare the code set name. * locale/programs/locale.c (write_charmaps): Also print names of charset in fields in the files. * elf/ldd.bash.in: Correct translatable strings. * posix/TESTS: Add some more tests for character class matching. * posix/regex.c: Merge with GNU awk version. (regex_compile): Use ISO C/amend 1 functions for character class handling. * posix/regex.h: Merge with GNU awk version. * posix/getopt.c: Declare as master copies. * posix/getopt1.c: Likewise. * posix/getopt.h: Likewise. * sysdeps/unix/sysv/linux/sys/mount.h: Add definitions for option value to mount functions. Patch by a sun . * stdio-common/bug4.c (main): Use /tmp/bug4.test for concurrency with other tests. * sunrpc/svc_run.c (svc_exit): New, defined. (svc_run): Test for svc_stop variable. * sysdeps/m68k/s_cexp.c: Rewritten. * sysdeps/m68k/s_cexpf.c: Likewise. * sysdeps/m68k/s_cexpl.c: Likewise. --- locale/programs/charmap.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'locale/programs/charmap.c') diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c index 37b6cdef96..359b913c1f 100644 --- a/locale/programs/charmap.c +++ b/locale/programs/charmap.c @@ -22,6 +22,7 @@ #endif #include +#include #include #include #include @@ -76,6 +77,73 @@ charmap_read (const char *filename) error (0, errno, _("character map file `%s' not found"), filename); } + if (result == NULL) + { + /* OK, one more try. We also accept the names given to the + character sets in the files. Sometimes they differ from the + file name. */ + DIR *dir; + struct dirent *dirent; + + dir = opendir (CHARMAP_PATH); + if (dir == NULL) + { + while ((dirent = readdir (dir)) != NULL) + if (strcmp (dirent->d_name, ".") != 0 + && strcmp (dirent->d_name, "..") != 0) + { + char buf[sizeof (CHARMAP_PATH) + + strlen (dirent->d_name) + 1]; + FILE *fp; +#ifdef _DIRENT_HAVE_D_TYPE + if (dirent->d_type != DT_UNKNOWN && dirent->d_type != DT_REG) + continue; +#endif + stpcpy (stpcpy (stpcpy (buf, CHARMAP_PATH), "/"), + dirent->d_name); + + fp = fopen (buf, "r"); + if (fp != NULL) + { + char *name = NULL; + + while (!feof (fp)) + { + char junk[BUFSIZ]; + + if (fscanf (fp, " %as", &name) == 1) + break; + + do + fgets (junk, sizeof junk, fp); + while (strchr (junk, '\n') == NULL); + } + + fclose (fp); + + if (name != NULL) + { + if (strcmp (name, filename) == 0) + { + result = parse_charmap (buf); + + free (buf); + + if (result) + return result; + + break; + } + + free (name); + } + } + } + + closedir (dir); + } + } + if (result == NULL) { pathnfile = CHARMAP_PATH "/" DEFAULT_CHARMAP; -- cgit 1.4.1