summaryrefslogtreecommitdiff
path: root/iconv/gconv_conf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-05-08 12:32:47 +0000
committerUlrich Drepper <drepper@redhat.com>1998-05-08 12:32:47 +0000
commitfab6d621377dcd0ace90066684cff09cb26ba725 (patch)
treeebb9ddc285c78bdfdccfa5ba33eba7a2e57d6cae /iconv/gconv_conf.c
parentebcd12d4f11fac725e30b49a8dd1635ec0573eb5 (diff)
downloadglibc-fab6d621377dcd0ace90066684cff09cb26ba725.tar.gz
Update.
1998-05-08 12:26 Ulrich Drepper <drepper@cygnus.com> * iconv/gconv_int.h (struct gconv_module): Remove cost field and add cost_hi and cost_lo. * iconv/gconv_conf.c (builtin_modules): Initialize cost_hi from Cost parameter and set cost_lo to INT_MAX. (add_module): Take new parameter and use it to initialize cost_lo. (read_conf_file): Count modules being loaded and use counter for new parameter to add_module. * iconv/gconv_db.c (find_derivation): When look for cost examine cost_hi and cost_lo. 1998-05-08 10:52 Ulrich Drepper <drepper@cygnus.com> * string/bits/string2.h: Don't use unsigned char * unless really necessary since this disturbs C++. * sysdeps/i386/i486/bits/string.h: Likewise. Patch by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>. 1998-05-08 13:53 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * malloc/malloc.c (top_check): Fix last change.
Diffstat (limited to 'iconv/gconv_conf.c')
-rw-r--r--iconv/gconv_conf.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index ae5ba19e5d..6457e37113 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -20,6 +20,7 @@
#include <ctype.h>
#include <errno.h>
+#include <limits.h>
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
@@ -54,7 +55,8 @@ static struct gconv_module builtin_modules[] =
from_constpfx_len: ConstLen, \
from_regex: NULL, \
to_string: To, \
- cost: Cost, \
+ cost_hi: Cost, \
+ cost_lo: INT_MAX, \
module_name: Name \
},
#define BUILTIN_ALIAS(From, To)
@@ -151,7 +153,7 @@ add_alias (char *rp)
/* Add new module. */
static inline void
add_module (char *rp, const char *directory, size_t dir_len, void **modules,
- size_t *nmodules)
+ size_t *nmodules, int modcounter)
{
/* We expect now
1. `from' name
@@ -164,7 +166,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
size_t const_len;
int from_is_regex;
int need_ext;
- int cost;
+ int cost_hi;
while (isspace (*rp))
++rp;
@@ -198,7 +200,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
{
/* There is no cost, use one by default. */
*wp++ = '\0';
- cost = 1;
+ cost_hi = 1;
}
else
{
@@ -206,10 +208,10 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
char *endp;
*wp++ = '\0';
- cost = strtol (rp, &endp, 10);
+ cost_hi = strtol (rp, &endp, 10);
if (rp == endp)
/* No useful information. */
- cost = 1;
+ cost_hi = 1;
}
if (module[0] == '\0')
@@ -264,7 +266,8 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
new_module->to_string = memcpy ((char *) new_module->from_constpfx
+ (to - from), to, module - to);
- new_module->cost = cost;
+ new_module->cost_hi = cost_hi;
+ new_module->cost_lo = modcounter;
new_module->module_name = (char *) new_module->to_string + (module - to);
@@ -314,6 +317,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
FILE *fp = fopen (filename, "r");
char *line = NULL;
size_t line_len = 0;
+ int modcounter = 0;
/* Don't complain if a file is not present or readable, simply silently
ignore it. */
@@ -356,7 +360,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
add_alias (rp);
else if (rp - word == sizeof ("module") - 1
&& memcmp (word, "module", sizeof ("module") - 1) == 0)
- add_module (rp, directory, dir_len, modules, nmodules);
+ add_module (rp, directory, dir_len, modules, nmodules, modcounter++);
/* else */
/* Otherwise ignore the line. */
}