[25/59] Fix mishandling of default DST rule

Message ID 20250105055750.1668721-26-eggert@cs.ucla.edu (mailing list archive)
State New
Headers
Series time: sync mktime from Gnulib |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Paul Eggert Jan. 5, 2025, 5:57 a.m. UTC
  For timezone settings like TZ="AST4ADT" where POSIX says the
default is implementation-defined, time/tzfile.c has long had
vestiges of an old attempt to be upward compatible with UNIX
System V.  This code has not worked for decades and evidently is
not being used, so remove it and use the simpler fallback code
already present in time/tzset.c, which uses US DST.  Also, add a
few test cases to demonstrate some bugs in the removed code.
* time/tst-posixtz.c: Include stdckdint.h.
(tests): WHEN is now intmax_t, not time_t, to support
skipping tests after 2038 on 32-bit time_t.  All uses changed.
Make it const while we're at it.  Add several tests for AST4ADT.
* time/tzfile.c (rule_dstoff): Remove.  All uses removed.
(__tzfile_read): Remove args EXTRA, EXTRAP.  All uses changed.
(__tzfile_default): Remove.  All uses removed.
(__tzfile_compute): Remove no-longer-needed code dealing
with __tzfile_default.
* timezone/Makefile (build-testdata):
Add '-p $(posixrules)' option if compiling 'northamerica',
so that we can test non-use of posixrules.
* timezone/tst-timezone.c: Include stdbool.h, stdckdint.h.
(failed): Now bool, not int.  All uses changed.
(do_test): Test AST4ADT too.
---
 Makeconfig       | 16 +++++++---------
 NEWS             | 11 +++++------
 manual/time.texi |  8 +++-----
 3 files changed, 15 insertions(+), 20 deletions(-)
  

Patch

diff --git a/Makeconfig b/Makeconfig
index d0108d2caa..a4be5b0e21 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -285,19 +285,17 @@  ifndef leapseconds
 leapseconds = /dev/null
 endif
 
-# What timezone's DST rules should be used when a POSIX-style TZ
-# environment variable doesn't specify any rules.  For 1003.1 compliance
-# this timezone must use rules that are as U.S. federal law defines DST.
-# Run `make -C time echo-zonenames' to see a list of available zone names.
-# This setting can be changed with `zic -p TIMEZONE' at any time.
-# If you want POSIX.1 compatibility, use `America/New_York'.
+# What timezone's DST rules to use when testing that glibc does
+# not mishandle TZif files built with zic's obsolescent -p option.
+# This macro no longer affects glibc's code or installation.
 ifndef posixrules
 posixrules = America/New_York
 endif
 
-# Where to install the "posixrules" timezone file; this is file
-# whose contents $(posixrules) specifies.  If this is a relative
-# pathname, it is relative to $(zonedir).
+# Where to put the "posixrules" timezone file used during testing; this
+# is the file whose contents $(posixrules) specifies.
+# If this is a relative pathname, it is relative to $(zonedir).
+# Like posixrules, this macro no longer affects glibc's code or installation.
 ifndef posixrules-file
 posixrules-file = posixrules
 endif
diff --git a/NEWS b/NEWS
index 3e6227a448..a62fb8136d 100644
--- a/NEWS
+++ b/NEWS
@@ -84,12 +84,11 @@  Deprecated and removed features, and other changes affecting compatibility:
   explicitly because of the executable bit in GNU_STACK, and the stack is
   not already executable.  Instead, loading such objects will fail.
 
-* The default daylight saving rules for old Unix System V style TZ
-  strings like TZ="AST4ADT" are now those of current US DST.  Although
-  the rules were supposed to be those of /usr/share/zoneinfo/posixrules,
-  this feature, which has been disabled by default and marked obsolete
-  upstream in tzcode, did not work in either glibc or tzcode, and in
-  practice posixrules invariably specified current US DST anyway.
+* The US daylight saving rule is now the default for incomplete TZ
+  strings like TZ="AST4ADT" that use the TZ syntax from circa-1980s
+  Unix System V.  Formerly the rule was documented to be that of
+  /usr/share/zoneinfo/posixrules but this did not work and in practice
+  posixrules invariably specified the US rule anyway.
 
 Changes to build and runtime requirements:
 
diff --git a/manual/time.texi b/manual/time.texi
index 28d8912446..cff94cb48b 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -2759,11 +2759,9 @@  and offset for the corresponding daylight saving time zone; if the
 
 The remainder of the proleptic format, which starts with the first comma,
 describes when daylight saving time is in effect.  This remainder is
-optional and if omitted, @theglibc{} defaults to US daylight saving rules.
-rules that would be used if @env{TZ} had the value @t{"posixrules"}.
-However, other POSIX implementations default to different daylight
-saving rules, so portable @env{TZ} settings should not omit the
-remainder.
+optional and if omitted, @theglibc{} defaults to the US daylight saving rule.
+POSIX does not specify this default, so portable @env{TZ} settings
+should not omit the remainder.
 
 In the remainder, the @var{start} field is when daylight saving time goes into
 effect and the @var{end} field is when the change is made back to standard