Initialize LC_MESSAGES at start-up
authorKarl Williamson <public@khwilliamson.com>
Sat, 15 Feb 2014 21:26:46 +0000 (14:26 -0700)
committerKarl Williamson <public@khwilliamson.com>
Sat, 15 Feb 2014 22:50:35 +0000 (15:50 -0700)
The code did not explicitly iinitialize LC_MESSAGES at startup, unlike
most of the other standard categories; I don't know why.

This is only an issue for those few platforms without LC_ALL, as that is
initialized, and includes LC_MESSAGES.  This commit extends the proper
initialization to those other platforms.

locale.c

index e024f35..e504a8d 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -516,6 +516,14 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
        else
            curnum = savepv(curnum);
 #       endif /* USE_LOCALE_NUMERIC */
+#       ifdef USE_LOCALE_MESSAGES
+       if (! my_setlocale(LC_MESSAGES,
+                        (!done && (lang || PerlEnv_getenv("LC_MESSAGES")))
+                                 ? setlocale_init : NULL))
+        {
+           setlocale_failure = TRUE;
+        }
+#       endif /* USE_LOCALE_MESSAGES */
     }
 
 #   endif /* LC_ALL */
@@ -588,6 +596,10 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
             else
                 curnum = savepv(curnum);
 #endif /* USE_LOCALE_NUMERIC */
+#ifdef USE_LOCALE_MESSAGES
+            if (! (my_setlocale(LC_MESSAGES, trial_locale)))
+                setlocale_failure = TRUE;
+#endif /* USE_LOCALE_MESSAGES */
             if (! setlocale_failure) {  /* Success */
                 break;
             }
@@ -621,7 +633,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
                 if (! curnum)
                     PerlIO_printf(Perl_error_log, "LC_NUMERIC ");
 #endif /* USE_LOCALE_NUMERIC */
-                PerlIO_printf(Perl_error_log, "\n");
+                PerlIO_printf(Perl_error_log, "and possibly others\n");
 
 #endif /* LC_ALL */