diff options
author | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-03-09 10:03:48 (GMT) |
---|---|---|
committer | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-03-09 10:03:48 (GMT) |
commit | d0edb72a0c9bc1a28197ab4566928f7ee63a6d43 (patch) | |
tree | 6d524fb16d2dd1aa9f2d98529ef1de7a39f52700 /gl/m4/fpurge.m4 | |
parent | 9fdc82f0543c6e2891c7079f70297f92e8ef4619 (diff) | |
parent | 269718094177fb8a7e3d3005d1310495009fe8c4 (diff) | |
download | monitoring-plugins-d0edb72a0c9bc1a28197ab4566928f7ee63a6d43.tar.gz |
Merge branch 'master' into RincewindsHat-patch-1
Diffstat (limited to 'gl/m4/fpurge.m4')
-rw-r--r-- | gl/m4/fpurge.m4 | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4 new file mode 100644 index 0000000..b365409 --- /dev/null +++ b/gl/m4/fpurge.m4 | |||
@@ -0,0 +1,73 @@ | |||
1 | # fpurge.m4 serial 12 | ||
2 | dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | AC_DEFUN([gl_FUNC_FPURGE], | ||
8 | [ | ||
9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | ||
10 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
11 | AC_CHECK_HEADERS_ONCE([stdio_ext.h]) | ||
12 | AC_CHECK_FUNCS_ONCE([fpurge]) | ||
13 | AC_CHECK_FUNCS_ONCE([__fpurge]) | ||
14 | AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]]) | ||
15 | if test "x$ac_cv_func_fpurge" = xyes; then | ||
16 | HAVE_FPURGE=1 | ||
17 | # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune. | ||
18 | AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works], | ||
19 | [AC_RUN_IFELSE( | ||
20 | [AC_LANG_PROGRAM( | ||
21 | [[#include <stdio.h> | ||
22 | ]], | ||
23 | [[FILE *f = fopen ("conftest.txt", "w+"); | ||
24 | if (!f) | ||
25 | return 1; | ||
26 | if (fputc ('a', f) != 'a') | ||
27 | { fclose (f); return 2; } | ||
28 | rewind (f); | ||
29 | if (fgetc (f) != 'a') | ||
30 | { fclose (f); return 3; } | ||
31 | if (fgetc (f) != EOF) | ||
32 | { fclose (f); return 4; } | ||
33 | if (fpurge (f) != 0) | ||
34 | { fclose (f); return 5; } | ||
35 | if (putc ('b', f) != 'b') | ||
36 | { fclose (f); return 6; } | ||
37 | if (fclose (f) != 0) | ||
38 | return 7; | ||
39 | if ((f = fopen ("conftest.txt", "r")) == NULL) | ||
40 | return 8; | ||
41 | if (fgetc (f) != 'a') | ||
42 | { fclose (f); return 9; } | ||
43 | if (fgetc (f) != 'b') | ||
44 | { fclose (f); return 10; } | ||
45 | if (fgetc (f) != EOF) | ||
46 | { fclose (f); return 11; } | ||
47 | if (fclose (f) != 0) | ||
48 | return 12; | ||
49 | if (remove ("conftest.txt") != 0) | ||
50 | return 13; | ||
51 | return 0; | ||
52 | ]])], | ||
53 | [gl_cv_func_fpurge_works=yes], | ||
54 | [gl_cv_func_fpurge_works=no], | ||
55 | [case "$host_os" in | ||
56 | # Guess yes on musl systems. | ||
57 | *-musl*) gl_cv_func_fpurge_works="guessing yes" ;; | ||
58 | # Otherwise obey --enable-cross-guesses. | ||
59 | *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;; | ||
60 | esac | ||
61 | ]) | ||
62 | ]) | ||
63 | case "$gl_cv_func_fpurge_works" in | ||
64 | *yes) ;; | ||
65 | *) REPLACE_FPURGE=1 ;; | ||
66 | esac | ||
67 | else | ||
68 | HAVE_FPURGE=0 | ||
69 | fi | ||
70 | if test "x$ac_cv_have_decl_fpurge" = xno; then | ||
71 | HAVE_DECL_FPURGE=0 | ||
72 | fi | ||
73 | ]) | ||