mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Set all locale categories.
This commit is contained in:
parent
aeafe847f3
commit
2254e5c4e4
@ -1,3 +1,9 @@
|
||||
2005-06-27 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* main.c (i18n_initialize): Set all locale categories.
|
||||
|
||||
* http.c (http_atotm): Temporarily set locale to "C".
|
||||
|
||||
2005-06-27 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* http.c (gethttp): Improve "POST data file missing" error
|
||||
|
25
src/http.c
25
src/http.c
@ -38,6 +38,7 @@ so, delete this exception statement from your version. */
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "wget.h"
|
||||
#include "utils.h"
|
||||
@ -2635,7 +2636,14 @@ http_atotm (const char *time_string)
|
||||
(used in Set-Cookie, defined in the
|
||||
Netscape cookie specification.) */
|
||||
};
|
||||
const char *oldlocale;
|
||||
int i;
|
||||
time_t ret = (time_t) -1;
|
||||
|
||||
/* Solaris strptime fails to recognize English month names in
|
||||
non-English locales, which we work around by temporarily setting
|
||||
locale to C before invoking strptime. */
|
||||
oldlocale = setlocale (LC_TIME, "C");
|
||||
|
||||
for (i = 0; i < countof (time_formats); i++)
|
||||
{
|
||||
@ -2646,19 +2654,18 @@ http_atotm (const char *time_string)
|
||||
to prevent garbage from the stack influencing strptime. */
|
||||
xzero (t);
|
||||
|
||||
/* Solaris strptime fails to recognize English month names in
|
||||
non-English locales, which we work around by not setting the
|
||||
LC_TIME category. Another way would be to temporarily set
|
||||
locale to C before invoking strptime, but that's slow and
|
||||
messy. GNU strptime does not have this problem because it
|
||||
recognizes English month names along with the local ones. */
|
||||
|
||||
if (check_end (strptime (time_string, time_formats[i], &t)))
|
||||
return mktime_from_utc (&t);
|
||||
{
|
||||
ret = mktime_from_utc (&t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore the previous locale. */
|
||||
setlocale (LC_TIME, oldlocale);
|
||||
|
||||
/* All formats have failed. */
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Authorization support: We support three authorization schemes:
|
||||
|
13
src/main.c
13
src/main.c
@ -79,20 +79,7 @@ i18n_initialize (void)
|
||||
/* HAVE_NLS implies existence of functions invoked here. */
|
||||
#ifdef HAVE_NLS
|
||||
/* Set the current locale. */
|
||||
/* 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, ""); /* safe because we use safe-ctype */
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
#endif
|
||||
/* Set the text message domain. */
|
||||
bindtextdomain ("wget", LOCALEDIR);
|
||||
textdomain ("wget");
|
||||
|
Loading…
Reference in New Issue
Block a user