From 48384fd1c637a2f683b634a4c3522eccc1b0dfe9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 14 Aug 2024 20:04:42 -0700 Subject: [PATCH] verror: allow library name-spacing of verror MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 8 ++++++-- lib/error.in.h | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/error.c b/lib/error.c index 843e19304e..837d5e56c6 100644 --- a/lib/error.c +++ b/lib/error.c @@ -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 diff --git a/lib/error.in.h b/lib/error.in.h index 82022a9362..4804c8c465 100644 --- a/lib/error.in.h +++ b/lib/error.in.h @@ -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 -- 2.39.5