* 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 | 7 +++++++ lib/parse-datetime.y | 8 ++++---- lib/strftime.c | 8 ++++---- lib/strptime.c | 2 +- m4/tm_gmtoff.m4 | 17 +++++++++++------ tests/test-parse-datetime.c | 6 +++--- 6 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog index b551084953..ebdd04567f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-06-16 Paul Eggert <egg...@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 <br...@clisp.org> Drop outdated cppi configuration. diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y index 83e0ba38ce..f98e7200d6 100644 --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -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 diff --git a/lib/strftime.c b/lib/strftime.c index 7d124e68f3..cd216fb6a5 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -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) diff --git a/lib/strptime.c b/lib/strptime.c index 568caf6df8..e0fe2bfd9a 100644 --- a/lib/strptime.c +++ b/lib/strptime.c @@ -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; diff --git a/m4/tm_gmtoff.m4 b/m4/tm_gmtoff.m4 index 0c7dcb2a09..ad64df4954 100644 --- a/m4/tm_gmtoff.m4 +++ b/m4/tm_gmtoff.m4 @@ -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.])]) ]) diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c index 330d5ea574..133b2c3e06 100644 --- a/tests/test-parse-datetime.c +++ b/tests/test-parse-datetime.c @@ -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); -- 2.43.0