changeset 13661:e1c46598fd57

strsignal: work around NetBSD bug * m4/strsignal.m4 (gl_FUNC_STRSIGNAL): Also check in <unistd.h>. * lib/string.in.h (includes): Likewise. * doc/posix-functions/strsignal.texi (strsignal): Document the bug. Reported by Nelson H. F. Beebe. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Thu, 09 Sep 2010 17:05:15 -0600
parents 6a2c7d3ca5f0
children 4cbe1ae13867
files ChangeLog doc/posix-functions/strsignal.texi lib/string.in.h m4/strsignal.m4
diffstat 4 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-09-09  Eric Blake  <eblake@redhat.com>
 
+	strsignal: work around NetBSD bug
+	* m4/strsignal.m4 (gl_FUNC_STRSIGNAL): Also check in <unistd.h>.
+	* lib/string.in.h (includes): Likewise.
+	* doc/posix-functions/strsignal.texi (strsignal): Document the
+	bug.
+	Reported by Nelson H. F. Beebe.
+
 	gnulib-tool: work with NetBSD /bin/sh
 	* gnulib-tool (func_cache_var, func_cache_lookup_module)
 	(func_get_description, func_get_comment, func_get_status)
--- a/doc/posix-functions/strsignal.texi
+++ b/doc/posix-functions/strsignal.texi
@@ -16,6 +16,11 @@
 This function does not return a string for out-of-range numbers on
 some platforms:
 Solaris, AIX 5.1.
+
+@item
+This function is declared in @code{unistd.h} instead of
+@code{string.h} on some platforms:
+NetBSD 5.0.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -49,6 +49,12 @@
 # define _GL_ATTRIBUTE_PURE /* empty */
 #endif
 
+/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK)  \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
--- a/m4/strsignal.m4
+++ b/m4/strsignal.m4
@@ -1,4 +1,4 @@
-# strsignal.m4 serial 3
+# strsignal.m4 serial 4
 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -26,6 +26,7 @@
       [AC_RUN_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <string.h>
+#include <unistd.h> /* NetBSD 5.0 declares it in wrong header. */
             ]],
             [[char *s = strsignal (-1);
               return !(s != (char *) 0 && s != (char *) -1);]])],