Eric Blake wrote on 2011-06-21: > diff --git a/ChangeLog b/ChangeLog > index 07f3819..36d72ae 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,5 +1,9 @@ > 2011-06-21 Eric Blake <ebl...@redhat.com> > > + perror: test for output mismatch > + * m4/perror.m4 (gl_FUNC_PERROR): Add test, in order to replace > + perror on IRIX. > + > strerror_r: fix OpenBSD behavior on out-of-range > * lib/strerror_r.c (strerror_r): Always use maximal string. > * doc/posix-functions/strerror_r.texi (strerror_r): Document it. > diff --git a/m4/perror.m4 b/m4/perror.m4 > index d08f365..86e2020 100644 > --- a/m4/perror.m4 > +++ b/m4/perror.m4 > @@ -1,4 +1,4 @@ > -# perror.m4 serial 2 > +# perror.m4 serial 3 > dnl Copyright (C) 2008-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, > @@ -9,13 +9,45 @@ AC_DEFUN([gl_FUNC_PERROR], > AC_REQUIRE([gl_STDIO_H_DEFAULTS]) > AC_REQUIRE([gl_HEADER_ERRNO_H]) > AC_REQUIRE([gl_FUNC_STRERROR_R]) > - if test -n "$ERRNO_H"; then > + AC_REQUIRE([gl_FUNC_STRERROR_0]) > + dnl We intentionally do not check for the broader REPLACE_STRERROR_R, > + dnl since on glibc systems, strerror_r is replaced only for signature > + dnl issues, and perror is just fine. Rather, we only want to > + dnl replace perror if strerror_r was replaced for a content fix. > + if test "$ERRNO_H:$REPLACE_STRERROR_0" != :0; then > dnl The system's perror() cannot know about the new errno values we add > - dnl to <errno.h>. Replace it. > + dnl to <errno.h>, or any fix for strerror(0). Replace it. > REPLACE_PERROR=1 > fi > case ${gl_cv_func_strerror_r_works-unset} in > - unset|*yes) ;; > + unset|*yes) > + AC_CACHE_CHECK([whether perror matches strerror], > + [gl_cv_func_perror_works], > + [AC_RUN_IFELSE( > + [AC_LANG_PROGRAM( > + [[#include <errno.h> > + #include <stdio.h> > + ]], > + [[char *str = strerror (-1); > + if (!getenv("CONFTEST_OUTPUT")) return 0; > + if (!str) str = ""; > + puts (str); > + errno = -1; > + perror (""); > + ]])], > + [CONFTEST_OUTPUT=1 ./conftest$EXEEXT >conftest.txt1 > 2>conftest.txt2 > + if cmp conftest.txt1 conftest.txt2 >/dev/null; then > + gl_cv_func_perror_works=yes > + else > + gl_cv_func_perror_works=no > + fi > + rm -rf conftest.txt1 conftest.txt2], > + [gl_cv_func_perror_works=no], > + [dnl Guess no when cross-compiling. > + gl_cv_func_perror_works="guessing no"])]) > + if test "$gl_cv_func_perror_works" != yes; then > + REPLACE_PERROR=1 > + fi ;; > *) dnl The system's perror() probably inherits the bugs in the > dnl system's strerror_r(). Replace it. > REPLACE_PERROR=1 ;;
Sorry, but the indentation in this patch is not consistent: 2 vs. 3 spaces in the same case alternative. I'm fixing it like this. Probably the tendency to put all closing ])])]) parentheses and brackets on the end of the same line contributed to this mistake. I'm in favour of aligning corresponding brackets vertically if it can avoid misindentation or - worse - confusion about which is the corresponding opening bracket. 2011-10-22 Bruno Haible <br...@clisp.org> perror: Fix indentation. * m4/perror.m4 (gl_FUNC_PERROR): Fix indentation. *** m4/perror.m4.orig Sat Oct 22 14:20:29 2011 --- m4/perror.m4 Sat Oct 22 14:16:55 2011 *************** *** 1,4 **** ! # perror.m4 serial 4 dnl Copyright (C) 2008-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, --- 1,4 ---- ! # perror.m4 serial 5 dnl Copyright (C) 2008-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, *************** *** 46,57 **** rm -rf conftest.txt1 conftest.txt2], [gl_cv_func_perror_works=no], [dnl Guess no when cross-compiling. ! gl_cv_func_perror_works="guessing no"])]) ! if test "$gl_cv_func_perror_works" != yes; then ! REPLACE_PERROR=1 ! fi ;; ! *) dnl The system's perror() probably inherits the bugs in the ! dnl system's strerror_r(). Replace it. ! REPLACE_PERROR=1 ;; esac ]) --- 46,62 ---- rm -rf conftest.txt1 conftest.txt2], [gl_cv_func_perror_works=no], [dnl Guess no when cross-compiling. ! gl_cv_func_perror_works="guessing no" ! ]) ! ]) ! if test "$gl_cv_func_perror_works" != yes; then ! REPLACE_PERROR=1 ! fi ! ;; ! *) ! dnl The system's perror() probably inherits the bugs in the ! dnl system's strerror_r(). Replace it. ! REPLACE_PERROR=1 ! ;; esac ]) -- In memoriam Nunilo and Alodia <http://en.wikipedia.org/wiki/Nunilo_and_Alodia>