Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time Update to tzcode2022f



details:   https://anonhg.NetBSD.org/src/rev/04b7ee3d4638
branches:  trunk
changeset: 372177:04b7ee3d4638
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 29 13:55:50 2022 +0000

description:
Update to tzcode2022f

  Changes to code

    zic now supports links to links regardless of input line order.
    For example, if Australia/Sydney is a Zone, the lines
      Link Australia/Canberra Australia/ACT
      Link Australia/Sydney Australia/Canberra
    now work correctly, even though the shell commands
      ln Australia/Canberra Australia/ACT
      ln Australia/Sydney Australia/Canberra
    would fail because the first command attempts to use a link
    Australia/Canberra that does not exist until after the second
    command is executed.  Previously, zic had unspecified behavior if
    a Link line's target was another link, and zic often misbehaved if
    a Link line's target was a later Link line.

    Fix line number in zic's diagnostic for a link to a link.

    Fix a bug that caused localtime to mishandle timestamps starting
    in the year 2438 when reading data generated by 'zic -b fat' when
    distant-future DST transitions occur at times given in standard
    time or in UT, not the usual case of local time.  This occurs when
    the corresponding .zi Rule lines specify DST transitions with TO
    columns of 'max' and AT columns that end in 's' or 'u'.  The
    number 2438 comes from the 32-bit limit in the year 2038, plus the
    400-year Gregorian cycle.  (Problem reported by Bradley White.)

    On glibc 2.34 and later, which optionally supports 64-bit time_t
    on platforms like x86 where time_t was traditionally 32 bits,
    default time_t to 64 instead of 32 bits.  This lets functions like
    localtime support timestamps after the year 2038, and fixes
    year-2038 problems in zic when accessing files dated after 2038.
    To continue to limit time_t to 32 bits on these platforms, use
    "make CFLAGS='-D_TIME_BITS=32'".

    In C code, do not enable large-file support on platforms like AIX
    and macOS that no longer need it now that tzcode does not use
    off_t or related functions like 'stat'.  Large-file support is
    still enabled by default on GNU/Linux, as it is needed for 64-bit
    time_t support.

    In C code, prefer C23 keywords to pre-C23 macros for alignof,
    bool, false, and true.  Also, use the following C23 features if
    available: __has_include, unreachable.

    zic no longer works around Qt bug 53071, as the relevant Qt
    releases have been out of support since 2019.  This change affects
    only fat TZif files, as thin files never had the workaround.

    zdump no longer modifies the environ vector when compiled on
    platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
    This avoid undefined behavior on POSIX platforms.

diffstat:

 lib/libc/time/Makefile    |   40 ++-
 lib/libc/time/NEWS        |  101 ++++++++++
 lib/libc/time/localtime.c |   12 +-
 lib/libc/time/private.h   |  112 ++++++----
 lib/libc/time/theory.html |    1 +
 lib/libc/time/version     |    2 +-
 lib/libc/time/zdump.c     |   89 ++++----
 lib/libc/time/zic.8       |   25 ++-
 lib/libc/time/zic.c       |  449 ++++++++++++++++++++++++++++++++-------------
 9 files changed, 593 insertions(+), 238 deletions(-)

diffs (truncated from 1496 to 300 lines):

diff -r 6284c39e86c0 -r 04b7ee3d4638 lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Sat Oct 29 13:53:35 2022 +0000
+++ b/lib/libc/time/Makefile    Sat Oct 29 13:55:50 2022 +0000
@@ -210,7 +210,8 @@
 #  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
 #  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
 #  -DHAVE_GENERIC=0 if _Generic does not work
-#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)
+#  -DHAVE_GETRANDOM if getgrandom works (e.g., GNU/Linux)*
+#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)*
 #  -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
 #      ctime_r and asctime_r incompatibly with the POSIX standard
 #      (Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
@@ -222,16 +223,17 @@
 #  -DHAVE_MALLOC_ERRNO=0 if malloc etc. do not set errno on failure.
 #  -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
 #      functions like 'link' or variables like 'tzname' required by POSIX
+#  -DHAVE_SETENV=0 if your system lacks the setenv function
 #  -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
