diff options
Diffstat (limited to 'gl/m4/strstr.m4')
-rw-r--r-- | gl/m4/strstr.m4 | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4 index c486bdb..7de203a 100644 --- a/gl/m4/strstr.m4 +++ b/gl/m4/strstr.m4 | |||
@@ -1,5 +1,5 @@ | |||
1 | # strstr.m4 serial 16 | 1 | # strstr.m4 serial 24 |
2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
@@ -7,30 +7,40 @@ dnl with or without modifications, as long as this notice is preserved. | |||
7 | dnl Check that strstr works. | 7 | dnl Check that strstr works. |
8 | AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], | 8 | AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], |
9 | [ | 9 | [ |
10 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | 10 | AC_REQUIRE([gl_STRING_H_DEFAULTS]) |
11 | AC_REQUIRE([gl_FUNC_MEMCHR]) | 11 | AC_REQUIRE([gl_FUNC_MEMCHR]) |
12 | if test "$gl_cv_func_memchr_works" != yes; then | 12 | if test $REPLACE_MEMCHR = 1; then |
13 | REPLACE_STRSTR=1 | 13 | REPLACE_STRSTR=1 |
14 | else | 14 | else |
15 | dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. | 15 | dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092 |
16 | dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637. | ||
16 | AC_CACHE_CHECK([whether strstr works], | 17 | AC_CACHE_CHECK([whether strstr works], |
17 | [gl_cv_func_strstr_works_always], | 18 | [gl_cv_func_strstr_works_always], |
18 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | 19 | [AC_RUN_IFELSE( |
19 | #include <string.h> /* for strstr */ | 20 | [AC_LANG_PROGRAM([[ |
21 | #include <string.h> /* for __GNU_LIBRARY__, strstr */ | ||
22 | #ifdef __GNU_LIBRARY__ | ||
23 | #include <features.h> | ||
24 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28 | ||
25 | Unlucky user | ||
26 | #endif | ||
27 | #endif | ||
20 | #define P "_EF_BF_BD" | 28 | #define P "_EF_BF_BD" |
21 | #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P | 29 | #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P |
22 | #define NEEDLE P P P P P | 30 | #define NEEDLE P P P P P |
23 | ]], [[return !!strstr (HAYSTACK, NEEDLE); | 31 | ]], |
24 | ]])], | 32 | [[return !!strstr (HAYSTACK, NEEDLE); |
25 | [gl_cv_func_strstr_works_always=yes], | 33 | ]])], |
26 | [gl_cv_func_strstr_works_always=no], | 34 | [gl_cv_func_strstr_works_always=yes], |
27 | [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not | 35 | [gl_cv_func_strstr_works_always=no], |
28 | dnl affected, since it uses different source code for strstr than | 36 | [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not |
29 | dnl glibc. | 37 | dnl affected, since it uses different source code for strstr than |
30 | dnl Assume that it works on all other platforms, even if it is not | 38 | dnl glibc. |
31 | dnl linear. | 39 | dnl Assume that it works on all other platforms, even if it is not |
32 | AC_EGREP_CPP([Lucky user], | 40 | dnl linear. |
33 | [ | 41 | AC_EGREP_CPP([Lucky user], |
42 | [ | ||
43 | #include <string.h> /* for __GNU_LIBRARY__ */ | ||
34 | #ifdef __GNU_LIBRARY__ | 44 | #ifdef __GNU_LIBRARY__ |
35 | #include <features.h> | 45 | #include <features.h> |
36 | #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ | 46 | #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ |
@@ -45,10 +55,10 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], | |||
45 | #else | 55 | #else |
46 | Lucky user | 56 | Lucky user |
47 | #endif | 57 | #endif |
48 | ], | 58 | ], |
49 | [gl_cv_func_strstr_works_always="guessing yes"], | 59 | [gl_cv_func_strstr_works_always="guessing yes"], |
50 | [gl_cv_func_strstr_works_always="guessing no"]) | 60 | [gl_cv_func_strstr_works_always="$gl_cross_guess_normal"]) |
51 | ]) | 61 | ]) |
52 | ]) | 62 | ]) |
53 | case "$gl_cv_func_strstr_works_always" in | 63 | case "$gl_cv_func_strstr_works_always" in |
54 | *yes) ;; | 64 | *yes) ;; |
@@ -67,11 +77,17 @@ AC_DEFUN([gl_FUNC_STRSTR], | |||
67 | AC_CACHE_CHECK([whether strstr works in linear time], | 77 | AC_CACHE_CHECK([whether strstr works in linear time], |
68 | [gl_cv_func_strstr_linear], | 78 | [gl_cv_func_strstr_linear], |
69 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | 79 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
80 | #ifdef __MVS__ | ||
81 | /* z/OS does not deliver signals while strstr() is running (thanks to | ||
82 | restrictions on its LE runtime), which prevents us from limiting the | ||
83 | running time of this test. */ | ||
84 | # error "This test does not work properly on z/OS" | ||
85 | #endif | ||
70 | #include <signal.h> /* for signal */ | 86 | #include <signal.h> /* for signal */ |
71 | #include <string.h> /* for strstr */ | 87 | #include <string.h> /* for strstr */ |
72 | #include <stdlib.h> /* for malloc */ | 88 | #include <stdlib.h> /* for malloc */ |
73 | #include <unistd.h> /* for alarm */ | 89 | #include <unistd.h> /* for alarm */ |
74 | static void quit (int sig) { exit (sig + 128); } | 90 | static void quit (int sig) { _exit (sig + 128); } |
75 | ]], [[ | 91 | ]], [[ |
76 | int result = 0; | 92 | int result = 0; |
77 | size_t m = 1000000; | 93 | size_t m = 1000000; |
@@ -93,6 +109,9 @@ static void quit (int sig) { exit (sig + 128); } | |||
93 | if (!strstr (haystack, needle)) | 109 | if (!strstr (haystack, needle)) |
94 | result |= 1; | 110 | result |= 1; |
95 | } | 111 | } |
112 | /* Free allocated memory, in case some sanitizer is watching. */ | ||
113 | free (haystack); | ||
114 | free (needle); | ||
96 | return result; | 115 | return result; |
97 | ]])], | 116 | ]])], |
98 | [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no], | 117 | [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no], |
@@ -117,7 +136,7 @@ static void quit (int sig) { exit (sig + 128); } | |||
117 | #endif | 136 | #endif |
118 | ], | 137 | ], |
119 | [gl_cv_func_strstr_linear="guessing yes"], | 138 | [gl_cv_func_strstr_linear="guessing yes"], |
120 | [gl_cv_func_strstr_linear="guessing no"]) | 139 | [gl_cv_func_strstr_linear="$gl_cross_guess_normal"]) |
121 | ]) | 140 | ]) |
122 | ]) | 141 | ]) |
123 | case "$gl_cv_func_strstr_linear" in | 142 | case "$gl_cv_func_strstr_linear" in |