From 2bd608801708e2fa3d0e39f1220604a81a036a78 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 18 Jan 1999 23:15:16 +0000 Subject: Update. 1999-01-18 Ulrich Drepper * iconv/gconv_conf.c (add_module): Complete rewrite. Use cleverer data structures and avoid creating intermediate representations first. Rewrite also all helper functions. * iconv/gconv_db.c (find_derivation): Use new data structure for module database. * iconv/Versions: Remove __gconv_nmodules. * iconv/iconv_prog.c: Rewrite generation of charset name list to use new data structure. * iconv/gconv_int.h (struct gconv_module): Add new elements for database data structure. (__gconv_modules_db): Update type. (__gconv_transform_dummy): Removed. * iconv/gconv_builtin.h: Remove dummy transformation. * iconv/gconv_simple.c: Remove __gconv_transform_dummy. * sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Remove __syscall_vfork, add vfork. * sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise. * Rules: Add dummp.c and dummy.o to common-generated. --- iconv/iconv_prog.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'iconv/iconv_prog.c') diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c index 8f05d57a18..78fa6234f4 100644 --- a/iconv/iconv_prog.c +++ b/iconv/iconv_prog.c @@ -99,7 +99,7 @@ static int process_block (iconv_t cd, const char *addr, size_t len, FILE *output); static int process_fd (iconv_t cd, int fd, FILE *output); static int process_file (iconv_t cd, FILE *input, FILE *output); -static void print_known_names (void); +static void print_known_names (void) internal_function; int @@ -503,9 +503,38 @@ do_print (const void *nodep, VISIT value, int level) } static void +internal_function +add_known_names (struct gconv_module *node) +{ + if (node->left != NULL) + add_known_names (node->left); + if (node->right != NULL) + add_known_names (node->right); + if (node->same != NULL) + add_known_names (node->same); + do + { + if (node->from_pattern == NULL) + { + if (strcmp (node->from_constpfx, "INTERNAL")) + tsearch (node->from_constpfx, &printlist, + (__compar_fn_t) strverscmp); + if (strcmp (node->to_string, "INTERNAL")) + tsearch (node->to_string, &printlist, (__compar_fn_t) strverscmp); + } + else + if (strcmp (node->from_pattern, "INTERNAL")) + tsearch (node->from_pattern, &printlist, (__compar_fn_t) strverscmp); + + node = node->matching; + } + while (node != NULL); +} + +static void +internal_function print_known_names (void) { - size_t cnt; iconv_t h; /* We must initialize the internal databases first. */ @@ -516,22 +545,7 @@ print_known_names (void) twalk (__gconv_alias_db, insert_print_list); /* Add the from- and to-names from the known modules. */ - for (cnt = 0; cnt < __gconv_nmodules; ++cnt) - { - if (__gconv_modules_db[cnt]->from_pattern == NULL) - { - if (strcmp (__gconv_modules_db[cnt]->from_constpfx, "INTERNAL")) - tsearch (__gconv_modules_db[cnt]->from_constpfx, &printlist, - (__compar_fn_t) strverscmp); - if (strcmp (__gconv_modules_db[cnt]->to_string, "INTERNAL")) - tsearch (__gconv_modules_db[cnt]->to_string, &printlist, - (__compar_fn_t) strverscmp); - } - else - if (strcmp (__gconv_modules_db[cnt]->from_pattern, "INTERNAL")) - tsearch (__gconv_modules_db[cnt]->from_pattern, &printlist, - (__compar_fn_t) strverscmp); - } + add_known_names (__gconv_modules_db); fputs (_("\ The following list contain all the coded character sets known. This does\n\ -- cgit 1.4.1