Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/time Merge in 2022g:



details:   https://anonhg.NetBSD.org/src/rev/0055f25c80d0
branches:  trunk
changeset: 372608:0055f25c80d0
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 11 17:57:23 2022 +0000

description:
Merge in 2022g:

    Although tzcode still works with C89, bugs found in recent routine
    maintenance indicate that bitrot has set in and that in practice
    C89 is no longer used to build tzcode.  As it is a maintenance
    burden, support for C89 is planned to be removed soon.  Instead,
    please use compilers compatible with C99, C11, C17, or C23.

    timegm, which tzcode implemented in 1989, will finally be
    standardized 34 years later as part of C23, so timegm is now
    supported even if STD_INSPIRED is not defined.

    Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
    (Problem reported by Đoàn Trần Công Danh.)

    Fix bug in zic on hosts where malloc(0) yields NULL on success.
    (Problem reported by Tim McBrayer for AIX 6.1.)

    Fix zic configuration to avoid linkage failures on some platforms.
    (Problems reported by Gilmore Davidson and Igor Ivanov.)

    Work around MS-Windows nmake incompatibility with POSIX.
    (Problem reported by Manuela Friedrich.)

    Port mktime and strftime to debugging platforms where accessing
    uninitialized data has undefined behavior (strftime problem
    reported by Robert Elz).

    Check more carefully for unlikely integer overflows, preferring
    C23 <stdckdint.h> to overflow checking by hand, as the latter has
    had obscure bugs.

diffstat:

 lib/libc/time/Makefile     |   55 +++++---
 lib/libc/time/NEWS         |   89 +++++++++++++-
 lib/libc/time/ctime.3      |    7 +-
 lib/libc/time/localtime.c  |  102 +++++++++++---
 lib/libc/time/private.h    |  203 ++++++++++++++++++++++--------
 lib/libc/time/strftime.c   |   25 ++-
 lib/libc/time/theory.html  |    1 -
 lib/libc/time/time2posix.3 |   18 +-
 lib/libc/time/tzfile.5     |    8 +-
 lib/libc/time/tzselect.8   |    8 +-
 lib/libc/time/tzset.3      |    6 +-
 lib/libc/time/version      |    2 +-
 lib/libc/time/zdump.8      |    9 +-
 lib/libc/time/zdump.c      |  111 ++++++++++------
 lib/libc/time/zic.8        |    9 +-
 lib/libc/time/zic.c        |  298 ++++++++++++++++++++++++++------------------
 16 files changed, 644 insertions(+), 307 deletions(-)

diffs (truncated from 2090 to 300 lines):

diff -r fc038d8181f1 -r 0055f25c80d0 lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Sun Dec 11 17:35:56 2022 +0000
+++ b/lib/libc/time/Makefile    Sun Dec 11 17:57:23 2022 +0000
@@ -196,6 +196,7 @@
 UTF8_LOCALE=   en_US.utf8
 
 # Non-default libraries needed to link.
+# On some hosts, this should have -lintl unless CFLAGS has -DHAVE_GETTEXT=0.
 LDLIBS=
 
 # Add the following to the end of the "CFLAGS=" line as needed to override
@@ -208,14 +209,18 @@
 #      For example, N is 252460800 on AmigaOS.
 #  -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
 #  -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
+#  -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
 #  -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
-#  -DHAVE_GENERIC=0 if _Generic does not work
-#  -DHAVE_GETRANDOM if getgrandom works (e.g., GNU/Linux)*
-#  -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris)*
+#  -DHAVE_GENERIC=0 if _Generic does not work*
+#  -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
+#      -DHAVE_GETRANDOM=0 to avoid using getrandom
+#  -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
+#      where LDLIBS also needs to contain -lintl on some hosts;
+#      -DHAVE_GETTEXT=0 to avoid using gettext
 #  -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).
-#  -DHAVE_INTTYPES_H if you have a non-C99 compiler with <inttypes.h>
+#  -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*
 #  -DHAVE_LINK=0 if your system lacks a link function
 #  -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
 #  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
@@ -225,15 +230,17 @@
 #      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_STDINT_H if you have a non-C99 compiler with <stdint.h>*
+#  -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
+#      __builtin_add_overflow work*
+#  -DHAVE_STDINT_H=0 if <stdint.h> does not work*
 #  -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 <sys/stat.h> does not work*
 #  -DHAVE_TZSET=0 if your system lacks a tzset function
-#  -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h>*
-#  -DHAVE_UTMPX_H=0 if your compiler lacks a <utmpx.h>*
+#  -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
+#  -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
 #  -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'.
@@ -280,7 +287,7 @@
   -Wdeclaration-after-statement -Wdouble-promotion \
   -Wduplicated-branches -Wduplicated-cond \
   -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \
-  -Winit-self -Wlogical-op \
+  -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op \
   -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
   -Wnull-dereference \
   -Wold-style-definition -Woverlength-strings -Wpointer-arith \
@@ -293,7 +300,7 @@
   -Wtrampolines -Wundef -Wuninitialized -Wunused-macros -Wuse-after-free=3 \
   -Wvariadic-macros -Wvla -Wwrite-strings \
   -Wno-address -Wno-format-nonliteral -Wno-sign-compare \
