zic, zdump, date patch needed for proper handling of locales

Paul Eggert eggert at CS.UCLA.EDU
Thu Jul 29 22:54:47 UTC 2004


Andreas Schwab <schwab at suse.de> writes:

>> 2000-10-23  Jakub Jelinek  <jakub at redhat.com>
>>
>>         * timezone/zdump.c (main): setlocale LC_CTYPE as well as LC_MESSAGES.
>>         * timezone/zic.c (main): Likewise.
>
> It would be nice if that would be included upstream.

OK, here's a patch suitable for inclusion in the tz sources, which I'm
sending to the tz list.

The problem here is that one can't reliably set parts of a locale
without setting them consistently; otherwise the behavior is
undefined, and on some hosts things go very badly.  The problem here
is with LC_CTYPE, but it could occur in other locale components.  The
simplest fix is to use LC_ALL, which sets everything consistently.

===================================================================
RCS file: RCS/date.c,v
retrieving revision 2001.4.0.1
retrieving revision 2001.4.0.2
diff -pu -r2001.4.0.1 -r2001.4.0.2
--- date.c	2004/06/15 05:53:49	2001.4.0.1
+++ date.c	2004/07/29 22:50:01	2001.4.0.2
@@ -117,13 +117,12 @@ char *		argv[];
 	INITIALIZE(adjust);
 	INITIALIZE(t);
 #if HAVE_GETTEXT - 0
-	(void) setlocale(LC_MESSAGES, "");
+	(void) setlocale(LC_ALL, "");
 #ifdef TZ_DOMAINDIR
 	(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
 #endif /* defined(TEXTDOMAINDIR) */
 	(void) textdomain(TZ_DOMAIN);
 #endif /* HAVE_GETTEXT - 0 */
-	(void) setlocale(LC_TIME, "");
 	(void) time(&now);
 	format = value = NULL;
 	while ((ch = getopt(argc, argv, "ucnd:t:a:")) != EOF && ch != -1) {
===================================================================
RCS file: RCS/zdump.c,v
retrieving revision 2004.2.0.1
retrieving revision 2004.2.0.2
diff -pu -r2004.2.0.1 -r2004.2.0.2
--- zdump.c	2004/07/20 23:27:39	2004.2.0.1
+++ zdump.c	2004/07/29 22:50:01	2004.2.0.2
@@ -184,7 +184,7 @@ char *	argv[];
 	struct tm *		newtm;
 
 #if HAVE_GETTEXT - 0
-	(void) setlocale(LC_MESSAGES, "");
+	(void) setlocale(LC_ALL, "");
 #ifdef TZ_DOMAINDIR
 	(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
 #endif /* defined(TEXTDOMAINDIR) */
===================================================================
RCS file: RCS/zic.c,v
retrieving revision 2004.1
retrieving revision 2004.1.0.1
diff -pu -r2004.1 -r2004.1.0.1
--- zic.c	2004/03/02 15:54:30	2004.1
+++ zic.c	2004/07/29 22:50:01	2004.1.0.1
@@ -467,7 +467,7 @@ char *	argv[];
 	(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
 #endif /* defined unix */
 #if HAVE_GETTEXT - 0
-	(void) setlocale(LC_MESSAGES, "");
+	(void) setlocale(LC_ALL, "");
 #ifdef TZ_DOMAINDIR
 	(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
 #endif /* defined TEXTDOMAINDIR */



More information about the tz mailing list