summaryrefslogtreecommitdiff
path: root/m4/strerror.m4
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2007-09-25 10:40:16 -0600
committerEric Blake <ebb9@byu.net>2007-09-25 10:40:16 -0600
commitd5d3e86d326de4aa7d661fde1ebb636f3efbffd5 (patch)
tree63d0f761271c9884d613824cfd89f42caeda91bf /m4/strerror.m4
parenta1d5bf4615a98dd53267bf49646a09b823df3fe2 (diff)
downloadgnulib-d5d3e86d326de4aa7d661fde1ebb636f3efbffd5.tar.gz
Fix strerror on Interix.
* lib/string_.h (strerror): Declare replacement. * doc/functions/strerror.texi (strerror): Document the Interix shortcoming. * modules/string (Makefile.am): Support new hooks. * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Add new hooks. * m4/strerror.m4 (gl_FUNC_STRERROR): Defer to gl_FUNC_STRERROR_SEPARATE. (gl_FUNC_STRERROR_SEPARATE): Check for Interix bug. * lib/strerror.c (rpl_strerror): Provide replacement. * modules/strerror (Depends-on): Add string. (configure.ac): Detect use of module. * tests/test-strerror.c: New file. * modules/strerror-tests: New test module. * modules/argp (Depends-on): Add strerror. * modules/error (Depends-on): Likewise. Reported by Martin Koeppe. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'm4/strerror.m4')
-rw-r--r--m4/strerror.m431
1 files changed, 27 insertions, 4 deletions
diff --git a/m4/strerror.m4 b/m4/strerror.m4
index bbcda30508..52f3e3fdc3 100644
--- a/m4/strerror.m4
+++ b/m4/strerror.m4
@@ -1,4 +1,4 @@
-# strerror.m4 serial 3
+# strerror.m4 serial 4
dnl Copyright (C) 2002, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -6,10 +6,11 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_STRERROR],
[
- AC_CHECK_FUNCS_ONCE([strerror])
- if test $ac_cv_func_strerror = no; then
+ AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
+ if test $gl_cv_func_working_strerror = no; then
AC_LIBOBJ([strerror])
- gl_PREREQ_STRERROR
+ AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
+ [Define this to 1 if strerror is broken.])
fi
])
@@ -18,6 +19,28 @@ AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
[
AC_CHECK_FUNCS_ONCE([strerror])
gl_PREREQ_STRERROR
+ if test $ac_cv_func_strerror = no; then
+ HAVE_DECL_STRERROR=0
+ gl_cv_func_working_strerror=no
+ else
+ AC_CACHE_CHECK([for working strerror function],
+ [gl_cv_func_working_strerror],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([
+#include <string.h>
+ ], [return !*strerror (-2);])],
+ [gl_cv_func_working_strerror=yes], [gl_cv_func_working_strerror=no],
+ [dnl assume success except on Interix
+ AC_EGREP_CPP([assuming success], [
+#ifndef __INTERIX
+ assuming success
+#endif
+ ], [gl_cv_func_working_strerror=yes],
+ [gl_cv_func_working_strerror=no])])])
+ if test $gl_cv_func_working_strerror = no ; then
+ REPLACE_STRERROR=1
+ fi
+ fi
])
# Prerequisites of lib/strerror.c.