]> Savannah Git Hosting - gnulib.git/commitdiff
time_rz: Support time zone names on MSVC.
authorBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 16:17:23 +0000 (18:17 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 23:34:11 +0000 (01:34 +0200)
* 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
lib/time-internal.h
lib/time_rz.c
m4/time_rz.m4
modules/time_rz

index eb8dde396b07f25632ad9c0620b681e0611b7b94..308bec6bc75f0075dd1220b1f48b22044314fe36 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-06-06  Bruno Haible  <bruno@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  <bruno@clisp.org>
 
        tzname: Add tests.
index 51423c94ca93f52486ea1c6cf68e98309b5082a4..045e9e0ac77973585e24ceba938855b2838a9544 100644 (file)
@@ -1,6 +1,6 @@
 /* Time internal interface
 
-   Copyright 2015-2023 Free Software Foundation, Inc.
+   Copyright 2015-2024 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
@@ -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];
index da0d57b8b1aa12c4f5c482e3d16d85238e529255..b28d55c2fda039ec6a6dc1837fe99b592c76067a 100644 (file)
@@ -1,6 +1,6 @@
 /* Time zone functions such as tzalloc and localtime_rz
 
-   Copyright 2015-2023 Free Software Foundation, Inc.
+   Copyright 2015-2024 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
@@ -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)
index d13bc06b7a0607f19c011d3ad1e7f722614fa483..c7387ca9a22adc6501fa54162a66a2922083e4bb 100644 (file)
@@ -1,6 +1,6 @@
 dnl Time zone functions: tzalloc, localtime_rz, etc.
 
-dnl Copyright (C) 2015-2023 Free Software Foundation, Inc.
+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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,7 +11,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
index f487e24c6b3d4fa275ce2b2de650932584164b9b..da621684f51be864eacaeb882721eba709e6f4f0 100644 (file)
@@ -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]