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