This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[patch] time/tzset.c: Fix problem with missing /etc/localtime showing wrong TZ
- To: GNU C Library <libc-alpha at sourceware dot cygnus dot com>
- Subject: [patch] time/tzset.c: Fix problem with missing /etc/localtime showing wrong TZ
- From: Ben Collins <bcollins at debian dot org>
- Date: Tue, 2 Jan 2001 20:28:13 -0500
If env TZ is not set, and /etc/localtime is not present, then the
timezone showed up as "/etc/localtime" instead of the default UTC, as
the code tries to do. This patch fixes that issue.
One odd thing I saw here, is that all the tests for tz == NULL (other
than the first test after getenv()) are superflous, since the only way
that tz can be NULL, is if TZ is not set, and TZDEFAULT itself is
defined as NULL. Assuming that TZDEFAULT is never going to be NULL,
could reduce some code here. Is that a safe assumption?
2001-01-02 Ben Collins <bcollins@debian.org>
* time/tzset.c: tzset_internal(): Make sure we fall back to UTC
if TZ is not set and TZDEFAULT is not present.
--
-----------=======-=-======-=========-----------=====------------=-=------
/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` bcollins@debian.org -- bcollins@openldap.org -- bcollins@linux.com '
`---=========------=======-------------=-=-----=-===-======-------=--=---'
Index: time/tzset.c
===================================================================
RCS file: /cvs/glibc/libc/time/tzset.c,v
retrieving revision 1.68
diff -u -u -r1.68 tzset.c
--- tzset.c 2000/08/24 08:28:11 1.68
+++ tzset.c 2001/01/03 01:21:45
@@ -175,7 +175,7 @@
/* No data file found. Default to UTC if nothing specified. */
- if (tz == NULL || *tz == '\0')
+ if (tz == NULL || *tz == '\0' || (TZDEFAULT != NULL && strcmp(tz,TZDEFAULT) == 0))
{
tz_rules[0].name = tz_rules[1].name = "UTC";
tz_rules[0].type = tz_rules[1].type = J0;