verror: allow library name-spacing of verror
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 15 Aug 2024 03:04:42 +0000 (20:04 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 15 Aug 2024 03:13:24 +0000 (20:13 -0700)
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-08/msg00085.html
* lib/error.c (verror, verror_at_line) [!_LIBC]: #undef only if
the corresponding GNULIB_defined_... macros are defined.
* lib/error.in.h (verror, verror_with_line):
Don't define as macros if they are already defined, or if
_GL_NO_INLINE_ERROR is defined.  This may lose some niceties with GCC
warnings, but the code’s valid.

lib/error.c
lib/error.in.h

index 843e19304ea428391109f7603b036f9f28b3301e..837d5e56c624996e72d42400c5de43384c9019e5 100644 (file)
@@ -131,8 +131,12 @@ int strerror_r (int errnum, char *buf, size_t buflen);
 #  define __strerror_r strerror_r
 # endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
 
-# undef verror
-# undef verror_at_line
+# if GNULIB_defined_verror
+#  undef verror
+# endif
+# if GNULIB_defined_verror_at_line
+#  undef verror_at_line
+# endif
 #endif  /* not _LIBC */
 
 #if !_LIBC
index 82022a9362029ef71cc172ee96fe6bc185eadce6..4804c8c46549848bbb1380c89607f7a7fc5e11f8 100644 (file)
@@ -213,8 +213,13 @@ extern void verror (int __status, int __errnum, const char *__format,
                     va_list __args)
      _GL_ATTRIBUTE_COLD
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
-#define verror(status, ...) \
-   __gl_error_call (verror, status, __VA_ARGS__)
+#ifndef _GL_NO_INLINE_ERROR
+# ifndef verror
+#  define verror(status, ...) \
+     __gl_error_call (verror, status, __VA_ARGS__)
+#  define GNULIB_defined_verror 1
+# endif
+#endif
 
 /* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
@@ -228,8 +233,13 @@ extern void verror_at_line (int __status, int __errnum, const char *__fname,
                             va_list __args)
      _GL_ATTRIBUTE_COLD
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0));
-#define verror_at_line(status, ...) \
-   __gl_error_call (verror_at_line, status, __VA_ARGS__)
+#ifdef _GL_NO_INLINE_ERROR
+# ifndef verror_at_line
+#  define verror_at_line(status, ...) \
+     __gl_error_call (verror_at_line, status, __VA_ARGS__)
+#  define GNULIB_defined_verror_at_line 1
+# endif
+#endif
 
 /* If NULL, error will flush stdout, then print on stderr the program
    name, a colon and a space.  Otherwise, error will call this