summaryrefslogtreecommitdiffstats
path: root/gl/m4/fpurge.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/fpurge.m4')
-rw-r--r--gl/m4/fpurge.m494
1 files changed, 47 insertions, 47 deletions
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
index a77f5b96..408a2579 100644
--- a/gl/m4/fpurge.m4
+++ b/gl/m4/fpurge.m4
@@ -1,65 +1,65 @@
1# fpurge.m4 1# fpurge.m4
2# serial 14 2# serial 16
3dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. 3dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8AC_DEFUN([gl_FUNC_FPURGE], 9AC_DEFUN([gl_FUNC_FPURGE],
9[ 10[
10 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_CHECK_HEADERS_ONCE([stdio_ext.h]) 12 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
13 AC_CHECK_FUNCS_ONCE([fpurge]) 13 AC_CHECK_FUNCS_ONCE([fpurge])
14 gl_CHECK_FUNCS_ANDROID([__fpurge], [[#include <stdio_ext.h>]]) 14 gl_CHECK_FUNCS_ANDROID([__fpurge], [[#include <stdio_ext.h>]])
15 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]]) 15 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
16 if test "x$ac_cv_func_fpurge" = xyes; then 16 if test $ac_cv_func_fpurge = yes; then
17 HAVE_FPURGE=1 17 HAVE_FPURGE=1
18 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune. 18 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune.
19 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works], 19 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
20 [AC_RUN_IFELSE( 20 [if test $ac_cv_have_decl_fpurge = yes; then
21 [AC_LANG_PROGRAM( 21 AC_RUN_IFELSE(
22 [[#include <stdio.h> 22 [AC_LANG_PROGRAM(
23]], 23 [[#include <stdio.h>
24 [[FILE *f = fopen ("conftest.txt", "w+"); 24 ]],
25 if (!f) 25 [[FILE *f = fopen ("conftest.txt", "w+");
26 return 1; 26 if (!f)
27 if (fputc ('a', f) != 'a') 27 return 1;
28 { fclose (f); return 2; } 28 if (fputc ('a', f) != 'a')
29 rewind (f); 29 { fclose (f); return 2; }
30 if (fgetc (f) != 'a') 30 rewind (f);
31 { fclose (f); return 3; } 31 if (fgetc (f) != 'a')
32 if (fgetc (f) != EOF) 32 { fclose (f); return 3; }
33 { fclose (f); return 4; } 33 if (fgetc (f) != EOF)
34 if (fpurge (f) != 0) 34 { fclose (f); return 4; }
35 { fclose (f); return 5; } 35 if (fpurge (f) != 0)
36 if (putc ('b', f) != 'b') 36 { fclose (f); return 5; }
37 { fclose (f); return 6; } 37 if (putc ('b', f) != 'b')
38 if (fclose (f) != 0) 38 { fclose (f); return 6; }
39 return 7; 39 if (fclose (f) != 0)
40 if ((f = fopen ("conftest.txt", "r")) == NULL) 40 return 7;
41 return 8; 41 if ((f = fopen ("conftest.txt", "r")) == NULL)
42 if (fgetc (f) != 'a') 42 return 8;
43 { fclose (f); return 9; } 43 if (fgetc (f) != 'a')
44 if (fgetc (f) != 'b') 44 { fclose (f); return 9; }
45 { fclose (f); return 10; } 45 if (fgetc (f) != 'b')
46 if (fgetc (f) != EOF) 46 { fclose (f); return 10; }
47 { fclose (f); return 11; } 47 if (fgetc (f) != EOF)
48 if (fclose (f) != 0) 48 { fclose (f); return 11; }
49 return 12; 49 if (fclose (f) != 0)
50 if (remove ("conftest.txt") != 0) 50 return 12;
51 return 13; 51 if (remove ("conftest.txt") != 0)
52 return 0; 52 return 13;
53 ]])], 53 return 0;
54 [gl_cv_func_fpurge_works=yes], 54 ]])],
55 [gl_cv_func_fpurge_works=no], 55 [gl_cv_func_fpurge_works=yes],
56 [case "$host_os" in 56 [gl_cv_func_fpurge_works=no],
57 # Guess yes on musl systems. 57 [# Obey --enable-cross-guesses.
58 *-musl* | midipix*) gl_cv_func_fpurge_works="guessing yes" ;; 58 gl_cv_func_fpurge_works="$gl_cross_guess_normal"
59 # Otherwise obey --enable-cross-guesses. 59 ])
60 *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;; 60 else
61 esac 61 gl_cv_func_fpurge_works=no
62 ]) 62 fi
63 ]) 63 ])
64 case "$gl_cv_func_fpurge_works" in 64 case "$gl_cv_func_fpurge_works" in
65 *yes) ;; 65 *yes) ;;