From 47ccb39924da61da726ad6a8484c183aa70f075c Mon Sep 17 00:00:00 2001 From: hniksic Date: Fri, 6 May 2005 06:55:35 -0700 Subject: [PATCH] [svn] Explain the choice of only setting LC_MESSAGES more thoroughly. --- src/main.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main.c b/src/main.c index 836ae3c8..43c00b0d 100644 --- a/src/main.c +++ b/src/main.c @@ -83,25 +83,27 @@ static RETSIGTYPE redirect_output_signal PARAMS ((int)); const char *exec_name; -/* 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