-  -Wno-type-limits -Wno-unused-parameter
+  -Wno-type-limits
 #
 # If your system has a "GMT offset" field in its "struct tm"s
 # (or if you decide to add such a field in your system's "time.h" file),
@@ -340,14 +347,11 @@
 # If you want functions that were inspired by early versions of X3J11's work,
 # add
 #      -DSTD_INSPIRED
-# to the end of the "CFLAGS=" line.  This arranges for the functions
-# "offtime", "timelocal", "timegm", "timeoff",
-# "posix2time", and "time2posix" to be added to the time conversion library.
+# to the end of the "CFLAGS=" line.  This arranges for the following
+# functions to be added to the time conversion library.
 # "offtime" is like "gmtime" except that it accepts a second (long) argument
 # that gives an offset to add to the time_t when converting it.
 # "timelocal" is equivalent to "mktime".
-# "timegm" is like "timelocal" except that it turns a struct tm into
-# a time_t using UT (rather than local time as "timelocal" does).
 # "timeoff" is like "timegm" except that it accepts a second (long) argument
 # that gives an offset to use when converting to a time_t.
 # "posix2time" and "time2posix" are described in an included manual page.
@@ -495,6 +499,11 @@
 # Flags to give 'gzip' when making a distribution.
 GZIPFLAGS=     -9n
 
+# When comparing .tzs files, use GNU diff's -F'^TZ=' option if supported.
+# This makes it easier to see which Zone has been affected.
+DIFF_TZS=       diff -u$$(! diff -u -F'^TZ=' - - <>/dev/null >&0 2>&1 \
+                          || echo ' -F^TZ=')
+
 ###############################################################################
 
 #MAKE=         make
@@ -773,7 +782,8 @@
                chmod +x $@.out
                mv $@.out $@
 
-check:         check_character_set check_white_space check_links \
+check: check_back check_mild
+check_mild:    check_character_set check_white_space check_links \
                  check_name_lengths check_slashed_abbrs check_sorted \
                  check_tables check_web check_ziguard check_zishrink check_tzs
 
@@ -824,16 +834,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/ {printf "%.5d %s\n", g, $$3} /^$$/ {g++}' \
+               $(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
+check_back:    checklinks.awk $(TDATA_TO_CHECK)
                $(AWK) \
                  -v DATAFORM=$(DATAFORM) \
                  -v backcheck=backward \
                  -f checklinks.awk $(TDATA_TO_CHECK)
+               touch $@
+
+check_links:   checklinks.awk tzdata.zi
                $(AWK) \
                  -v DATAFORM=$(DATAFORM) \
                  -f checklinks.awk tzdata.zi
@@ -849,7 +862,7 @@
 
 check_tzs:     $(TZS) $(TZS_NEW)
                if test -s $(TZS); then \
-                 diff -u $(TZS) $(TZS_NEW); \
+                 $(DIFF_TZS) $(TZS) $(TZS_NEW); \
                else \
                  cp $(TZS_NEW) $(TZS); \
                fi
@@ -1050,7 +1063,7 @@
                      TZS_YEAR="$$range" TZS_CUTOFF_FLAG="-t $$range" \
                        D=$$wd/$@.dir \
                      to$$range.tzs) && \
-                 diff -u $(TIME_T_ALTERNATIVES_HEAD).dir/to$$range.tzs \
+                 $(DIFF_TZS) $(TIME_T_ALTERNATIVES_HEAD).dir/to$$range.tzs \
                          $@.dir/to$$range.tzs && \
                  if diff -q Makefile Makefile 2>/dev/null; then \
                    quiet_option='-q'; \
@@ -1220,7 +1233,7 @@
 zic.o:         private.h tzfile.h version.h
 
 .PHONY: ALL INSTALL all
-.PHONY: check check_time_t_alternatives
+.PHONY: check check_mild check_time_t_alternatives
 .PHONY: check_web check_zishrink
 .PHONY: clean clean_misc dummy.zd force_tzs
 .PHONY: install install_data maintainer-clean names
diff -r fc038d8181f1 -r 0055f25c80d0 lib/libc/time/NEWS
--- a/lib/libc/time/NEWS        Sun Dec 11 17:35:56 2022 +0000
+++ b/lib/libc/time/NEWS        Sun Dec 11 17:57:23 2022 +0000
@@ -1,5 +1,91 @@
 News for the tz database
 
