Ensure that setlocale (LC_MESSAGES is called when appropriate.
[pspp-builds.git] / src / libpspp / i18n.c
index f10a52a50e271a4081bfff8252429d4b3edc856f..fb3973f437bb737d0ba53011596da1f844588509 100644 (file)
@@ -128,6 +128,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 +164,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,7 +190,7 @@ i18n_init (void)
 {
 #if ENABLE_NLS
   setlocale (LC_CTYPE, "");
-#if HAVE_LC_MESSAGES
+#ifdef LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
 #if HAVE_LC_PAPER