X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=m4%2Fperror.m4;h=60568a7ad90a8836633535187b1264dff6d7aeb4;hb=516c9f591ad74f22f988fe4d6c7c7733c9b173b6;hp=350cd4203fa736cc32bc8fd2863e37ba6137a6a3;hpb=a2016c1de6e4884f6c8ed5cc498f3bf821c25ca4;p=debian%2Fgzip diff --git a/m4/perror.m4 b/m4/perror.m4 index 350cd42..60568a7 100644 --- a/m4/perror.m4 +++ b/m4/perror.m4 @@ -1,5 +1,5 @@ -# perror.m4 serial 1 -dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# perror.m4 serial 7 +dnl Copyright (C) 2008-2018 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. @@ -8,10 +8,62 @@ AC_DEFUN([gl_FUNC_PERROR], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_REQUIRE([gl_HEADER_ERRNO_H]) - if test -n "$ERRNO_H"; then + AC_REQUIRE([gl_FUNC_STRERROR_R]) + AC_REQUIRE([gl_FUNC_STRERROR_0]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + 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 . Replace it. + dnl to , or any fix for strerror(0). Replace it. REPLACE_PERROR=1 - AC_LIBOBJ([perror]) fi + case ${gl_cv_func_strerror_r_works-unset} in + unset|*yes) + AC_CACHE_CHECK([whether perror matches strerror], + [gl_cv_func_perror_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + #include + ]], + [[char *str = strerror (-1); + if (!getenv("CONFTEST_OUTPUT")) return 0; + if (!str) str = ""; + puts (str); + errno = -1; + perror (""); + return 0; + ]])], + [if CONFTEST_OUTPUT=1 ./conftest$EXEEXT >conftest.txt1 2>conftest.txt2 \ + && 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], + [case "$host_os" in + # Guess yes on native Windows. + mingw*) gl_cv_func_perror_works="guessing yes" ;; + # Otherwise guess no. + *) gl_cv_func_perror_works="guessing no" ;; + esac + ]) + ]) + case "$gl_cv_func_perror_works" in + *yes) ;; + *) REPLACE_PERROR=1 ;; + esac + ;; + *) + dnl The system's perror() probably inherits the bugs in the + dnl system's strerror_r(). Replace it. + REPLACE_PERROR=1 + ;; + esac ])