]> Savannah Git Hosting - gnulib.git/commitdiff
fpurge: Improve configure test.
authorBruno Haible <bruno@clisp.org>
Tue, 26 Nov 2024 08:38:42 +0000 (09:38 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 1 Dec 2024 06:52:32 +0000 (07:52 +0100)
Reported by Eli Schwartz <eschwartz@gentoo.org>.

* m4/fpurge.m4 (gl_FUNC_FPURGE): If fpurge is not declared, don't test
whether it works. Remove now-redundant cross-compilation guess.

ChangeLog
m4/fpurge.m4

index a8bc52a1f84b7c271c5302afb524ef21a13390c1..ff86bb57e8f8fa2a58a3f42b508dc336c42ceeec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-11-26  Bruno Haible  <bruno@clisp.org>
+
+       fpurge: Improve configure test.
+       Reported by Eli Schwartz <eschwartz@gentoo.org>.
+       * m4/fpurge.m4 (gl_FUNC_FPURGE): If fpurge is not declared, don't test
+       whether it works. Remove now-redundant cross-compilation guess.
+
 2024-11-24  Bruno Haible  <bruno@clisp.org>
 
        gettext-h: Fix compilation error when pgettext is used.
index a77f5b965c34887cc3f1dbb77b5d2f43fc07b840..2af2fd110883fcf5e5a7251637c83dc61665ca31 100644 (file)
@@ -1,5 +1,5 @@
 # fpurge.m4
-# serial 14
+# serial 16
 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,58 +8,57 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_FPURGE],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([fpurge])
   gl_CHECK_FUNCS_ANDROID([__fpurge], [[#include <stdio_ext.h>]])
   AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
-  if test "x$ac_cv_func_fpurge" = xyes; then
+  if test $ac_cv_func_fpurge = yes; then
     HAVE_FPURGE=1
     # Detect BSD bug.  Only cygwin 1.7 and musl are known to be immune.
     AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
-      [AC_RUN_IFELSE(
-         [AC_LANG_PROGRAM(
-            [[#include <stdio.h>
-]],
-            [[FILE *f = fopen ("conftest.txt", "w+");
-              if (!f)
-                return 1;
-              if (fputc ('a', f) != 'a')
-                { fclose (f); return 2; }
-              rewind (f);
-              if (fgetc (f) != 'a')
-                { fclose (f); return 3; }
-              if (fgetc (f) != EOF)
-                { fclose (f); return 4; }
-              if (fpurge (f) != 0)
-                { fclose (f); return 5; }
-              if (putc ('b', f) != 'b')
-                { fclose (f); return 6; }
-              if (fclose (f) != 0)
-                return 7;
-              if ((f = fopen ("conftest.txt", "r")) == NULL)
-                return 8;
-              if (fgetc (f) != 'a')
-                { fclose (f); return 9; }
-              if (fgetc (f) != 'b')
-                { fclose (f); return 10; }
-              if (fgetc (f) != EOF)
-                { fclose (f); return 11; }
-              if (fclose (f) != 0)
-                return 12;
-              if (remove ("conftest.txt") != 0)
-                return 13;
-              return 0;
-            ]])],
-         [gl_cv_func_fpurge_works=yes],
-         [gl_cv_func_fpurge_works=no],
-         [case "$host_os" in
-                                # Guess yes on musl systems.
-            *-musl* | midipix*) gl_cv_func_fpurge_works="guessing yes" ;;
-                                # Otherwise obey --enable-cross-guesses.
-            *)                  gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;;
-          esac
-         ])
+      [if test $ac_cv_have_decl_fpurge = yes; then
+         AC_RUN_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <stdio.h>
+              ]],
+              [[FILE *f = fopen ("conftest.txt", "w+");
+                if (!f)
+                  return 1;
+                if (fputc ('a', f) != 'a')
+                  { fclose (f); return 2; }
+                rewind (f);
+                if (fgetc (f) != 'a')
+                  { fclose (f); return 3; }
+                if (fgetc (f) != EOF)
+                  { fclose (f); return 4; }
+                if (fpurge (f) != 0)
+                  { fclose (f); return 5; }
+                if (putc ('b', f) != 'b')
+                  { fclose (f); return 6; }
+                if (fclose (f) != 0)
+                  return 7;
+                if ((f = fopen ("conftest.txt", "r")) == NULL)
+                  return 8;
+                if (fgetc (f) != 'a')
+                  { fclose (f); return 9; }
+                if (fgetc (f) != 'b')
+                  { fclose (f); return 10; }
+                if (fgetc (f) != EOF)
+                  { fclose (f); return 11; }
+                if (fclose (f) != 0)
+                  return 12;
+                if (remove ("conftest.txt") != 0)
+                  return 13;
+                return 0;
+              ]])],
+           [gl_cv_func_fpurge_works=yes],
+           [gl_cv_func_fpurge_works=no],
+           [# Obey --enable-cross-guesses.
+            gl_cv_func_fpurge_works="$gl_cross_guess_normal"
+           ])
+       else
+         gl_cv_func_fpurge_works=no
+       fi
       ])
     case "$gl_cv_func_fpurge_works" in
       *yes) ;;