1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

strerrorname_np: New module.

* lib/string.in.h (strerrorname_np): New declaration.
* lib/strerrorname_np.c: New file.
* m4/strerrorname_np.m4: New file.
* m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Test whether strerrorname_np
is declared.
(gl_HEADER_STRING_H_DEFAULTS): Initialize GNULIB_STRERRORNAME_NP,
HAVE_STRERRORNAME_NP, REPLACE_STRERRORNAME_NP.
* modules/string (Makefile.am): Substitute GNULIB_STRERRORNAME_NP,
HAVE_STRERRORNAME_NP, REPLACE_STRERRORNAME_NP.
* modules/strerrorname_np: New file.
* tests/test-string-c++.cc: Verify the signature of strerrorname_np.
* doc/glibc-functions/strerrorname_np.texi: Mention the new module and
the glibc 2.32 bug.
This commit is contained in:
Bruno Haible
2020-08-30 22:19:05 +02:00
parent 175e0bc728
commit 4041bb7cb2
9 changed files with 1519 additions and 48 deletions

View File

@@ -1,3 +1,20 @@
2020-08-30 Bruno Haible <bruno@clisp.org>
strerrorname_np: New module.
* lib/string.in.h (strerrorname_np): New declaration.
* lib/strerrorname_np.c: New file.
* m4/strerrorname_np.m4: New file.
* m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Test whether strerrorname_np
is declared.
(gl_HEADER_STRING_H_DEFAULTS): Initialize GNULIB_STRERRORNAME_NP,
HAVE_STRERRORNAME_NP, REPLACE_STRERRORNAME_NP.
* modules/string (Makefile.am): Substitute GNULIB_STRERRORNAME_NP,
HAVE_STRERRORNAME_NP, REPLACE_STRERRORNAME_NP.
* modules/strerrorname_np: New file.
* tests/test-string-c++.cc: Verify the signature of strerrorname_np.
* doc/glibc-functions/strerrorname_np.texi: Mention the new module and
the glibc 2.32 bug.
2020-08-27 Paul Eggert <eggert@cs.ucla.edu> 2020-08-27 Paul Eggert <eggert@cs.ucla.edu>
perror, strerror_r: remove unportable tests perror, strerror_r: remove unportable tests

View File

@@ -10,15 +10,19 @@ Documentation:@*
@url{https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html}. @url{https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html}.
@end ifnotinfo @end ifnotinfo
Gnulib module: --- Gnulib module: strerrorname_np
Portability problems fixed by Gnulib: Portability problems fixed by Gnulib:
@itemize @itemize
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item @item
This function is missing on all non-glibc platforms: This function is missing on all non-glibc platforms:
glibc 2.31, Mac OS X 10.13, FreeBSD 6.4, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android 9.0. glibc 2.31, Mac OS X 10.13, FreeBSD 6.4, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
@item
This function returns wrong values on some platforms:
@c https://sourceware.org/bugzilla/show_bug.cgi?id=26555
glibc 2.32.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@end itemize @end itemize

1342
lib/strerrorname_np.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1045,6 +1045,30 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
# endif # endif
#endif #endif
/* Return the name of the system error code ERRNUM. */
#if @GNULIB_STRERRORNAME_NP@
# if @REPLACE_STRERRORNAME_NP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef strerrorname_np
# define strerrorname_np rpl_strerrorname_np
# endif
_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
# else
# if !@HAVE_STRERRORNAME_NP@
_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
# endif
_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
# endif
_GL_CXXALIASWARN (strerrorname_np);
#elif defined GNULIB_POSIXCHECK
# undef strerrorname_np
# if HAVE_RAW_DECL_STRERRORNAME_NP
_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
"use gnulib module strerrorname_np for portability");
# endif
#endif
/* Return an abbreviation string for the signal number SIG. */ /* Return an abbreviation string for the signal number SIG. */
#if @GNULIB_SIGABBREV_NP@ #if @GNULIB_SIGABBREV_NP@
# if ! @HAVE_SIGABBREV_NP@ # if ! @HAVE_SIGABBREV_NP@

46
m4/strerrorname_np.m4 Normal file
View File