-#  -DHAVE_STDBOOL_H if you have a non-C99 compiler with <stdbool.h>
-#  -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h>
+#  -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h>*
 #  -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
 #  -DHAVE_STRDUP=0 if your system lacks the strdup function
 #  -DHAVE_STRTOLL=0 if your system lacks the strtoll function
 #  -DHAVE_SYMLINK=0 if your system lacks the symlink function
-#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h>
+#  -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h>*
 #  -DHAVE_TZSET=0 if your system lacks a tzset function
-#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>
+#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>*
+#  -DHAVE_UTMPX_H=0 if your compiler lacks a <utmpx.h>*
 #  -Dlocale_t=XXX if your system uses XXX instead of locale_t
 #  -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
 #      with external linkage, e.g., applications cannot define 'localtime'.
@@ -254,14 +256,17 @@
 #      Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
 #  -DZIC_BLOAT_DEFAULT=\"fat\" to default zic's -b option to "fat", and
 #      similarly for "slim".  Fat TZif files work around incompatibilities
-#      and bugs in some TZif readers, notably readers that mishandle 64-bit
-#      data in TZif files.  Slim TZif files are more efficient and do not
-#      work around these incompatibilities and bugs.  If not given, the
-#      default is "slim".
+#      and bugs in some TZif readers, notably older ones that
+#      ignore or otherwise mishandle 64-bit data in TZif files;
+#      however, fat TZif files may trigger bugs in newer TZif readers.
+#      Slim TZif files are more efficient, and are the default.
 #  -DZIC_MAX_ABBR_LEN_WO_WARN=3
 #      (or some other number) to set the maximum time zone abbreviation length
 #      that zic will accept without a warning (the default is 6)
 #  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
+#
+# * Options marked "*" can be omitted if your compiler is C23 compatible.
+#
 # Select instrumentation via "make GCC_INSTRUMENT='whatever'".
 GCC_INSTRUMENT = \
   -fsanitize=undefined -fsanitize-address-use-after-scope \
@@ -397,8 +402,9 @@
 
 # To shrink the size of installed TZif files,
 # append "-r @N" to omit data before N-seconds-after-the-Epoch.
-# To grow the files and work around older application bugs, append "-b fat";
-# see ZIC_BLOAT_DEFAULT above.
+# To grow the files and work around bugs in older applications,
+# possibly at the expense of introducing bugs in newer ones,
+# append "-b fat"; see ZIC_BLOAT_DEFAULT above.
 # See the zic man page for more about -b and -r.
 ZFLAGS=
 
@@ -818,13 +824,19 @@
 CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
 
 check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
