]> Savannah Git Hosting - gnulib.git/commitdiff
nstrftime: rename HAVE_TM_GMTOFF
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 16 Jun 2024 17:17:47 +0000 (10:17 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 16 Jun 2024 23:38:20 +0000 (16:38 -0700)
* m4/tm_gmtoff.m4 (gl_TM_GMTOFF): Rename HAVE_TM_GMTOFF
to HAVE_STRUCT_TM_TM_GMTOFF, for consistency with
HAVE_STRUCT_TM_TM_ZONE.  All uses changed.

ChangeLog
lib/parse-datetime.y
lib/strftime.c
lib/strptime.c
m4/tm_gmtoff.m4
tests/test-parse-datetime.c

index b5510849537a28dc38f1df0bc0771f926c19dfbe..ebdd04567f65cf086cf2f85e378122d2805a8e32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-06-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       nstrftime: rename HAVE_TM_GMTOFF
+       * m4/tm_gmtoff.m4 (gl_TM_GMTOFF): Rename HAVE_TM_GMTOFF
+       to HAVE_STRUCT_TM_TM_GMTOFF, for consistency with
+       HAVE_STRUCT_TM_TM_ZONE.  All uses changed.
+
 2024-06-15  Bruno Haible  <bruno@clisp.org>
 
        Drop outdated cppi configuration.
index 83e0ba38ce715c4a93e1cf6a7a516b795dccd66e..f98e7200d64e4d3de83e60ce8761ef1bd2b06b7e 100644 (file)
@@ -1311,7 +1311,7 @@ lookup_zone (parser_control const *pc, char const *name)
   return NULL;
 }
 
-#if ! HAVE_TM_GMTOFF
+#if ! HAVE_STRUCT_TM_TM_GMTOFF
 /* Yield the difference between *A and *B,
    measured in seconds, ignoring leap seconds.
    The body of this function is taken directly from the GNU C Library;
@@ -1336,7 +1336,7 @@ tm_diff (const struct tm *a, const struct tm *b)
                 + (a->tm_min - b->tm_min))
           + (a->tm_sec - b->tm_sec));
 }
-#endif /* ! HAVE_TM_GMTOFF */
+#endif
 
 static table const *
 lookup_word (parser_control const *pc, char *word)
@@ -2221,7 +2221,7 @@ parse_datetime_body (struct timespec *result, char const *p,
       if (pc.zones_seen)
         {
           bool overflow = false;
-#ifdef HAVE_TM_GMTOFF
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
           long int utcoff = tm.tm_gmtoff;
 #else
           time_t t = Start;
@@ -2337,7 +2337,7 @@ parse_datetime_body (struct timespec *result, char const *p,
                                         dbg_tm, sizeof dbg_tm));
       if (localtime_rz (tz, &result->tv_sec, &lmt))
         {
-#ifdef HAVE_TM_GMTOFF
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
           bool got_utcoff = true;
           long int utcoff = lmt.tm_gmtoff;
 #else
index 7d124e68f33efb902c9f5e2c62178a09665855e1..cd216fb6a53145d40c189d1656e1827f0c9e7f91 100644 (file)
@@ -25,7 +25,7 @@
 #ifdef _LIBC
 # define USE_IN_EXTENDED_LOCALE_MODEL 1
 # define HAVE_STRUCT_ERA_ENTRY 1
-# define HAVE_TM_GMTOFF 1
+# define HAVE_STRUCT_TM_TM_GMTOFF 1
 # define HAVE_STRUCT_TM_TM_ZONE 1
 # define HAVE_TZNAME_ARRAY 1
 # include "../locale/localeinfo.h"
@@ -746,7 +746,7 @@ should_remove_ampm (void)
 #endif
 
 
-#if ! HAVE_TM_GMTOFF
+#if ! HAVE_STRUCT_TM_TM_GMTOFF
 /* Yield the difference between *A and *B,
    measured in seconds, ignoring leap seconds.  */
 # define tm_diff ftime_tm_diff
@@ -771,7 +771,7 @@ tm_diff (const struct tm *a, const struct tm *b)
                 + (a->tm_min - b->tm_min))
           + (a->tm_sec - b->tm_sec));
 }
-#endif /* ! HAVE_TM_GMTOFF */
+#endif
 
 
 
@@ -1998,7 +1998,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
             int hour_diff;
             int min_diff;
             int sec_diff;
-#if HAVE_TM_GMTOFF
+#if HAVE_STRUCT_TM_TM_GMTOFF
             diff = tp->tm_gmtoff;
 #else
             if (!tz)
index 568caf6df809f886b21b726c1b61f9f63fa1e94b..e0fe2bfd9a8bf3e1d6c340a6ad7ef72e61e8529d 100644 (file)
@@ -713,7 +713,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
               }
             if (val > 1200)
               return NULL;
-#if defined _LIBC || HAVE_TM_GMTOFF
+#if defined _LIBC || HAVE_STRUCT_TM_TM_GMTOFF
             tm->tm_gmtoff = (val * 3600) / 100;
             if (neg)
               tm->tm_gmtoff = -tm->tm_gmtoff;
index 0c7dcb2a09aacdd7671919268bf5d420fc318296..ad64df49546a8eccbd39858501dddbb9055ced77 100644 (file)
@@ -1,5 +1,5 @@
 # tm_gmtoff.m4
-# serial 3
+# serial 4
 dnl Copyright (C) 2002, 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,
@@ -7,9 +7,14 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_TM_GMTOFF],
 [
- AC_CHECK_MEMBER([struct tm.tm_gmtoff],
-                 [AC_DEFINE([HAVE_TM_GMTOFF], [1],
-                            [Define if struct tm has the tm_gmtoff member.])],
-                 ,
-                 [#include <time.h>])
+  AC_CHECK_MEMBERS([struct tm.tm_gmtoff], [], [],
+    [[#include <time.h>
+    ]])
+
+  dnl Backward compatibility with 2024-and-earlier versions of this macro.
+  AS_IF([test "$ac_cv_member_struct_tm_tm_gmtoff" = yes],
+    [AC_DEFINE([HAVE_TM_GMTOFF], [1],
+       [Define if struct tm has the tm_gmtoff member.
+        This macro is obsolete.
+        New code should use HAVE_STRUCT_TM_TM_GMTOFF.])])
 ])
index 330d5ea574e27c7c4e8e2ba2991e81c20c02b3e3..133b2c3e06ea960af13c34064983fc7fdddf1993 100644 (file)
@@ -49,7 +49,7 @@ static const char *const day_table[] =
 };
 
 
-#if ! HAVE_TM_GMTOFF
+#if ! HAVE_STRUCT_TM_TM_GMTOFF
 /* Shift A right by B bits portably, by dividing A by 2**B and
    truncating towards minus infinity.  A and B should be free of side
    effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
@@ -91,14 +91,14 @@ tm_diff (struct tm const *a, struct tm const *b)
                 + (a->tm_min - b->tm_min))
           + (a->tm_sec - b->tm_sec));
 }
-#endif /* ! HAVE_TM_GMTOFF */
+#endif
 
 static long
 gmt_offset (time_t s)
 {
   long gmtoff;
 
-#if !HAVE_TM_GMTOFF
+#if !HAVE_STRUCT_TM_TM_GMTOFF
   struct tm tm_local = *localtime (&s);
   struct tm tm_gmt   = *gmtime (&s);