diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-03-10 10:33:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 10:33:25 (GMT) |
commit | 5077120a251980b4fafed61b4aa8fa5730a85443 (patch) | |
tree | 8500b8f5dbe774b399cfdc79f5665ba88ef7f255 /gl/m4/getdelim.m4 | |
parent | a3de84594104ac87a91e200d569fb57edacca928 (diff) | |
parent | 269718094177fb8a7e3d3005d1310495009fe8c4 (diff) | |
download | monitoring-plugins-5077120a251980b4fafed61b4aa8fa5730a85443.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'gl/m4/getdelim.m4')
-rw-r--r-- | gl/m4/getdelim.m4 | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4 new file mode 100644 index 0000000..9aaed20 --- /dev/null +++ b/gl/m4/getdelim.m4 | |||
@@ -0,0 +1,111 @@ | |||
1 | # getdelim.m4 serial 16 | ||
2 | |||
3 | dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. | ||
4 | dnl | ||
5 | dnl This file is free software; the Free Software Foundation | ||
6 | dnl gives unlimited permission to copy and/or distribute it, | ||
7 | dnl with or without modifications, as long as this notice is preserved. | ||
8 | |||
9 | AC_PREREQ([2.59]) | ||
10 | |||
11 | AC_DEFUN([gl_FUNC_GETDELIM], | ||
12 | [ | ||
13 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) | ||
14 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
15 | |||
16 | dnl Persuade glibc <stdio.h> to declare getdelim(). | ||
17 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
18 | |||
19 | AC_CHECK_DECLS_ONCE([getdelim]) | ||
20 | |||
21 | AC_CHECK_FUNCS_ONCE([getdelim]) | ||
22 | if test $ac_cv_func_getdelim = yes; then | ||
23 | HAVE_GETDELIM=1 | ||
24 | dnl Found it in some library. Verify that it works. | ||
25 | AC_CACHE_CHECK([for working getdelim function], | ||
26 | [gl_cv_func_working_getdelim], | ||
27 | [case "$host_os" in | ||
28 | darwin*) | ||
29 | dnl On macOS 10.13, valgrind detected an out-of-bounds read during | ||
30 | dnl the GNU sed test suite: | ||
31 | dnl Invalid read of size 16 | ||
32 | dnl at 0x100EE6A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib) | ||
33 | dnl by 0x100B7B0BD: getdelim (in /usr/lib/system/libsystem_c.dylib) | ||
34 | dnl by 0x10000B0BE: ck_getdelim (utils.c:254) | ||
35 | gl_cv_func_working_getdelim=no ;; | ||
36 | *) | ||
37 | echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data | ||
38 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | ||
39 | # include <stdio.h> | ||
40 | # include <stdlib.h> | ||
41 | # include <string.h> | ||
42 | int main () | ||
43 | { | ||
44 | FILE *in = fopen ("./conftest.data", "r"); | ||
45 | if (!in) | ||
46 | return 1; | ||
47 | { | ||
48 | /* Test result for a NULL buffer and a zero size. | ||
49 | Based on a test program from Karl Heuer. */ | ||
50 | char *line = NULL; | ||
51 | size_t siz = 0; | ||
52 | int len = getdelim (&line, &siz, '\n', in); | ||
53 | if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) | ||
54 | { free (line); fclose (in); return 2; } | ||
55 | free (line); | ||
56 | } | ||
57 | { | ||
58 | /* Test result for a NULL buffer and a non-zero size. | ||
59 | This crashes on FreeBSD 8.0. */ | ||
60 | char *line = NULL; | ||
61 | size_t siz = (size_t)(~0) / 4; | ||
62 | if (getdelim (&line, &siz, '\n', in) == -1) | ||
63 | { fclose (in); return 3; } | ||
64 | free (line); | ||
65 | } | ||
66 | fclose (in); | ||
67 | return 0; | ||
68 | } | ||
69 | ]])], | ||
70 | [gl_cv_func_working_getdelim=yes], | ||
71 | [gl_cv_func_working_getdelim=no], | ||
72 | [dnl We're cross compiling. | ||
73 | dnl Guess it works on glibc2 systems and musl systems. | ||
74 | AC_EGREP_CPP([Lucky GNU user], | ||
75 | [ | ||
76 | #include <features.h> | ||
77 | #ifdef __GNU_LIBRARY__ | ||
78 | #if (__GLIBC__ >= 2) && !defined __UCLIBC__ | ||
79 | Lucky GNU user | ||
80 | #endif | ||
81 | #endif | ||
82 | ], | ||
83 | [gl_cv_func_working_getdelim="guessing yes"], | ||
84 | [case "$host_os" in | ||
85 | *-musl*) gl_cv_func_working_getdelim="guessing yes" ;; | ||
86 | *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;; | ||
87 | esac | ||
88 | ]) | ||
89 | ]) | ||
90 | ;; | ||
91 | esac | ||
92 | ]) | ||
93 | case "$gl_cv_func_working_getdelim" in | ||
94 | *yes) ;; | ||
95 | *) REPLACE_GETDELIM=1 ;; | ||
96 | esac | ||
97 | else | ||
98 | HAVE_GETDELIM=0 | ||
99 | fi | ||
100 | |||
101 | if test $ac_cv_have_decl_getdelim = no; then | ||
102 | HAVE_DECL_GETDELIM=0 | ||
103 | fi | ||
104 | ]) | ||
105 | |||
106 | # Prerequisites of lib/getdelim.c. | ||
107 | AC_DEFUN([gl_PREREQ_GETDELIM], | ||
108 | [ | ||
109 | AC_CHECK_FUNCS([flockfile funlockfile]) | ||
110 | AC_CHECK_DECLS([getc_unlocked]) | ||
111 | ]) | ||