X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fi18n.c;h=7fd7580e89d0d12fff978dbb35c6b95981758a00;hb=77dc491d3b0c1429801ec839e7afab0fbef6a7fc;hp=293276c6aa9416f4bc4579b6d5ae266745610418;hpb=20b64bf74741594e1f1767c0fd12c5f5da5ea58c;p=pspp-builds.git diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index 293276c6..7fd7580e 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "assertion.h" #include "hmapx.h" #include "hash-functions.h" @@ -57,7 +58,7 @@ create_iconv (const char* tocode, const char* fromcode) struct hmapx_node *node; struct converter *converter; - hash = hsh_hash_string (tocode) ^ hsh_hash_string (fromcode); + hash = hash_string (tocode, hash_string (fromcode, 0)); HMAPX_FOR_EACH_WITH_HASH (converter, node, hash, &map) if (!strcmp (tocode, converter->tocode) && !strcmp (fromcode, converter->fromcode)) @@ -68,7 +69,7 @@ create_iconv (const char* tocode, const char* fromcode) converter->fromcode = xstrdup (fromcode); converter->conv = iconv_open (tocode, fromcode); hmapx_insert (&map, converter, hash); - + /* I don't think it's safe to translate this string or to use messaging as the convertors have not yet been set up */ if ( (iconv_t) -1 == converter->conv && 0 != strcmp (tocode, fromcode)) @@ -128,6 +129,9 @@ recode_string (const char *to, const char *from, conv = create_iconv (to, from); + if ( (iconv_t) -1 == conv ) + return xstrdup (text); + do { const char *ip = text; result = iconv (conv, (ICONV_CONST char **) &text, &inbytes, @@ -161,6 +165,7 @@ recode_string (const char *to, const char *from, break; default: /* should never happen */ + fprintf (stderr, "Character conversion error: %s\n", strerror (the_error)); NOT_REACHED (); break; } @@ -186,13 +191,13 @@ i18n_init (void) { #if ENABLE_NLS setlocale (LC_CTYPE, ""); -#if HAVE_LC_MESSAGES +#ifdef LC_MESSAGES setlocale (LC_MESSAGES, ""); #endif #if HAVE_LC_PAPER setlocale (LC_PAPER, ""); #endif - bindtextdomain (PACKAGE, locale_dir); + bindtextdomain (PACKAGE, relocate(locale_dir)); textdomain (PACKAGE); #endif /* ENABLE_NLS */