This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Fix multiple minor tzset glitches [BZ #24004]
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: libc-alpha at sourceware dot org
- Cc: Paul Eggert <eggert at cs dot ucla dot edu>
- Date: Mon, 11 Feb 2019 08:37:28 -0800
- Subject: [PATCH] Fix multiple minor tzset glitches [BZ #24004]
Avoid polling if TZ is unset.
Consistently ignore leading ":" in TZ as per documentation.
Treat TZ="" as Universal Time without leap seconds,
for consistency with upstream.
* time/tzset.c (tzset_internal): Check for null TZ first.
Do not substitute "Universal" for ""; this is __tzfile_read’s
job and we were doing it incorrectly as we treated TZ=""
differently from TZ=":".
* time/tzfile.c (__tzfile_read): Simplify, as FILE cannot be null.
---
ChangeLog | 13 +++++++++++++
NEWS | 7 +++++++
time/tzfile.c | 5 +----
time/tzset.c | 15 ++++++---------
4 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6f1d967f62..831d89ba8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-02-11 Paul Eggert <eggert@cs.ucla.edu>
+
+ Fix multiple minor tzset glitches [BZ #24004]
+ Avoid polling if TZ is unset.
+ Consistently ignore leading ":" in TZ as per documentation.
+ Treat TZ="" as Universal Time without leap seconds,
+ for consistency with upstream.
+ * time/tzset.c (tzset_internal): Check for null TZ first.
+ Do not substitute "Universal" for ""; this is __tzfile_read’s
+ job and we were doing it incorrectly as we treated TZ=""
+ differently from TZ=":".
+ * time/tzfile.c (__tzfile_read): Simplify, as FILE cannot be null.
+
2019-02-11 Paul A. Clarke <pc@us.ibm.com>
* sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf):
diff --git a/NEWS b/NEWS
index 0a3b6c7a5a..87de5030c1 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,13 @@ Deprecated and removed features, and other changes affecting compatibility:
definitions in libc will be used automatically, which have been available
since glibc 2.17.
+* If the TZ environment variable is unset, functions like localtime no
+ longer stat the file /etc/localtime if the file has already been
+ consulted. Instead, they reuse the cached timezone info, just as they
+ would with TZ="/etc/localtime". If TZ="", these functions now omit leap
+ seconds even on unusual installations where TZ="Universal" identifies a
+ TZif file with leap seconds; this is for consistency with tzcode and BSD.
+
Changes to build and runtime requirements:
* GCC 6.2 or later is required to build the GNU C Library.
diff --git a/time/tzfile.c b/time/tzfile.c
index 7229ed93b7..db66f22a4e 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -115,10 +115,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
__use_tzfile = 0;
- if (file == NULL)
- /* No user specification; use the site-wide default. */
- file = TZDEFAULT;
- else if (*file == '\0')
+ if (*file == '\0')
/* User specified the empty string; use UTC with no leap seconds. */
goto ret_free_transitions;
else
diff --git a/time/tzset.c b/time/tzset.c
index 307eb651ad..1903ef864d 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -375,25 +375,22 @@ tzset_internal (int always)
/* Examine the TZ environment variable. */
tz = getenv ("TZ");
- if (tz && *tz == '\0')
- /* User specified the empty string; use UTC explicitly. */
- tz = "Universal";
+
+ if (tz == NULL)
+ /* No user specification; use the site-wide default. */
+ tz = TZDEFAULT;
/* A leading colon means "implementation defined syntax".
We ignore the colon and always use the same algorithm:
try a data file, and if none exists parse the 1003.1 syntax. */
- if (tz && *tz == ':')
+ if (*tz == ':')
++tz;
/* Check whether the value changed since the last run. */
- if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0)
+ if (old_tz != NULL && strcmp (tz, old_tz) == 0)
/* No change, simply return. */
return;
- if (tz == NULL)
- /* No user specification; use the site-wide default. */
- tz = TZDEFAULT;
-
tz_rules[0].name = NULL;
tz_rules[1].name = NULL;
--
2.20.1