On MSVC, the nstrftime and c-nstrftime tests fail, because the %Z directive produces an empty string instead of a time zone abbreviation.
The cause is that strftime.c contains code for two cases: - HAVE_STRUCT_TM_TM_ZONE - HAVE_TZNAME but on MSVC both macros are undefined, since MSVC has '_tzname', not 'tzname'. This patch series adds a module 'tzname' that, compared to Autoconf's AC_STRUCT_TIMEZONE, adds support for this platform. I'm *not* adding modules for 'daylight' and 'timezone', which have the same problem on MSVC, for two reasons: - Hardly any code uses these two variables. The fact that FreeBSD hasn't gotten around to implement them shows that they are not so important. - Defining #define daylight _daylight #define timezone _timezone would cause trouble in C++ code that uses namespaced symbols, such as chrono::timezone boost::chrono::timezone icu::timezone::ZoneVariant::daylight The new macro gl_TZNAME cannot simply define HAVE_TZNAME also on MSVC, because that would assign different meaning to a macro defined by Autoconf: before: HAVE_TZNAME means that 'tzname' can be used after including <time.h>, after: HAVE_TZNAME means that 'tzname' can be used after including <time.h> and possibly '#define tzname _tzname'. Code unrelated to Gnulib, which so far compiles fine on MSVC would then access an undefined variable 'tzname'. For this reason, the new macro defines HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. After adding this module and replacing all uses of HAVE_TZNAME with HAVE_TZNAME_ARRAY, the %Z directive in nstrftime works fine. 2024-06-06 Bruno Haible <br...@clisp.org> nstrftime, c-nstrftime: Support time zone names on MSVC. * lib/strftime.c: Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. (tzname): Remove declaration. * modules/nstrftime (Depends-on): Add tzname. * modules/c-nstrftime (Depends-on): Likewise. * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't require AC_STRUCT_TIMEZONE. * m4/c-nstrftime.m4 (gl_C_GNU_STRFTIME): Likewise. 2024-06-06 Bruno Haible <br...@clisp.org> parse-datetime: Support time zone names on MSVC. * lib/parse-datetime.y (parse_datetime_body): Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. Don't declare tzname. * modules/parse-datetime (Depends-on): Add tzname. * m4/parse-datetime.m4 (gl_PARSE_DATETIME): Don't invoke AC_STRUCT_TIMEZONE. 2024-06-06 Bruno Haible <br...@clisp.org> time_rz: Support time zone names on MSVC. * lib/time-internal.h: Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. * lib/time_rz.c (tzalloc, save_abbr, mktime_z): Likewise. * modules/time_rz (Depends-on): Add tzname. * m4/time_rz.m4 (gl_TIME_RZ): Don't require AC_STRUCT_TIMEZONE. 2024-06-06 Bruno Haible <br...@clisp.org> tzname: Add tests. * tests/test-tzname.c: New file. * modules/tzname-tests: New file. tzname: New module. * lib/time.in.h (tzname): New declaration. * m4/tzname.m4: New file. * m4/time_h.m4 (gl_TIME_H_REQUIRE_DEFAULTS): Initialize GNULIB_TZNAME. * modules/time-h (Makefile.am): Substitute GNULIB_TZNAME. * modules/tzname: New file. * doc/posix-functions/tzname.texi: Mention the new module.
>From 7c302b4bef254349eb9d322b5a5cce1dbe317e43 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 6 Jun 2024 17:47:21 +0200 Subject: [PATCH 1/5] tzname: New module. * lib/time.in.h (tzname): New declaration. * m4/tzname.m4: New file. * m4/time_h.m4 (gl_TIME_H_REQUIRE_DEFAULTS): Initialize GNULIB_TZNAME. * modules/time-h (Makefile.am): Substitute GNULIB_TZNAME. * modules/tzname: New file. * doc/posix-functions/tzname.texi: Mention the new module. --- ChangeLog | 10 ++++++ doc/posix-functions/tzname.texi | 8 ++--- lib/time.in.h | 17 +++++++++ m4/time_h.m4 | 3 +- m4/tzname.m4 | 62 +++++++++++++++++++++++++++++++++ modules/time-h | 1 + modules/tzname | 23 ++++++++++++ 7 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 m4/tzname.m4 create mode 100644 modules/tzname diff --git a/ChangeLog b/ChangeLog index f5d56af5d5..97733e4c40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-06-06 Bruno Haible <br...@clisp.org> + + tzname: New module. + * lib/time.in.h (tzname): New declaration. + * m4/tzname.m4: New file. + * m4/time_h.m4 (gl_TIME_H_REQUIRE_DEFAULTS): Initialize GNULIB_TZNAME. + * modules/time-h (Makefile.am): Substitute GNULIB_TZNAME. + * modules/tzname: New file. + * doc/posix-functions/tzname.texi: Mention the new module. + 2024-06-06 Bruno Haible <br...@clisp.org> tzname, daylight, timezone: Update documentation. diff --git a/doc/posix-functions/tzname.texi b/doc/posix-functions/tzname.texi index d56ff5c924..e3413d47de 100644 --- a/doc/posix-functions/tzname.texi +++ b/doc/posix-functions/tzname.texi @@ -4,18 +4,18 @@ POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/tzname.html} -Gnulib module: --- +Gnulib module: tzname Portability problems fixed by Gnulib: @itemize +@item +This variable is called @code{_tzname} on some platforms: +mingw with @code{-DNO_OLDNAMES}, MSVC. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This variable is called @code{_tzname} on some platforms: -mingw with @code{-DNO_OLDNAMES}, MSVC. -@item The address of this variable is not a compile-time constant on some platforms: Cygwin, mingw, MSVC. @item diff --git a/lib/time.in.h b/lib/time.in.h index df99c8abca..b91018937a 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -122,6 +122,23 @@ struct __time_t_must_be_integral { # endif # endif +# if @GNULIB_TZNAME@ +/* tzname[0..1]: Abbreviated time zone names, set by the tzset() function. */ +# if NEED_DECL_TZNAME +extern +# ifdef __cplusplus + "C" +# endif + char *tzname[]; +# endif +# if defined _WIN32 && !defined __CYGWIN__ +/* On native Windows, map 'tzname' to '_tzname' etc., so that -loldnames is not + required. */ +# undef tzname +# define tzname _tzname +# endif +# endif + /* Set *TS to the current time, and return BASE. Upon failure, return 0. */ # if @GNULIB_TIMESPEC_GET@ diff --git a/m4/time_h.m4 b/m4/time_h.m4 index d2f3c9701c..4ca7305792 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -1,5 +1,5 @@ # time_h.m4 -# serial 25 +# serial 26 dnl Copyright (C) 2000-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -145,6 +145,7 @@ AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS] gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZNAME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET]) dnl Support Microsoft deprecated alias function names by default. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1]) diff --git a/m4/tzname.m4 b/m4/tzname.m4 new file mode 100644 index 0000000000..b600e56d01 --- /dev/null +++ b/m4/tzname.m4 @@ -0,0 +1,62 @@ +# tzname.m4 +# serial 1 +dnl Copyright (C) 2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl gl_TZNAME tests how the time zone can be obtained. +dnl It is similar AC_STRUCT_TIMEZONE, but also supports MSVC. +dnl It defines +dnl * the C macro HAVE_STRUCT_TM_TM_ZONE to 1 if 'struct tm' has a field +dnl 'tm_zone', +dnl * otherwise: +dnl - the C macro HAVE_TZNAME_ARRAY to 1 if there the rvalue 'tzname' +dnl or (on native Windows) '_tzname' is usable, +dnl - the C macro NEED_DECL_TZNAME to 1 if 'tzname' needs to be declared +dnl extern char *tzname[]; +dnl before use. +AC_DEFUN([gl_TZNAME], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + + dnl Set ac_cv_member_struct_tm_tm_zone, + dnl ac_cv_var_tzname, ac_cv_have_decl_tzname. + dnl Possibly define HAVE_STRUCT_TM_TM_ZONE, + dnl HAVE_TZNAME, HAVE_DECL_TZNAME. + AC_REQUIRE([AC_STRUCT_TIMEZONE]) + + dnl If 'struct tm' has a field 'tm_zone', don't test for tzname or _tzname. + dnl Rationale: Some code assumes that HAVE_STRUCT_TM_TM_ZONE and HAVE_TZNAME + dnl are exclusive. + if test "$ac_cv_member_struct_tm_tm_zone" != yes; then + if test $ac_cv_var_tzname = yes && test $ac_cv_have_decl_tzname != yes; then + AC_DEFINE([NEED_DECL_TZNAME], [1], + [Define to 1 if tzname exists but needs to be declared.]) + fi + AC_CACHE_CHECK([for tzname array], + [gl_cv_var_tzname], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <time.h> + #if NEED_DECL_TZNAME + extern char *tzname[]; + #endif + #if defined _WIN32 && !defined __CYGWIN__ + #undef tzname + #define tzname _tzname + #endif + ]], + [[return tzname[0][0]; + ]]) + ], + [gl_cv_var_tzname=yes], + [gl_cv_var_tzname=no]) + ]) + if test $gl_cv_var_tzname = yes; then + AC_DEFINE([HAVE_TZNAME_ARRAY], [1], + [Define to 1 if 'struct tm' does not have a field 'tm_zone' + but instead 'tzname' is usable.]) + fi + fi +]) diff --git a/modules/time-h b/modules/time-h index 3b07845b56..e84100bf93 100644 --- a/modules/time-h +++ b/modules/time-h @@ -44,6 +44,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GNULIB_TIMESPEC_GETRES)/g' \ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ -e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \ + -e 's/@''GNULIB_TZNAME''@/$(GNULIB_TZNAME)/g' \ -e 's/@''GNULIB_TZSET''@/$(GNULIB_TZSET)/g' \ -e 's/@''GNULIB_MDA_TZSET''@/$(GNULIB_MDA_TZSET)/g' \ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ diff --git a/modules/tzname b/modules/tzname new file mode 100644 index 0000000000..4195d74f8e --- /dev/null +++ b/modules/tzname @@ -0,0 +1,23 @@ +Description: +tzname variable: abbreviated time zone names, set by the tzset() function. + +Files: +m4/tzname.m4 + +Depends-on: +time-h + +configure.ac: +gl_TZNAME +gl_TIME_MODULE_INDICATOR([tzname]) + +Makefile.am: + +Include: +<time.h> + +License: +LGPL + +Maintainer: +all -- 2.34.1
>From 0208dcf9550d425e3ed4f0883b1c2a4491fe58ff Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 6 Jun 2024 18:05:57 +0200 Subject: [PATCH 2/5] tzname: Add tests. * tests/test-tzname.c: New file. * modules/tzname-tests: New file. --- ChangeLog | 4 ++++ modules/tzname-tests | 11 +++++++++++ tests/test-tzname.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 modules/tzname-tests create mode 100644 tests/test-tzname.c diff --git a/ChangeLog b/ChangeLog index 97733e4c40..78af4a7090 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2024-06-06 Bruno Haible <br...@clisp.org> + tzname: Add tests. + * tests/test-tzname.c: New file. + * modules/tzname-tests: New file. + tzname: New module. * lib/time.in.h (tzname): New declaration. * m4/tzname.m4: New file. diff --git a/modules/tzname-tests b/modules/tzname-tests new file mode 100644 index 0000000000..b2c590eaff --- /dev/null +++ b/modules/tzname-tests @@ -0,0 +1,11 @@ +Files: +tests/test-tzname.c + +Depends-on: +tzset + +configure.ac: + +Makefile.am: +TESTS += test-tzname +check_PROGRAMS += test-tzname diff --git a/tests/test-tzname.c b/tests/test-tzname.c new file mode 100644 index 0000000000..385d594cc3 --- /dev/null +++ b/tests/test-tzname.c @@ -0,0 +1,36 @@ +/* Test of tzname array. + Copyright (C) 2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2024. */ + +#include <config.h> + +/* Specification. */ +#include <time.h> + +#include <stdio.h> +#include <stdlib.h> + +int +main () +{ + const char *tz = getenv ("TZ"); + tzset (); + printf ("TZ=%s -> tzname[0]=\"%s\", tzname[1]=\"%s\"\n", + tz != NULL ? tz : "(null)", + tzname[0], tzname[1]); + return 0; +} -- 2.34.1
>From 14b9063716442d81770554ad33a635125d56194f Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 6 Jun 2024 18:17:23 +0200 Subject: [PATCH 3/5] time_rz: Support time zone names on MSVC. * lib/time-internal.h: Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. * lib/time_rz.c (tzalloc, save_abbr, mktime_z): Likewise. * modules/time_rz (Depends-on): Add tzname. * m4/time_rz.m4 (gl_TIME_RZ): Don't require AC_STRUCT_TIMEZONE. --- ChangeLog | 8 ++++++++ lib/time-internal.h | 2 +- lib/time_rz.c | 17 +++++++++-------- m4/time_rz.m4 | 3 +-- modules/time_rz | 1 + 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78af4a7090..16b1ec8496 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-06 Bruno Haible <br...@clisp.org> + + time_rz: Support time zone names on MSVC. + * lib/time-internal.h: Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. + * lib/time_rz.c (tzalloc, save_abbr, mktime_z): Likewise. + * modules/time_rz (Depends-on): Add tzname. + * m4/time_rz.m4 (gl_TIME_RZ): Don't require AC_STRUCT_TIMEZONE. + 2024-06-06 Bruno Haible <br...@clisp.org> tzname: Add tests. diff --git a/lib/time-internal.h b/lib/time-internal.h index 816684a117..045e9e0ac7 100644 --- a/lib/time-internal.h +++ b/lib/time-internal.h @@ -24,7 +24,7 @@ struct tm_zone members are zero. */ struct tm_zone *next; -#if HAVE_TZNAME && !HAVE_STRUCT_TM_TM_ZONE +#if HAVE_TZNAME_ARRAY && !HAVE_STRUCT_TM_TM_ZONE /* Copies of recent strings taken from tzname[0] and tzname[1]. The copies are in ABBRS, so that they survive tzset. Null if unknown. */ char *tzname_copy[2]; diff --git a/lib/time_rz.c b/lib/time_rz.c index 468d7539ce..b28d55c2fd 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -70,7 +70,7 @@ tzalloc (char const *name) if (tz) { tz->next = NULL; -#if HAVE_TZNAME && !HAVE_STRUCT_TM_TM_ZONE +#if HAVE_TZNAME_ARRAY && !HAVE_STRUCT_TM_TM_ZONE tz->tzname_copy[0] = tz->tzname_copy[1] = NULL; #endif tz->tz_is_set = !!name; @@ -81,18 +81,19 @@ tzalloc (char const *name) return tz; } -/* Save into TZ any nontrivial time zone abbreviation used by TM, and - update *TM (if HAVE_STRUCT_TM_TM_ZONE) or *TZ (if - !HAVE_STRUCT_TM_TM_ZONE && HAVE_TZNAME) if they use the abbreviation. +/* Save into TZ any nontrivial time zone abbreviation used by TM, and update + *TM (if HAVE_STRUCT_TM_TM_ZONE) + or *TZ (if !HAVE_STRUCT_TM_TM_ZONE && HAVE_TZNAME_ARRAY) + if they use the abbreviation. Return true if successful, false (setting errno) otherwise. */ static bool save_abbr (timezone_t tz, struct tm *tm) { -#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME +#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME_ARRAY char const *zone = NULL; char *zone_copy = (char *) ""; -# if HAVE_TZNAME +# if HAVE_TZNAME_ARRAY int tzname_index = -1; # endif @@ -100,7 +101,7 @@ save_abbr (timezone_t tz, struct tm *tm) zone = tm->tm_zone; # endif -# if HAVE_TZNAME +# if HAVE_TZNAME_ARRAY if (! (zone && *zone) && 0 <= tm->tm_isdst) { tzname_index = tm->tm_isdst != 0; @@ -302,7 +303,7 @@ mktime_z (timezone_t tz, struct tm *tm) tm_1.tm_isdst = tm->tm_isdst; time_t t = mktime (&tm_1); bool ok = 0 <= tm_1.tm_yday; -#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME +#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME_ARRAY ok = ok && save_abbr (tz, &tm_1); #endif if (revert_tz (old_tz) && ok) diff --git a/m4/time_rz.m4 b/m4/time_rz.m4 index 8f45f2b1d3..9613597aca 100644 --- a/m4/time_rz.m4 +++ b/m4/time_rz.m4 @@ -1,5 +1,5 @@ # time_rz.m4 -# serial 1 +# serial 2 dnl Copyright (C) 2015-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -13,7 +13,6 @@ AC_DEFUN([gl_TIME_RZ] [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_TIME_H_DEFAULTS]) - AC_REQUIRE([AC_STRUCT_TIMEZONE]) # On Mac OS X 10.6, localtime loops forever with some time_t values. # See Bug#27706, Bug#27736, and diff --git a/modules/time_rz b/modules/time_rz index f487e24c6b..da621684f5 100644 --- a/modules/time_rz +++ b/modules/time_rz @@ -10,6 +10,7 @@ Depends-on: c99 extensions time-h +tzname flexmember [test $HAVE_TIMEZONE_T = 0] idx [test $HAVE_TIMEZONE_T = 0] setenv [test $HAVE_TIMEZONE_T = 0] -- 2.34.1
>From b53e7a0509f8a5ff65304b79fe7fbcfd5e49de64 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 6 Jun 2024 18:22:21 +0200 Subject: [PATCH 4/5] parse-datetime: Support time zone names on MSVC. * lib/parse-datetime.y (parse_datetime_body): Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. Don't declare tzname. * modules/parse-datetime (Depends-on): Add tzname. * m4/parse-datetime.m4 (gl_PARSE_DATETIME): Don't invoke AC_STRUCT_TIMEZONE. --- ChangeLog | 9 +++++++++ lib/parse-datetime.y | 5 +---- m4/parse-datetime.m4 | 3 +-- modules/parse-datetime | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16b1ec8496..3e32b61642 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-06-06 Bruno Haible <br...@clisp.org> + + parse-datetime: Support time zone names on MSVC. + * lib/parse-datetime.y (parse_datetime_body): Use HAVE_TZNAME_ARRAY + instead of HAVE_TZNAME. Don't declare tzname. + * modules/parse-datetime (Depends-on): Add tzname. + * m4/parse-datetime.m4 (gl_PARSE_DATETIME): Don't invoke + AC_STRUCT_TIMEZONE. + 2024-06-06 Bruno Haible <br...@clisp.org> time_rz: Support time zone names on MSVC. diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y index 447a943db1..83e0ba38ce 100644 --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -1863,11 +1863,8 @@ parse_datetime_body (struct timespec *result, char const *p, } } #else -#if HAVE_TZNAME +#if HAVE_TZNAME_ARRAY { -# if !HAVE_DECL_TZNAME - extern char *tzname[]; -# endif int i; for (i = 0; i < 2; i++) { diff --git a/m4/parse-datetime.m4 b/m4/parse-datetime.m4 index 09e87e85d0..9932796231 100644 --- a/m4/parse-datetime.m4 +++ b/m4/parse-datetime.m4 @@ -1,5 +1,5 @@ # parse-datetime.m4 -# serial 27 +# serial 28 dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -49,7 +49,6 @@ AC_DEFUN([gl_PARSE_DATETIME] dnl Prerequisites of lib/parse-datetime.y. AC_REQUIRE([gl_BISON]) AC_REQUIRE([gl_C_COMPOUND_LITERALS]) - AC_STRUCT_TIMEZONE AC_REQUIRE([gl_CLOCK_TIME]) AC_REQUIRE([gl_TM_GMTOFF]) ]) diff --git a/modules/parse-datetime b/modules/parse-datetime index 1645660abe..64b3b09913 100644 --- a/modules/parse-datetime +++ b/modules/parse-datetime @@ -28,6 +28,7 @@ time-h time_r time_rz timegm +tzname configure.ac: gl_PARSE_DATETIME -- 2.34.1
>From 4a31d1988bbc34cd348009cf8761f306fbd14c63 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Thu, 6 Jun 2024 18:29:51 +0200 Subject: [PATCH 5/5] nstrftime, c-nstrftime: Support time zone names on MSVC. * lib/strftime.c: Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. (tzname): Remove declaration. * modules/nstrftime (Depends-on): Add tzname. * modules/c-nstrftime (Depends-on): Likewise. * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't require AC_STRUCT_TIMEZONE. * m4/c-nstrftime.m4 (gl_C_GNU_STRFTIME): Likewise. --- ChangeLog | 11 +++++++++++ lib/strftime.c | 10 +++------- m4/c-nstrftime.m4 | 5 +---- m4/nstrftime.m4 | 5 +---- modules/c-nstrftime | 1 + modules/nstrftime | 1 + 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e32b61642..b0fa4f8a4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2024-06-06 Bruno Haible <br...@clisp.org> + + nstrftime, c-nstrftime: Support time zone names on MSVC. + * lib/strftime.c: Use HAVE_TZNAME_ARRAY instead of HAVE_TZNAME. + (tzname): Remove declaration. + * modules/nstrftime (Depends-on): Add tzname. + * modules/c-nstrftime (Depends-on): Likewise. + * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't require + AC_STRUCT_TIMEZONE. + * m4/c-nstrftime.m4 (gl_C_GNU_STRFTIME): Likewise. + 2024-06-06 Bruno Haible <br...@clisp.org> parse-datetime: Support time zone names on MSVC. diff --git a/lib/strftime.c b/lib/strftime.c index 3a429ed4af..7d124e68f3 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -27,7 +27,7 @@ # define HAVE_STRUCT_ERA_ENTRY 1 # define HAVE_TM_GMTOFF 1 # define HAVE_STRUCT_TM_TM_ZONE 1 -# define HAVE_TZNAME 1 +# define HAVE_TZNAME_ARRAY 1 # include "../locale/localeinfo.h" #else # include <libc-config.h> @@ -60,10 +60,6 @@ #include <errno.h> #include <time.h> -#if HAVE_TZNAME && !HAVE_DECL_TZNAME -extern char *tzname[]; -#endif - /* Do multibyte processing if multibyte encodings are supported, unless multibyte sequences are safe in formats. Multibyte sequences are safe if they cannot contain byte sequences that look like format @@ -930,7 +926,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) # define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11)) # define ap_len 2 #endif -#if HAVE_TZNAME +#if HAVE_TZNAME_ARRAY char **tzname_vec = tzname; #endif const char *zone; @@ -951,7 +947,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) POSIX does not require it. Do the right thing instead. */ zone = (const char *) tp->tm_zone; #endif -#if HAVE_TZNAME +#if HAVE_TZNAME_ARRAY if (!tz) { if (! (zone && *zone)) diff --git a/m4/c-nstrftime.m4 b/m4/c-nstrftime.m4 index f5cafbbcca..fbc18ce8c7 100644 --- a/m4/c-nstrftime.m4 +++ b/m4/c-nstrftime.m4 @@ -1,5 +1,5 @@ # c-nstrftime.m4 -# serial 1 +# serial 2 dnl Copyright (C) 1996-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,9 +9,6 @@ AC_DEFUN([gl_C_GNU_STRFTIME] [ AC_REQUIRE([AC_C_RESTRICT]) - # This defines (or not) HAVE_TZNAME and HAVE_STRUCT_TM_TM_ZONE. - AC_REQUIRE([AC_STRUCT_TIMEZONE]) - AC_REQUIRE([gl_TM_GMTOFF]) dnl Test for strftime_l. It exists in diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4 index f73bca40ec..8c855c4163 100644 --- a/m4/nstrftime.m4 +++ b/m4/nstrftime.m4 @@ -1,5 +1,5 @@ # nstrftime.m4 -# serial 38 +# serial 39 dnl Copyright (C) 1996-1997, 1999-2007, 2009-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,8 +11,5 @@ AC_DEFUN([gl_FUNC_GNU_STRFTIME] [ AC_REQUIRE([AC_C_RESTRICT]) - # This defines (or not) HAVE_TZNAME and HAVE_STRUCT_TM_TM_ZONE. - AC_REQUIRE([AC_STRUCT_TIMEZONE]) - AC_REQUIRE([gl_TM_GMTOFF]) ]) diff --git a/modules/c-nstrftime b/modules/c-nstrftime index 8b2348c227..fdd054c10e 100644 --- a/modules/c-nstrftime +++ b/modules/c-nstrftime @@ -20,6 +20,7 @@ locale stdbool stdckdint time_rz +tzname configure.ac: gl_C_GNU_STRFTIME diff --git a/modules/nstrftime b/modules/nstrftime index 69b9d84605..35ed887a70 100644 --- a/modules/nstrftime +++ b/modules/nstrftime @@ -19,6 +19,7 @@ localename-unsafe-limited stdbool stdckdint time_rz +tzname configure.ac: gl_FUNC_GNU_STRFTIME -- 2.34.1