bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH 1/2] parse-datetime2: new module
@ 2021-03-01  8:29 Paul Eggert
  2021-03-01  8:29 ` [PATCH 2/2] unlocked-io: do not redefine getc_unlocked etc Paul Eggert
  2021-03-03  3:25 ` [PATCH 1/2] parse-datetime2: new module Bruno Haible
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Eggert @ 2021-03-01  8:29 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

This splits the old parse-datetime into two parts; the
first is parse-datetime2 which supports all the new bells
and whistles, the second is parse-datetime, which reverts to
its original intent.  This avoids some bogus diagnostics
when build GNU Tar with gcc -flto -fanalyze and
with --enable-gcc-warnings.  And it slims down the
executable a bit.
* NEWS: Mention this.
* lib/parse-datetime.y (parser_control) [!GNULIB_PARSE_DATETIME2]:
Omit parse_datetime_debug member.
(debugging): New function.  Use it everywhere the old code
would load parse_datetime_debug.
(parse_datetime_body): New static function, with the body
of the old parse_datetime2.  Set pc.parse_datetime_debug
only if GNULIB_PARSE_DATETIME2.
(parse_datetime2, parse_datetime): Use this new function.
(parse_datetime2) [!GNULIB_PARSE_DATETIME2]: Remove.
---
 ChangeLog            |  21 ++++++++
 NEWS                 |   5 ++
 lib/parse-datetime.y | 122 +++++++++++++++++++++++++++----------------
 3 files changed, 102 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9bc60f88e..f4bf4fced 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2021-03-01  Paul Eggert  <eggert@cs.ucla.edu>
+
+	parse-datetime2: new module
+	This splits the old parse-datetime into two parts; the
+	first is parse-datetime2 which supports all the new bells
+	and whistles, the second is parse-datetime, which reverts to
+	its original intent.  This avoids some bogus diagnostics
+	when build GNU Tar with gcc -flto -fanalyze and
+	with --enable-gcc-warnings.  And it slims down the
+	executable a bit.
+	* NEWS: Mention this.
+	* lib/parse-datetime.y (parser_control) [!GNULIB_PARSE_DATETIME2]:
+	Omit parse_datetime_debug member.
+	(debugging): New function.  Use it everywhere the old code
+	would load parse_datetime_debug.
+	(parse_datetime_body): New static function, with the body
+	of the old parse_datetime2.  Set pc.parse_datetime_debug
+	only if GNULIB_PARSE_DATETIME2.
+	(parse_datetime2, parse_datetime): Use this new function.
+	(parse_datetime2) [!GNULIB_PARSE_DATETIME2]: Remove.
+
 2021-02-27  Bruno Haible  <bruno@clisp.org>
 
 	string-buffer: Fixes.
diff --git a/NEWS b/NEWS
index c347ecd96..318055ae8 100644
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,11 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2021-02-28  parse-datetime  The parse_datetime2 function has been moved
+                            to the new parse-datetime2 module, so that
+                            programs that need just parse_datetime need
+                            not build the fancier function.
+
 2020-12-23  execute         These functions no longer execute scripts without
             spawn-pipe      '#!' marker through /bin/sh. To execute such a
             posix_spawn     script as a shell script, either add a '#!/bin/sh'
diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
index b8a832fcd..552fe5c90 100644
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -221,8 +221,10 @@ typedef struct
   idx_t zones_seen;
   bool year_seen;
 
+#ifdef GNULIB_PARSE_DATETIME2
   /* Print debugging output to stderr.  */
   bool parse_datetime_debug;
+#endif
 
   /* Which of the 'seen' parts have been printed when debugging.  */
   bool debug_dates_seen;
@@ -239,6 +241,16 @@ typedef struct
   table local_time_zone_table[3];
 } parser_control;
 
+static bool
+debugging (parser_control const *pc)
+{
+#ifdef GNULIB_PARSE_DATETIME2
+  return pc->parse_datetime_debug;
+#else
+  return false;
+#endif
+}
+
 union YYSTYPE;
 static int yylex (union YYSTYPE *, parser_control *);
 static int yyerror (parser_control const *, char const *);