-               $(AWK) '/^Link/ {print $$3}' backward | LC_ALL=C sort -cu
+               $(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} /^$$/ {g++}' \
+                 backward | LC_ALL=C sort -cu
                $(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu
                touch $@
 
 check_links:   checklinks.awk $(TDATA_TO_CHECK) tzdata.zi
-               $(AWK) -f checklinks.awk $(TDATA_TO_CHECK)
-               $(AWK) -f checklinks.awk tzdata.zi
+               $(AWK) \
+                 -v DATAFORM=$(DATAFORM) \
+                 -v backcheck=backward \
+                 -f checklinks.awk $(TDATA_TO_CHECK)
+               $(AWK) \
+                 -v DATAFORM=$(DATAFORM) \
+                 -f checklinks.awk tzdata.zi
                touch $@
 
 check_tables:  checktab.awk $(YDATA) backward $(ZONETABLES)
diff -r 6284c39e86c0 -r 04b7ee3d4638 lib/libc/time/NEWS
--- a/lib/libc/time/NEWS        Sat Oct 29 13:53:35 2022 +0000
+++ b/lib/libc/time/NEWS        Sat Oct 29 13:55:50 2022 +0000
@@ -1,5 +1,106 @@
 News for the tz database
 
+Release 2022f - 2022-10-28 18:04:57 -0700
+
+  Briefly:
+    Mexico will no longer observe DST except near the US border.
+    Chihuahua moves to year-round -06 on 2022-10-30.
+    Fiji no longer observes DST.
+    Move links to 'backward'.
+    In vanguard form, GMT is now a Zone and Etc/GMT a link.
+    zic now supports links to links, and vanguard form uses this.
+    Simplify four Ontario zones.
+    Fix a Y2438 bug when reading TZif data.
+    Enable 64-bit time_t on 32-bit glibc platforms.
+    Omit large-file support when no longer needed.
+    In C code, use some C23 features if available.
+    Remove no-longer-needed workaround for Qt bug 53071.
+
+  Changes to future timestamps.
+
+    Mexico will no longer observe DST after 2022, except for areas
+    near the US border that continue to observe US DST rules.
+    On 2022-10-30 at 02:00 the Mexican state of Chihuahua moves
+    from -07 (-06 with DST) to year-round -06, thus not changing
+    its clocks that day.  The new law states that Chihuahua
+    near the US border no longer observes US DST.
+
+    Fiji will not observe DST in 2022/3.  (Thanks to Shalvin Narayan.)
+    For now, assume DST is suspended indefinitely.
+
+  Changes to data
+
+    Move links to 'backward' to ease and simplify link maintenance.
+    This affects generated data only if you use 'make BACKWARD='.
+
+    GMT is now a Zone and Etc/GMT a link instead of vice versa,
+    as GMT is needed for leap second support whereas Etc/GMT is not.
+    However, this change exposes a bug in TZUpdater 2.3.2 so it is
+    present only in vanguard form for now.
+
+    Vanguard form now uses links to links, as zic now supports this.
+
+  Changes to past timestamps
+
+    Simplify four Ontario zones, as most of the post-1970 differences
+    seem to have been imaginary.  (Problem reported by Chris Walton.)
+    Move America/Nipigon, America/Rainy_River, and America/Thunder_Bay
+    to 'backzone'; backward-compatibility links still work, albeit
+    with some different timestamps before November 2005.
+
+  Changes to code
+
+    zic now supports links to links regardless of input line order.
+    For example, if Australia/Sydney is a Zone, the lines
+      Link Australia/Canberra Australia/ACT
+      Link Australia/Sydney Australia/Canberra
+    now work correctly, even though the shell commands
+      ln Australia/Canberra Australia/ACT
+      ln Australia/Sydney Australia/Canberra
+    would fail because the first command attempts to use a link
+    Australia/Canberra that does not exist until after the second
+    command is executed.  Previously, zic had unspecified behavior if
+    a Link line's target was another link, and zic often misbehaved if
+    a Link line's target was a later Link line.
+
+    Fix line number in zic's diagnostic for a link to a link.
+
+    Fix a bug that caused localtime to mishandle timestamps starting
+    in the year 2438 when reading data generated by 'zic -b fat' when
+    distant-future DST transitions occur at times given in standard
+    time or in UT, not the usual case of local time.  This occurs when
+    the corresponding .zi Rule lines specify DST transitions with TO
+    columns of 'max' and AT columns that end in 's' or 'u'.  The
+    number 2438 comes from the 32-bit limit in the year 2038, plus the
+    400-year Gregorian cycle.  (Problem reported by Bradley White.)
+
+    On glibc 2.34 and later, which optionally supports 64-bit time_t
+    on platforms like x86 where time_t was traditionally 32 bits,
+    default time_t to 64 instead of 32 bits.  This lets functions like
+    localtime support timestamps after the year 2038, and fixes
+    year-2038 problems in zic when accessing files dated after 2038.
+    To continue to limit time_t to 32 bits on these platforms, use
+    "make CFLAGS='-D_TIME_BITS=32'".
+
+    In C code, do not enable large-file support on platforms like AIX
+    and macOS that no longer need it now that tzcode does not use
+    off_t or related functions like 'stat'.  Large-file support is
+    still enabled by default on GNU/Linux, as it is needed for 64-bit
+    time_t support.
+
+    In C code, prefer C23 keywords to pre-C23 macros for alignof,
+    bool, false, and true.  Also, use the following C23 features if
+    available: __has_include, unreachable.
+
+    zic no longer works around Qt bug 53071, as the relevant Qt
+    releases have been out of support since 2019.  This change affects
+    only fat TZif files, as thin files never had the workaround.
+
+    zdump no longer modifies the environ vector when compiled on
+    platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
+    This avoid undefined behavior on POSIX platforms.
+
+
 Release 2022e - 2022-10-11 11:13:02 -0700
 
   Briefly:
diff -r 6284c39e86c0 -r 04b7ee3d4638 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Sat Oct 29 13:53:35 2022 +0000
+++ b/lib/libc/time/localtime.c Sat Oct 29 13:55:50 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.134 2022/08/16 10:56:21 christos Exp $ */
+/*     $NetBSD: localtime.c,v 1.135 2022/10/29 13:55:50 christos Exp $ */
 
 /* Convert timestamp from time_t to struct tm.  */
 
@@ -12,7 +12,7 @@
 #if 0
 static char    elsieid[] = "@(#)localtime.c    8.17";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.134 2022/08/16 10:56:21 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.135 2022/10/29 13:55:50 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -858,12 +858,14 @@
                b < 0 || b >= sp->typecnt)
                        result = false;
        else {
+               /* Compare the relevant members of *AP and *BP.
+                  Ignore tt_ttisstd and tt_ttisut, as they are
+                  irrelevant now and counting them could cause
+                  sp->goahead to mistakenly remain false.  */
                register const struct ttinfo *  ap = &sp->ttis[a];
                register const struct ttinfo *  bp = &sp->ttis[b];
                result = (ap->tt_utoff == bp->tt_utoff
                          && ap->tt_isdst == bp->tt_isdst
-                         && ap->tt_ttisstd == bp->tt_ttisstd
-                         && ap->tt_ttisut == bp->tt_ttisut
                          && (strcmp(&sp->chars[ap->tt_desigidx],
                                     &sp->chars[bp->tt_desigidx])
                              == 0));
@@ -1158,7 +1160,7 @@
                        value += mon_lengths[leapyear][i] * SECSPERDAY;
                break;
 
-       default: UNREACHABLE();
+       default: unreachable();
        }
 
        /*
diff -r 6284c39e86c0 -r 04b7ee3d4638 lib/libc/time/private.h
--- a/lib/libc/time/private.h   Sat Oct 29 13:53:35 2022 +0000
+++ b/lib/libc/time/private.h   Sat Oct 29 13:55:50 2022 +0000
@@ -1,6 +1,6 @@
 /* Private header for tzdb code.  */
 
