From fab6d621377dcd0ace90066684cff09cb26ba725 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 8 May 1998 12:32:47 +0000 Subject: Update. 1998-05-08 12:26 Ulrich Drepper * 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 * 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 . 1998-05-08 13:53 Andreas Schwab * malloc/malloc.c (top_check): Fix last change. --- iconv/gconv_db.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'iconv/gconv_db.c') diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c index 62d8f0540c..503c5d0c86 100644 --- a/iconv/gconv_db.c +++ b/iconv/gconv_db.c @@ -261,7 +261,8 @@ find_derivation (const char *toset, const char *toset_expand, { __libc_lock_define_initialized (static, lock) struct derivation_step *first, *current, **lastp, *best = NULL; - int best_cost = 0; + int best_cost_hi = 0; + int best_cost_lo = 0; int result; result = derivation_lookup (fromset_expand ?: fromset, toset_expand ?: toset, @@ -429,18 +430,22 @@ find_derivation (const char *toset, const char *toset_expand, /* Determine the costs. If they are lower than the previous solution (or this is the first solution) remember this solution. */ - int cost = __gconv_modules_db[cnt]->cost; + int cost_hi = __gconv_modules_db[cnt]->cost_hi; + int cost_lo = __gconv_modules_db[cnt]->cost_lo; struct derivation_step *runp = current; while (runp->code != NULL) { - cost += runp->code->cost; + cost_hi += runp->code->cost_hi; + cost_lo += runp->code->cost_lo; runp = runp->last; } - if (best == NULL || cost < best_cost) + if (best == NULL || cost_hi < best_cost_hi + || (cost_hi == best_cost_hi && cost_lo < best_cost_lo)) { best = NEW_STEP (result_set, __gconv_modules_db[cnt], current); - best_cost = cost; + best_cost_hi = cost_hi; + best_cost_lo = cost_lo; } } else -- cgit v1.2.3