diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-09-18 20:59:46 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-09-18 20:59:46 (GMT) |
commit | 0e70e81133c25274fe2dd2309556b41357dd759b (patch) | |
tree | 9a680b36788ee1ad4e7ecc5ccfeb4494db9fdc72 /gl/m4/getdelim.m4 | |
parent | ce355c80cf6054bfa5e1dcf81f9e2183ef963ee1 (diff) | |
parent | 2ddc75e69db5a3dd379c896d8420c9af20ec1cee (diff) | |
download | monitoring-plugins-0e70e81133c25274fe2dd2309556b41357dd759b.tar.gz |
Merge branch 'master' into mysql_detect_mysqldumprefs/pull/1718/head
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 | ]) | ||