-/*     $NetBSD: private.h,v 1.60 2022/08/16 11:07:40 christos Exp $    */
+/*     $NetBSD: private.h,v 1.61 2022/10/29 13:55:50 christos Exp $    */
 
 #ifndef PRIVATE_H
 #define PRIVATE_H
@@ -29,6 +29,15 @@
 ** Thank you!
 */
 
+/* Define true, false and bool if they don't work out of the box.  */
+#if __STDC_VERSION__ < 199901
+# define true 1
+# define false 0
+# define bool int
+#elif __STDC_VERSION__ < 202311
+# include <stdbool.h>
+#endif
+
 /*
 ** zdump has been made independent of the rest of the time
 ** conversion package to increase confidence in the verification it provides.
@@ -66,9 +75,25 @@
 # define HAVE_GENERIC (201112 <= __STDC_VERSION__)
 #endif
 
+#if !defined HAVE_GETRANDOM && defined __has_include
+# if __has_include(<sys/random.h>)
+#  define HAVE_GETRANDOM true
+# else
+#  define HAVE_GETRANDOM false
+# endif
+#endif
+#ifndef HAVE_GETRANDOM
+# define HAVE_GETRANDOM (2 < __GLIBC__ + (25 <= __GLIBC_MINOR__))
+#endif
+
+#if !defined HAVE_GETTEXT && defined __has_include
+# if __has_include(<libintl.h>)
+#  define HAVE_GETTEXT true
+# endif
+#endif
 #ifndef HAVE_GETTEXT
-# define HAVE_GETTEXT 0
-#endif /* !defined HAVE_GETTEXT */
+# define HAVE_GETTEXT false
+#endif
 
 #ifndef HAVE_INCOMPATIBLE_CTIME_R



Home | Main Index | Thread Index | Old Index