+Release 2022g - 2022-11-29 08:58:31 -0800
+
+  Briefly:
+    The northern edge of Chihuahua changes to US timekeeping.
+    Much of Greenland stops changing clocks after March 2023.
+    Fix some pre-1996 timestamps in northern Canada.
+    C89 is now deprecated; please use C99 or later.
+    Portability fixes for AIX, libintl, MS-Windows, musl, z/OS
+    In C code, use more C23 features if available.
+    C23 timegm now supported by default
+    Fixes for unlikely integer overflows
+
+  Changes to future timestamps
+
+    In the Mexican state of Chihuahua, the border strip near the US
+    will change to agree with nearby US locations on 2022-11-30.
+    The strip's western part, represented by Ciudad Juárez, switches
+    from -06 all year to -07/-06 with US DST rules, like El Paso, TX.
+    The eastern part, represented by Ojinaga, will observe US DST next
+    year, like Presidio, TX.  (Thanks to Heitor David Pinto.)
+    A new Zone America/Ciudad_Juarez splits from America/Ojinaga.
+
+    Much of Greenland, represented by America/Nuuk, stops observing
+    winter time after March 2023, so its daylight saving time becomes
+    standard time.  (Thanks to Jonas Nyrup and Jürgen Appel.)
+
+  Changes to past timestamps
+
+    Changes for pre-1996 northern Canada (thanks to Chris Walton):
+
+      Merge America/Iqaluit and America/Pangnirtung into the former,
+      with a backward compatibility link for the latter name.
+      There is no good evidence the two locations differ since 1970.
+      This change affects pre-1996 America/Pangnirtung timestamps.
+
+      Cambridge Bay, Inuvik, Iqaluit, Rankin Inlet, Resolute and
+      Yellowknife did not observe DST in 1965, and did observe DST
+      from 1972 through 1979.
+
+      Whitehorse moved from -09 to -08 on 1966-02-27, not 1967-05-28.
+
+    Colombia's 1993 fallback was 02-06 24:00, not 04-04 00:00.
+    (Thanks to Alois Treindl.)
+
+    Singapore's 1981-12-31 change was at 16:00 UTC (23:30 local time),
+    not 24:00 local time.  (Thanks to Geoff Clare via Robert Elz.)
+
+  Changes to code
+
+    Although tzcode still works with C89, bugs found in recent routine
+    maintenance indicate that bitrot has set in and that in practice
+    C89 is no longer used to build tzcode.  As it is a maintenance
+    burden, support for C89 is planned to be removed soon.  Instead,
+    please use compilers compatible with C99, C11, C17, or C23.
+
+    timegm, which tzcode implemented in 1989, will finally be
+    standardized 34 years later as part of C23, so timegm is now
+    supported even if STD_INSPIRED is not defined.
+
+    Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
+    (Problem reported by Đoàn Trần Công Danh.)
+
+    Fix bug in zic on hosts where malloc(0) yields NULL on success.
+    (Problem reported by Tim McBrayer for AIX 6.1.)
+
+    Fix zic configuration to avoid linkage failures on some platforms.
+    (Problems reported by Gilmore Davidson and Igor Ivanov.)
+
+    Work around MS-Windows nmake incompatibility with POSIX.
+    (Problem reported by Manuela Friedrich.)
+
+    Port mktime and strftime to debugging platforms where accessing
+    uninitialized data has undefined behavior (strftime problem
+    reported by Robert Elz).
+
+    Check more carefully for unlikely integer overflows, preferring
+    C23 <stdckdint.h> to overflow checking by hand, as the latter has
+    had obscure bugs.
+
+  Changes to build procedure
+
+    New Makefile rule check_mild that skips checking whether Link
+    lines are in the file 'backward'.  (Inspired by a suggestion from
+    Stephen Colebourne.)
+
+
 Release 2022f - 2022-10-28 18:04:57 -0700
 
   Briefly:
@@ -16,7 +102,7 @@
     In C code, use some C23 features if available.
     Remove no-longer-needed workaround for Qt bug 53071.
 
-  Changes to future timestamps.
+  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.
@@ -24,6 +110,7 @@
     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.
+    (Thanks to gera for the heads-up about Chihuahua.)
 
     Fiji will not observe DST in 2022/3.  (Thanks to Shalvin Narayan.)
     For now, assume DST is suspended indefinitely.
diff -r fc038d8181f1 -r 0055f25c80d0 lib/libc/time/ctime.3
--- a/lib/libc/time/ctime.3     Sun Dec 11 17:35:56 2022 +0000
+++ b/lib/libc/time/ctime.3     Sun Dec 11 17:57:23 2022 +0000
@@ -1,6 +1,7 @@
-.\" $NetBSD: ctime.3,v 1.68 2022/10/26 23:22:54 jschauma Exp $
+.\" $NetBSD: ctime.3,v 1.69 2022/12/11 17:57:23 christos Exp $
 .\"
-.\" XXX: License missing?
+.\" This file is in the public domain, so clarified as of
+.\" 2009-05-17 by Arthur David Olson.
 .\"
 .Dd October 22, 2022
 .Dt CTIME 3
@@ -603,6 +604,4 @@
 To avoid this portability mess, new programs should use
 .Fn strftime
 instead.
-.\" @(#)newctime.3     8.3
-.\" This file is in the public domain, so clarified as of
 .\" 2009-05-17 by Arthur David Olson.
diff -r fc038d8181f1 -r 0055f25c80d0 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Sun Dec 11 17:35:56 2022 +0000
+++ b/lib/libc/time/localtime.c Sun Dec 11 17:57:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.135 2022/10/29 13:55:50 christos Exp $ */
+/*     $NetBSD: localtime.c,v 1.136 2022/12/11 17:57:23 christos Exp $ */


Home | Main Index | Thread Index | Old Index