]> sjero.net Git - wget/commitdiff
[svn] Explain the choice of only setting LC_MESSAGES more thoroughly.
authorhniksic <devnull@localhost>
Fri, 6 May 2005 13:55:35 +0000 (06:55 -0700)
committerhniksic <devnull@localhost>
Fri, 6 May 2005 13:55:35 +0000 (06:55 -0700)
src/main.c

index 836ae3c8e27984dbaf3d28fdcad021ffa2219470..43c00b0d7cfd55774f533ebc2dc257755c0e5650 100644 (file)
@@ -83,25 +83,27 @@ static RETSIGTYPE redirect_output_signal PARAMS ((int));
 
 const char *exec_name;
 \f
-/* Initialize I18N.  The initialization amounts to invoking
-   setlocale(), bindtextdomain() and textdomain().
-   Does nothing if NLS is disabled or missing.  */
+/* Initialize I18N/L10N.  That amounts to invoking setlocale, and
+   setting up gettext's message catalog using bindtextdomain and
+   textdomain.  Does nothing if NLS is disabled or missing.  */
+
 static void
 i18n_initialize (void)
 {
-  /* If HAVE_NLS is defined, assume the existence of the three
-     functions invoked here.  */
+  /* HAVE_NLS implies existence of functions invoked here.  */
 #ifdef HAVE_NLS
   /* Set the current locale.  */
-  /* Here we use LC_MESSAGES instead of LC_ALL, for two reasons.
-     First, message catalogs are all of I18N Wget uses anyway.
-     Second, setting LC_ALL has a dangerous potential of messing
-     things up.  For example, when in a foreign locale, Solaris
-     strptime() fails to handle international dates correctly, which
-     makes http_atotm() malfunction.  */
-#ifdef LC_MESSAGES
+  /* Where possible, sets only LC_MESSAGES and LC_CTYPE.  Other
+     categories, such as numeric, time, or collation, break code that
+     parses data received from the network and relies on C-locale
+     behavior of libc functions.  For example, Solaris strptime fails
+     to recognize English month names in non-English locales, which
+     breaks http_atotm.  Some implementations of fnmatch perform
+     unwanted case folding in non-C locales.  ctype macros, while they
+     were used, provided another example against LC_ALL.  */
+#if defined(LC_MESSAGES) && defined(LC_CTYPE)
   setlocale (LC_MESSAGES, "");
-  setlocale (LC_CTYPE, "");
+  setlocale (LC_CTYPE, "");    /* safe because we use safe-ctype */
 #else
   setlocale (LC_ALL, "");
 #endif