diff options
author | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 23:49:18 +0100 |
---|---|---|
committer | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 23:49:18 +0100 |
commit | a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch) | |
tree | 8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/m4/getdelim.m4 | |
parent | ca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff) | |
parent | c07206f2ccc2356aa74bc6813a94c2190017d44e (diff) | |
download | monitoring-plugins-a0d4277.tar.gz |
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
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 00000000..9aaed202 --- /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 | ]) | ||