@@ -421,7 +433,7 @@ debug_print_current_time (char const *item, parser_control *pc)
 {
   bool space = false;
 
-  if (!pc->parse_datetime_debug)
+  if (!debugging (pc))
     return;
 
   /* no newline, more items printed below */
@@ -521,7 +533,7 @@ debug_print_relative_time (char const *item, parser_control const *pc)
 {
   bool space = false;
 
-  if (!pc->parse_datetime_debug)
+  if (!debugging (pc))
     return;
 
   /* no newline, more items printed below */
@@ -802,7 +814,7 @@ date:
            you want portability, use the ISO 8601 format.  */
         if (4 <= $1.digits)
           {
-            if (pc->parse_datetime_debug)
+            if (debugging (pc))
               {
                 intmax_t digits = $1.digits;
                 dbg_printf (_("warning: value %"PRIdMAX" has %"PRIdMAX" digits. "
@@ -816,7 +828,7 @@ date:
           }
         else
           {
-            if (pc->parse_datetime_debug)
+            if (debugging (pc))
               dbg_printf (_("warning: value %"PRIdMAX" has less than 4 digits. "
                             "Assuming MM/DD/YY[YY]\n"),
                           $1.value);
@@ -1504,7 +1516,7 @@ yylex (union YYSTYPE *lvalp, parser_control *pc)
           tp = lookup_word (pc, buff);
           if (! tp)
             {
-              if (pc->parse_datetime_debug)
+              if (debugging (pc))
                 dbg_printf (_("error: unknown word '%s'\n"), buff);
               return '?';
             }
@@ -1651,7 +1663,7 @@ debug_mktime_not_ok (struct tm const *tm0, struct tm const *tm1,
   const bool dst_shift = eq_sec && eq_min && !eq_hour
                          && eq_mday && eq_month && eq_year;
 
-  if (!pc->parse_datetime_debug)
+  if (!debugging (pc))
     return;
 
   dbg_printf (_("error: invalid date/time value:\n"));
@@ -1690,29 +1702,15 @@ debug_mktime_not_ok (struct tm const *tm0, struct tm const *tm1,
                               : _("missing timezone")));
 }
 
-/* The original interface: run with debug=false and the default timezone.   */
-bool
-parse_datetime (struct timespec *result, char const *p,
-                struct timespec const *now)
-{
-  char const *tzstring = getenv ("TZ");
-  timezone_t tz = tzalloc (tzstring);
-  if (!tz)
-    return false;
-  bool ok = parse_datetime2 (result, p, now, 0, tz, tzstring);
-  tzfree (tz);
-  return ok;
-}
-
 /* Parse a date/time string, storing the resulting time value into *RESULT.
    The string itself is pointed to by P.  Return true if successful.
    P can be an incomplete or relative time specification; if so, use
    *NOW as the basis for the returned time.  Default to timezone
    TZDEFAULT, which corresponds to tzalloc (TZSTRING).  */
-bool
-parse_datetime2 (struct timespec *result, char const *p,
-                 struct timespec const *now, unsigned int flags,
-                 timezone_t tzdefault, char const *tzstring)
+static bool
+parse_datetime_body (struct timespec *result, char const *p,
+                     struct timespec const *now, unsigned int flags,
+                     timezone_t tzdefault, char const *tzstring)
 {
   struct tm tm;
   struct tm tm0;
@@ -1803,10 +1801,12 @@ parse_datetime2 (struct timespec *result, char const *p,
 
   parser_control pc;
   pc.input = p;
+#ifdef GNULIB_PARSE_DATETIME2
   pc.parse_datetime_debug = (flags & PARSE_DATETIME_DEBUG) != 0;
+#endif
   if (INT_ADD_WRAPV (tmp.tm_year, TM_YEAR_BASE, &pc.year.value))
     {
-      if (pc.parse_datetime_debug)
+      if (debugging (&pc))
         dbg_printf (_("error: initial year out of range\n"));
       goto fail;
     }
@@ -1900,7 +1900,7 @@ parse_datetime2 (struct timespec *result, char const *p,
 
   if (yyparse (&pc) != 0)
     {
-      if (pc.parse_datetime_debug)
+      if (debugging (&pc))
         dbg_printf ((input_sentinel <= pc.input
                      ? _("error: parsing failed\n")
                      : _("error: parsing failed, stopped at '%s'\n")),
@@ -1911,7 +1911,7 @@ parse_datetime2 (struct timespec *result, char const *p,
 
   /* Determine effective timezone source.  */
 
-  if (pc.parse_datetime_debug)
+  if (debugging (&pc))
     {
       dbg_printf (_("input timezone: "));
 
@@ -1953,7 +1953,7 @@ parse_datetime2 (struct timespec *result, char const *p,
       if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen
                | (pc.local_zones_seen + pc.zones_seen)))
         {
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             {
               if (pc.times_seen > 1)
                 dbg_printf ("error: seen multiple time parts\n");
@@ -1969,11 +1969,11 @@ parse_datetime2 (struct timespec *result, char const *p,
           goto fail;
         }
 
-      if (! to_tm_year (pc.year, pc.parse_datetime_debug, &tm.tm_year)
+      if (! to_tm_year (pc.year, debugging (&pc), &tm.tm_year)
           || INT_ADD_WRAPV (pc.month, -1, &tm.tm_mon)
           || INT_ADD_WRAPV (pc.day, 0, &tm.tm_mday))
         {
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             dbg_printf (_("error: year, month, or day overflow\n"));
           goto fail;
         }
@@ -1984,14 +1984,14 @@ parse_datetime2 (struct timespec *result, char const *p,
             {
               char const *mrd = (pc.meridian == MERam ? "am"
                                  : pc.meridian == MERpm ?"pm" : "");
-              if (pc.parse_datetime_debug)
+              if (debugging (&pc))
                 dbg_printf (_("error: invalid hour %"PRIdMAX"%s\n"),
                             pc.hour, mrd);
               goto fail;
             }
           tm.tm_min = pc.minutes;
           tm.tm_sec = pc.seconds.tv_sec;
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             dbg_printf ((pc.times_seen
                          ? _("using specified time as starting value: '%s'\n")
                          : _("using current time as starting value: '%s'\n")),
@@ -2001,7 +2001,7 @@ parse_datetime2 (struct timespec *result, char const *p,
         {
           tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
           pc.seconds.tv_nsec = 0;
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             dbg_printf ("warning: using midnight as starting time: 00:00:00\n");
         }
 
@@ -2047,7 +2047,7 @@ parse_datetime2 (struct timespec *result, char const *p,
               timezone_t tz2 = tzalloc (tz2buf);
               if (!tz2)
                 {
-                  if (pc.parse_datetime_debug)
+                  if (debugging (&pc))
                     dbg_printf (_("error: tzalloc (\"%s\") failed\n"), tz2buf);
                   goto fail;
                 }
@@ -2092,7 +2092,7 @@ parse_datetime2 (struct timespec *result, char const *p,
 
           if (Start == (time_t) -1)
             {
-              if (pc.parse_datetime_debug)
+              if (debugging (&pc))
                 dbg_printf (_("error: day '%s' "
                               "(day ordinal=%"PRIdMAX" number=%d) "
                               "resulted in an invalid date: '%s'\n"),
@@ -2103,14 +2103,14 @@ parse_datetime2 (struct timespec *result, char const *p,
               goto fail;
             }
 
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             dbg_printf (_("new start date: '%s' is '%s'\n"),
                         str_days (&pc, dbg_ord, sizeof dbg_ord),
                         debug_strfdatetime (&tm, &pc, dbg_tm, sizeof dbg_tm));
 
         }
 
-      if (pc.parse_datetime_debug)
+      if (debugging (&pc))
         {
           if (!pc.dates_seen && !pc.days_seen)
             dbg_printf (_("using current date as starting value: '%s'\n"),
@@ -2128,7 +2128,7 @@ parse_datetime2 (struct timespec *result, char const *p,
       /* Add relative date.  */
       if (pc.rel.year | pc.rel.month | pc.rel.day)
         {
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             {
               if ((pc.rel.year != 0 || pc.rel.month != 0) && tm.tm_mday != 15)
                 dbg_printf (_("warning: when adding relative months/years, "
@@ -2145,7 +2145,7 @@ parse_datetime2 (struct timespec *result, char const *p,
               || INT_ADD_WRAPV (tm.tm_mon, pc.rel.month, &month)
               || INT_ADD_WRAPV (tm.tm_mday, pc.rel.day, &day))
             {
-              if (pc.parse_datetime_debug)
+              if (debugging (&pc))
                 dbg_printf (_("error: %s:%d\n"), __FILE__, __LINE__);
               goto fail;
             }
@@ -2159,7 +2159,7 @@ parse_datetime2 (struct timespec *result, char const *p,
           Start = mktime_z (tz, &tm);
           if (Start == (time_t) -1)
             {
-              if (pc.parse_datetime_debug)
+              if (debugging (&pc))
                 dbg_printf (_("error: adding relative date resulted "
                               "in an invalid date: '%s'\n"),
                             debug_strfdatetime (&tm, &pc, dbg_tm,
@@ -2167,7 +2167,7 @@ parse_datetime2 (struct timespec *result, char const *p,
               goto fail;
             }
 
-          if (pc.parse_datetime_debug)
+          if (debugging (&pc))
             {
               dbg_printf (_("after date adjustment "
                             "(%+"PRIdMAX" years, %+"PRIdMAX" months, "
@@ -2244,7 +2244,7 @@ parse_datetime2 (struct timespec *result, char const *p,
           overflow |= INT_SUBTRACT_WRAPV (Start, delta, &t1);
           if (overflow)
             {
-              if (pc.parse_datetime_debug)
+              if (debugging (&pc))
                 dbg_printf (_("error: timezone %d caused time_t overflow\n"),
                             pc.time_zone);
               goto fail;
@@ -2252,7 +2252,7 @@ parse_datetime2 (struct timespec *result, char const *p,
           Start = t1;
         }
 
-      if (pc.parse_datetime_debug)
+      if (debugging (&pc))
         {
           intmax_t Starti = Start;
           dbg_printf (_("'%s' = %"PRIdMAX" epoch-seconds\n"),
@@ -2282,7 +2282,7 @@ parse_datetime2 (struct timespec *result, char const *p,
             || INT_ADD_WRAPV (t2, pc.rel.seconds, &t3)
             || INT_ADD_WRAPV (t3, d4, &t4))
           {
-            if (pc.parse_datetime_debug)
+            if (debugging (&pc))
               dbg_printf (_("error: adding relative time caused an "
                             "overflow\n"));
             goto fail;
@@ -2291,7 +2291,7 @@ parse_datetime2 (struct timespec *result, char const *p,
         result->tv_sec = t4;
         result->tv_nsec = normalized_ns;
 
-        if (pc.parse_datetime_debug
+        if (debugging (&pc)
             && (pc.rel.hour | pc.rel.minutes | pc.rel.seconds | pc.rel.ns))
           {
             dbg_printf (_("after time adjustment (%+"PRIdMAX" hours, "
@@ -2322,7 +2322,7 @@ parse_datetime2 (struct timespec *result, char const *p,
       }
     }
 
-  if (pc.parse_datetime_debug)
+  if (debugging (&pc))
     {
       /* Special case: using 'date -u' simply set TZ=UTC0 */
       if (! tzstring)
@@ -2373,6 +2373,36 @@ parse_datetime2 (struct timespec *result, char const *p,
   return ok;
 }
 
+#ifdef GNULIB_PARSE_DATETIME2
+/* Parse a date/time string, storing the resulting time value into *RESULT.
+   The string itself is pointed to by P.  Return true if successful.
+   P can be an incomplete or relative time specification; if so, use
+   *NOW as the basis for the returned time.  Default to timezone
+   TZDEFAULT, which corresponds to tzalloc (TZSTRING).  */
+bool
+parse_datetime2 (struct timespec *result, char const *p,
+                 struct timespec const *now, unsigned int flags,
+                 timezone_t tzdefault, char const *tzstring)
+{
+  return parse_datetime_body (result, p, now, flags, tzdefault, tzstring);
+}
+#endif
+
+
+/* The plain interface: run with debug=false and the default timezone.   */
+bool
+parse_datetime (struct timespec *result, char const *p,
+                struct timespec const *now)
+{
+  char const *tzstring = getenv ("TZ");
+  timezone_t tz = tzalloc (tzstring);
+  if (!tz)
+    return false;
+  bool ok = parse_datetime_body (result, p, now, 0, tz, tzstring);
+  tzfree (tz);
+  return ok;
+}
+
 #if TEST
 
 int
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] unlocked-io: do not redefine getc_unlocked etc.
  2021-03-01  8:29 [PATCH 1/2] parse-datetime2: new module Paul Eggert
@ 2021-03-01  8:29 ` Paul Eggert
  2021-03-03  3:25 ` [PATCH 1/2] parse-datetime2: new module Bruno Haible
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2021-03-01  8:29 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

I ran into this problem on AIX 7.1 with GNU Tar, which
enables visibility of getc_unlocked etc. after testing
whether they’re declared, causing argp-namefrob.h and
unlocked-io.h to redefine the macros.
* lib/argp-namefrob.h, lib/unlocked-io.h:
(clearerr_unlocked, feof_unlocked ferror_unlocked)
(fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked)
(fread_unlocked, fwrite_unlocked, getc_unlocked, getchar_unlocked)
(putc_unlocked, putchar_unlocked): Do not define if already defined.
---
 ChangeLog           | 11 +++++++++++
 lib/argp-namefrob.h | 41 +++++++++++++++++++++++++++--------------
 lib/unlocked-io.h   | 26 +++++++++++++-------------
 3 files changed, 51 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f4bf4fced..c13c6816d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2021-03-01  Paul Eggert  <eggert@cs.ucla.edu>
 
+	unlocked-io: do not redefine getc_unlocked etc.
+	I ran into this problem on AIX 7.1 with GNU Tar, which
+	enables visibility of getc_unlocked etc. after testing
+	whether they’re declared, causing argp-namefrob.h and
+	unlocked-io.h to redefine the macros.
+	* lib/argp-namefrob.h, lib/unlocked-io.h:
+	(clearerr_unlocked, feof_unlocked ferror_unlocked)
+	(fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked)
+	(fread_unlocked, fwrite_unlocked, getc_unlocked, getchar_unlocked)
+	(putc_unlocked, putchar_unlocked): Do not define if already defined.
+
 	parse-datetime2: new module
 	This splits the old parse-datetime into two parts; the
 	first is parse-datetime2 which supports all the new bells
diff --git a/lib/argp-namefrob.h b/lib/argp-namefrob.h
index f3216d7dd..de1a26e2a 100644
--- a/lib/argp-namefrob.h
+++ b/lib/argp-namefrob.h
@@ -95,43 +95,56 @@
 #undef __vsnprintf
 #define __vsnprintf vsnprintf
 
-#if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
+#if (defined HAVE_DECL_CLEARERR_UNLOCKED  && !HAVE_DECL_CLEARERR_UNLOCKED \
+     && !defined clearerr_unlocked)
 # define clearerr_unlocked(x) clearerr (x)
 #endif
-#if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
+#if (defined HAVE_DECL_FEOF_UNLOCKED && !HAVE_DECL_FEOF_UNLOCKED \
+     && !defined feof_unlocked)
 # define feof_unlocked(x) feof (x)
 #endif
-#if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
+#if (defined HAVE_DECL_FERROR_UNLOCKED && !HAVE_DECL_FERROR_UNLOCKED \
+     && !defined ferror_unlocked)
 # define ferror_unlocked(x) ferror (x)
 #endif
-#if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
+#if (defined HAVE_DECL_FFLUSH_UNLOCKED && !HAVE_DECL_FFLUSH_UNLOCKED \
+     && !defined fflush_unlocked)
 # define fflush_unlocked(x) fflush (x)
 #endif
-#if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
+#if (defined HAVE_DECL_FGETS_UNLOCKED && !HAVE_DECL_FGETS_UNLOCKED \
+     && !defined fgets_unlocked)
 # define fgets_unlocked(x,y,z) fgets (x,y,z)
 #endif
-#if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
+#if (defined HAVE_DECL_FPUTC_UNLOCKED && !HAVE_DECL_FPUTC_UNLOCKED \
+     && !defined fputc_unlocked)
 # define fputc_unlocked(x,y) fputc (x,y)
 #endif
-#if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
+#if (defined HAVE_DECL_FPUTS_UNLOCKED && !HAVE_DECL_FPUTS_UNLOCKED \
+     && !defined fputs_unlocked)
 # define fputs_unlocked(x,y) fputs (x,y)
 #endif
-#if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
+#if (defined HAVE_DECL_FREAD_UNLOCKED && !HAVE_DECL_FREAD_UNLOCKED \
+     && !defined fread_unlocked)
 # define fread_unlocked(w,x,y,z) fread (w,x,y,z)
 #endif
-#if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
+#if (defined HAVE_DECL_FWRITE_UNLOCKED && !HAVE_DECL_FWRITE_UNLOCKED \
+     && !defined fwrite_unlocked)
 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
 #endif
-#if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
+#if (defined HAVE_DECL_GETC_UNLOCKED && !HAVE_DECL_GETC_UNLOCKED \
+     && !defined getc_unlocked)
 # define getc_unlocked(x) getc (x)
 #endif
-#if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
-#  define getchar_unlocked() getchar ()
+#if (defined HAVE_DECL_GETCHAR_UNLOCKED && !HAVE_DECL_GETCHAR_UNLOCKED \
+     && !defined getchar_unlocked)
+# define getchar_unlocked() getchar ()
 #endif
-#if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
+#if (defined HAVE_DECL_PUTC_UNLOCKED && !HAVE_DECL_PUTC_UNLOCKED \
+     && !defined putc_unlocked)
 # define putc_unlocked(x,y) putc (x,y)
 #endif
-#if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
+#if (defined HAVE_DECL_PUTCHAR_UNLOCKED && !HAVE_DECL_PUTCHAR_UNLOCKED \
+     && !defined putchar_unlocked)
 # define putchar_unlocked(x) putchar (x)
 #endif
 
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index 86b91c19d..ca184b31f 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -33,91 +33,91 @@
 
 # include <stdio.h>
 
-# if HAVE_DECL_CLEARERR_UNLOCKED
+# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked
 #  undef clearerr
 #  define clearerr(x) clearerr_unlocked (x)
 # else
 #  define clearerr_unlocked(x) clearerr (x)
 # endif
 
-# if HAVE_DECL_FEOF_UNLOCKED
+# if HAVE_DECL_FEOF_UNLOCKED || defined feof_unlocked
 #  undef feof
 #  define feof(x) feof_unlocked (x)
 # else
 #  define feof_unlocked(x) feof (x)
 # endif
 
-# if HAVE_DECL_FERROR_UNLOCKED
+# if HAVE_DECL_FERROR_UNLOCKED || defined ferror_unlocked
 #  undef ferror
 #  define ferror(x) ferror_unlocked (x)
 # else
 #  define ferror_unlocked(x) ferror (x)
 # endif
 
-# if HAVE_DECL_FFLUSH_UNLOCKED
+# if HAVE_DECL_FFLUSH_UNLOCKED || defined fflush_unlocked
 #  undef fflush
 #  define fflush(x) fflush_unlocked (x)
 # else
 #  define fflush_unlocked(x) fflush (x)
 # endif
 
-# if HAVE_DECL_FGETS_UNLOCKED
+# if HAVE_DECL_FGETS_UNLOCKED || defined fgets_unlocked
 #  undef fgets
 #  define fgets(x,y,z) fgets_unlocked (x,y,z)
 # else
 #  define fgets_unlocked(x,y,z) fgets (x,y,z)
 # endif
 
-# if HAVE_DECL_FPUTC_UNLOCKED
+# if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked
 #  undef fputc
 #  define fputc(x,y) fputc_unlocked (x,y)
 # else
 #  define fputc_unlocked(x,y) fputc (x,y)
 # endif
 
-# if HAVE_DECL_FPUTS_UNLOCKED
+# if HAVE_DECL_FPUTS_UNLOCKED || defined fputs_unlocked
 #  undef fputs
 #  define fputs(x,y) fputs_unlocked (x,y)
 # else
 #  define fputs_unlocked(x,y) fputs (x,y)
 # endif
 
-# if HAVE_DECL_FREAD_UNLOCKED
+# if HAVE_DECL_FREAD_UNLOCKED || defined fread_unlocked
 #  undef fread
 #  define fread(w,x,y,z) fread_unlocked (w,x,y,z)
 # else
 #  define fread_unlocked(w,x,y,z) fread (w,x,y,z)
 # endif
 
-# if HAVE_DECL_FWRITE_UNLOCKED
+# if HAVE_DECL_FWRITE_UNLOCKED || defined fwrite_unlocked
 #  undef fwrite
 #  define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
 # else
 #  define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
 # endif
 
-# if HAVE_DECL_GETC_UNLOCKED
+# if HAVE_DECL_GETC_UNLOCKED || defined get_unlocked
 #  undef getc
 #  define getc(x) getc_unlocked (x)
 # else
 #  define getc_unlocked(x) getc (x)
 # endif
 
-# if HAVE_DECL_GETCHAR_UNLOCKED
+# if HAVE_DECL_GETCHAR_UNLOCKED || defined getchar_unlocked
 #  undef getchar
 #  define getchar() getchar_unlocked ()
 # else
 #  define getchar_unlocked() getchar ()
 # endif
 
-# if HAVE_DECL_PUTC_UNLOCKED
+# if HAVE_DECL_PUTC_UNLOCKED || defined putc_unlocked
 #  undef putc
 #  define putc(x,y) putc_unlocked (x,y)
 # else
 #  define putc_unlocked(x,y) putc (x,y)
 # endif
 
-# if HAVE_DECL_PUTCHAR_UNLOCKED
+# if HAVE_DECL_PUTCHAR_UNLOCKED || defined putchar_unlocked
 #  undef putchar
 #  define putchar(x) putchar_unlocked (x)
 # else
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] parse-datetime2: new module
  2021-03-01  8:29 [PATCH 1/2] parse-datetime2: new module Paul Eggert
  2021-03-01  8:29 ` [PATCH 2/2] unlocked-io: do not redefine getc_unlocked etc Paul Eggert
@ 2021-03-03  3:25 ` Bruno Haible
  2021-03-06 16:26   ` Paul Eggert
  1 sibling, 1 reply; 5+ messages in thread
From: Bruno Haible @ 2021-03-03  3:25 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

Hi Paul,

> +	parse-datetime2: new module

gnulib-tool gives me these warnings

$ ./gnulib-tool --create-testdir --dir=../testdir-all --single-configure
gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: gettime
gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: nstrftime
gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: parse-datetime
gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: time_rz
gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: timespec
gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: tzset

Bruno



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] parse-datetime2: new module
  2021-03-03  3:25 ` [PATCH 1/2] parse-datetime2: new module Bruno Haible
@ 2021-03-06 16:26   ` Paul Eggert
  2021-03-06 17:54     ` Bruno Haible
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2021-03-06 16:26 UTC (permalink / raw)
  To: Bruno Haible; +Cc: Gnulib bugs

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

On 3/2/21 7:25 PM, Bruno Haible wrote:

> $ ./gnulib-tool --create-testdir --dir=../testdir-all --single-configure
> gnulib-tool: warning: module parse-datetime2 depends on a module with an incompatible license: gettime
...

Thanks for the heads-up; I had forgotten about the parse-datetime 
special case for licensing. I installed the attached 1-byte patch to 
work around the issue.

[-- Attachment #2: 0001-parse-datetime2-fix-licensing.patch --]
[-- Type: text/x-patch, Size: 1538 bytes --]

From 487b9551b63ef936a6be6df38d1c9484cd97810c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 6 Mar 2021 08:23:48 -0800
Subject: [PATCH] parse-datetime2: fix licensing

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2021-03/msg00017.html
* gnulib-tool (func_get_license): Treat parse-datetime2
(actually, anything starting with "parse-datetime")
like parse-datetime, as far as licenses go.
---
 ChangeLog   | 9 +++++++++
 gnulib-tool | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 86c3e04e8..9706d7826 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-03-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+	parse-datetime2: fix licensing
+	Problem reported by Bruno Haible in:
+	https://lists.gnu.org/r/bug-gnulib/2021-03/msg00017.html
+	* gnulib-tool (func_get_license): Treat parse-datetime2
+	(actually, anything starting with "parse-datetime")
+	like parse-datetime, as far as licenses go.
+
 2021-03-06  Bruno Haible  <bruno@clisp.org>
 
 	free-posix: Update documentation.
diff --git a/gnulib-tool b/gnulib-tool
index 2ba5dec65..23b2c4456 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -2683,7 +2683,7 @@ func_get_license ()
       ;;
   esac
   case "$1" in
-    parse-datetime )
+    parse-datetime* )
       # These modules are under a weaker license only for the purpose of some
       # users who hand-edit it and don't use gnulib-tool. For the regular
       # gnulib users they are under a stricter license.
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] parse-datetime2: new module
  2021-03-06 16:26   ` Paul Eggert
@ 2021-03-06 17:54     ` Bruno Haible
  0 siblings, 0 replies; 5+ messages in thread
From: Bruno Haible @ 2021-03-06 17:54 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Gnulib bugs

Paul Eggert wrote:
> Thanks for the heads-up; I had forgotten about the parse-datetime 
> special case for licensing. I installed the attached 1-byte patch to 
> work around the issue.

Thanks. I had forgotten about this special case as well...

Bruno



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-06 17:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01  8:29 [PATCH 1/2] parse-datetime2: new module Paul Eggert
2021-03-01  8:29 ` [PATCH 2/2] unlocked-io: do not redefine getc_unlocked etc Paul Eggert
2021-03-03  3:25 ` [PATCH 1/2] parse-datetime2: new module Bruno Haible
2021-03-06 16:26   ` Paul Eggert
2021-03-06 17:54     ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).