diff options
| author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2021-11-17 01:05:54 +0100 |
|---|---|---|
| committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-07-24 19:35:11 +0200 |
| commit | a405fc138596f552581d2011fd6de02d5c8186c4 (patch) | |
| tree | 4c084700b5cb5e9fcedf982a2d921bbc41d9935a /gl/m4/getdelim.m4 | |
| parent | 9f2a9ca3d72023ff9b5707d1872c54d65edc9017 (diff) | |
| download | monitoring-plugins-a405fc1.tar.gz | |
Sync with the latest Gnulib code (1a268176f)
Diffstat (limited to 'gl/m4/getdelim.m4')
| -rw-r--r-- | gl/m4/getdelim.m4 | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4 new file mode 100644 index 00000000..244a7319 --- /dev/null +++ b/gl/m4/getdelim.m4 | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | # getdelim.m4 serial 15 | ||
| 2 | |||
| 3 | dnl Copyright (C) 2005-2007, 2009-2021 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]) dnl for cross-compiles | ||
| 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 | [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data | ||
| 28 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | ||
| 29 | # include <stdio.h> | ||
| 30 | # include <stdlib.h> | ||
| 31 | # include <string.h> | ||
| 32 | int main () | ||
| 33 | { | ||
| 34 | FILE *in = fopen ("./conftest.data", "r"); | ||
| 35 | if (!in) | ||
| 36 | return 1; | ||
| 37 | { | ||
| 38 | /* Test result for a NULL buffer and a zero size. | ||
| 39 | Based on a test program from Karl Heuer. */ | ||
| 40 | char *line = NULL; | ||
| 41 | size_t siz = 0; | ||
| 42 | int len = getdelim (&line, &siz, '\n', in); | ||
| 43 | if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) | ||
| 44 | { free (line); fclose (in); return 2; } | ||
| 45 | free (line); | ||
| 46 | } | ||
| 47 | { | ||
| 48 | /* Test result for a NULL buffer and a non-zero size. | ||
| 49 | This crashes on FreeBSD 8.0. */ | ||
| 50 | char *line = NULL; | ||
| 51 | size_t siz = (size_t)(~0) / 4; | ||
| 52 | if (getdelim (&line, &siz, '\n', in) == -1) | ||
| 53 | { fclose (in); return 3; } | ||
| 54 | free (line); | ||
| 55 | } | ||
| 56 | fclose (in); | ||
| 57 | return 0; | ||
| 58 | } | ||
| 59 | ]])], | ||
| 60 | [gl_cv_func_working_getdelim=yes], | ||
| 61 | [gl_cv_func_working_getdelim=no], | ||
| 62 | [dnl We're cross compiling. | ||
| 63 | dnl Guess it works on glibc2 systems and musl systems. | ||
| 64 | AC_EGREP_CPP([Lucky GNU user], | ||
| 65 | [ | ||
| 66 | #include <features.h> | ||
| 67 | #ifdef __GNU_LIBRARY__ | ||
| 68 | #if (__GLIBC__ >= 2) && !defined __UCLIBC__ | ||
| 69 | Lucky GNU user | ||
| 70 | #endif | ||
| 71 | #endif | ||
| 72 | ], | ||
| 73 | [gl_cv_func_working_getdelim="guessing yes"], | ||
| 74 | [case "$host_os" in | ||
| 75 | *-musl*) gl_cv_func_working_getdelim="guessing yes" ;; | ||
| 76 | *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;; | ||
| 77 | esac | ||
| 78 | ]) | ||
| 79 | ]) | ||
| 80 | ]) | ||
| 81 | case "$gl_cv_func_working_getdelim" in | ||
| 82 | *yes) ;; | ||
| 83 | *) REPLACE_GETDELIM=1 ;; | ||
| 84 | esac | ||
| 85 | else | ||
| 86 | HAVE_GETDELIM=0 | ||
| 87 | fi | ||
| 88 | |||
| 89 | if test $ac_cv_have_decl_getdelim = no; then | ||
| 90 | HAVE_DECL_GETDELIM=0 | ||
| 91 | fi | ||
| 92 | ]) | ||
| 93 | |||
| 94 | # Prerequisites of lib/getdelim.c. | ||
| 95 | AC_DEFUN([gl_PREREQ_GETDELIM], | ||
| 96 | [ | ||
| 97 | AC_CHECK_FUNCS([flockfile funlockfile]) | ||
| 98 | AC_CHECK_DECLS([getc_unlocked]) | ||
| 99 | ]) | ||