@@ -0,0 +1,46 @@
# strerrorname_np.m4 serial 1
dnl Copyright (C) 2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_STRERRORNAME_NP],
[
dnl Persuade glibc <string.h> to declare strerrorname_np().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
AC_CHECK_FUNCS([strerrorname_np])
if test $ac_cv_func_strerrorname_np = yes; then
dnl In glibc 2.32, strerrorname_np returns English error descriptions, not
dnl error names.
dnl See <https://sourceware.org/bugzilla/show_bug.cgi?id=26555>.
AC_CACHE_CHECK([whether strerrorname_np works],
[gl_cv_func_strerrorname_np_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <errno.h>
#include <string.h>
]],
[[return strcmp (strerrorname_np (EINVAL), "EINVAL") != 0;
]])],
[gl_cv_func_strerrorname_np_works=yes],
[gl_cv_func_strerrorname_np_works=no],
[case "$host_os" in
# Guess no on glibc systems.
*-gnu* | gnu*)
gl_cv_func_strerrorname_np_works="guessing no" ;;
# Otherwise obey --enable-cross-guesses.
*)
gl_cv_func_strerrorname_np_works="$gl_cross_guess_normal" ;;
esac
])
])
case "$gl_cv_func_strerrorname_np_works" in
*yes) ;;
*) REPLACE_STRERRORNAME_NP=1 ;;
esac
else
HAVE_STRERRORNAME_NP=0
fi
])

View File

@@ -5,7 +5,7 @@
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved. # with or without modifications, as long as this notice is preserved.
# serial 26 # serial 27
# Written by Paul Eggert. # Written by Paul Eggert.
@@ -28,7 +28,7 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
]], ]],
[ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul
strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
strerror_r sigabbrev_np sigdescr_np strsignal strverscmp]) strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp])
AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([AC_C_RESTRICT])
]) ])
@@ -80,6 +80,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R])
GNULIB_STRERRORNAME_NP=0; AC_SUBST([GNULIB_STRERRORNAME_NP])
GNULIB_SIGABBREV_NP=0; AC_SUBST([GNULIB_SIGABBREV_NP]) GNULIB_SIGABBREV_NP=0; AC_SUBST([GNULIB_SIGABBREV_NP])
GNULIB_SIGDESCR_NP=0; AC_SUBST([GNULIB_SIGDESCR_NP]) GNULIB_SIGDESCR_NP=0; AC_SUBST([GNULIB_SIGDESCR_NP])
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
@@ -104,6 +105,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP])
HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP]) HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP]) HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
@@ -121,6 +123,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP])
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
]) ])

28
modules/strerrorname_np Normal file
View File

@@ -0,0 +1,28 @@
Description:
strerrorname_np() function: name of system error code.
Files:
lib/strerrorname_np.c
m4/strerrorname_np.m4
Depends-on:
extensions
string
configure.ac:
gl_FUNC_STRERRORNAME_NP
if test $HAVE_STRERRORNAME_NP = 0 || test $REPLACE_STRERRORNAME_NP = 1; then
AC_LIBOBJ([strerrorname_np])
fi
gl_STRING_MODULE_INDICATOR([strerrorname_np])
Makefile.am:
Include:
<string.h>
License:
LGPLv2+
Maintainer:
all

View File

@@ -66,6 +66,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
-e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
-e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
-e 's/@''GNULIB_STRERRORNAME_NP''@/$(GNULIB_STRERRORNAME_NP)/g' \
-e 's/@''GNULIB_SIGABBREV_NP''@/$(GNULIB_SIGABBREV_NP)/g' \ -e 's/@''GNULIB_SIGABBREV_NP''@/$(GNULIB_SIGABBREV_NP)/g' \
-e 's/@''GNULIB_SIGDESCR_NP''@/$(GNULIB_SIGDESCR_NP)/g' \ -e 's/@''GNULIB_SIGDESCR_NP''@/$(GNULIB_SIGDESCR_NP)/g' \
-e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
@@ -90,6 +91,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
-e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
-e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
-e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \
-e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \ -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \
-e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \ -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
@@ -107,6 +109,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
-e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
-e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \

View File

@@ -138,6 +138,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::strerror, char *, (int));
SIGNATURE_CHECK (GNULIB_NAMESPACE::strerror_r, int, (int, char *, size_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::strerror_r, int, (int, char *, size_t));
#endif #endif
#if GNULIB_TEST_STRERRORNAME_NP
SIGNATURE_CHECK (GNULIB_NAMESPACE::strerrorname_np, const char *, (int));
#endif
#if GNULIB_TEST_SIGABBREV_NP #if GNULIB_TEST_SIGABBREV_NP
SIGNATURE_CHECK (GNULIB_NAMESPACE::sigabbrev_np, const char *, (int)); SIGNATURE_CHECK (GNULIB_NAMESPACE::sigabbrev_np, const char *, (int));
#endif #endif