strerror_r-posix: Respect rules for use of AC_LIBOBJ.
[pspp] / m4 / strerror_r.m4
index 744488d84fe4d2c34e0fea5349618bc85dcdd013..1c0af3691dc0f7b01dffcc6020835d0e7d8f6847 100644 (file)
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 5
+# strerror_r.m4 serial 9
 dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,7 +33,7 @@ AC_DEFUN([gl_FUNC_STRERROR_R],
               [[#include <string.h>
                 int strerror_r (int, char *, size_t);
               ]],
-              [[return strerror (0);]])],
+              [])],
            [gl_cv_func_strerror_r_posix_signature=yes],
            [gl_cv_func_strerror_r_posix_signature=no])
         ])
@@ -42,13 +42,13 @@ AC_DEFUN([gl_FUNC_STRERROR_R],
         dnl HP-UX 11.31 strerror_r always fails when the buffer length argument
         dnl is less than 80.
         dnl FreeBSD 8.s strerror_r claims failure on 0
+        dnl Solaris 10 strerror_r corrupts errno on failure
         AC_CACHE_CHECK([whether strerror_r works],
           [gl_cv_func_strerror_r_works],
           [AC_RUN_IFELSE(
              [AC_LANG_PROGRAM(
                 [[#include <errno.h>
                   #include <string.h>
-                  int strerror_r (int, char *, size_t);
                 ]],
                 [[int result = 0;
                   char buf[79];
@@ -61,6 +61,11 @@ AC_DEFUN([gl_FUNC_STRERROR_R],
                     result |= 4;
                   if (errno)
                     result |= 8;
+                  errno = 0;
+                  if (strerror_r (-3, buf, sizeof buf) != 0)
+                    result |= 0x10;
+                  if (errno)
+                    result |= 0x20;
                   return result;
                 ]])],
              [gl_cv_func_strerror_r_works=yes],
@@ -95,13 +100,10 @@ changequote([,])dnl
       REPLACE_STRERROR_R=1
     fi
   fi
-  if test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1; then
-    AC_LIBOBJ([strerror_r])
-    gl_PREREQ_STRERROR_R
-  fi
 ])
 
 # Prerequisites of lib/strerror_r.c.
 AC_DEFUN([gl_PREREQ_STRERROR_R], [
+  AC_CHECK_FUNCS_ONCE([catgets])
   :
 ])