diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-07 21:11:46 -0400 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-12 21:26:35 -0400 |
commit | 74da141e618ef99959d509cb2e7be35a348a39db (patch) | |
tree | 88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/m4/regex.m4 | |
parent | c63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff) | |
download | monitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz |
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/m4/regex.m4')
-rw-r--r-- | gl/m4/regex.m4 | 275 |
1 files changed, 142 insertions, 133 deletions
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4 index aef53d29..95784e4b 100644 --- a/gl/m4/regex.m4 +++ b/gl/m4/regex.m4 | |||
@@ -1,7 +1,7 @@ | |||
1 | # serial 54 | 1 | # serial 56 |
2 | 2 | ||
3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, | 3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, |
4 | # 2006, 2007, 2008, 2009 Free Software Foundation, Inc. | 4 | # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
5 | # | 5 | # |
6 | # This file is free software; the Free Software Foundation | 6 | # This file is free software; the Free Software Foundation |
7 | # gives unlimited permission to copy and/or distribute it, | 7 | # gives unlimited permission to copy and/or distribute it, |
@@ -18,146 +18,154 @@ AC_DEFUN([gl_REGEX], | |||
18 | 18 | ||
19 | AC_ARG_WITH([included-regex], | 19 | AC_ARG_WITH([included-regex], |
20 | [AS_HELP_STRING([--without-included-regex], | 20 | [AS_HELP_STRING([--without-included-regex], |
21 | [don't compile regex; this is the default on systems | 21 | [don't compile regex; this is the default on systems |
22 | with recent-enough versions of the GNU C Library | 22 | with recent-enough versions of the GNU C Library |
23 | (use with caution on other systems).])]) | 23 | (use with caution on other systems).])]) |
24 | 24 | ||
25 | case $with_included_regex in #( | 25 | case $with_included_regex in #( |
26 | yes|no) ac_use_included_regex=$with_included_regex | 26 | yes|no) ac_use_included_regex=$with_included_regex |
27 | ;; | 27 | ;; |
28 | '') | 28 | '') |
29 | # If the system regex support is good enough that it passes the | 29 | # If the system regex support is good enough that it passes the |
30 | # following run test, then default to *not* using the included regex.c. | 30 | # following run test, then default to *not* using the included regex.c. |
31 | # If cross compiling, assume the test would fail and use the included | 31 | # If cross compiling, assume the test would fail and use the included |
32 | # regex.c. | 32 | # regex.c. |
33 | AC_CACHE_CHECK([for working re_compile_pattern], | 33 | AC_CACHE_CHECK([for working re_compile_pattern], |
34 | [gl_cv_func_re_compile_pattern_working], | 34 | [gl_cv_func_re_compile_pattern_working], |
35 | [AC_RUN_IFELSE( | 35 | [AC_RUN_IFELSE( |
36 | [AC_LANG_PROGRAM( | 36 | [AC_LANG_PROGRAM( |
37 | [AC_INCLUDES_DEFAULT[ | 37 | [AC_INCLUDES_DEFAULT[ |
38 | #if HAVE_LOCALE_H | 38 | #if HAVE_LOCALE_H |
39 | #include <locale.h> | 39 | #include <locale.h> |
40 | #endif | 40 | #endif |
41 | #include <limits.h> | 41 | #include <limits.h> |
42 | #include <regex.h> | 42 | #include <regex.h> |
43 | ]], | 43 | ]], |
44 | [[static struct re_pattern_buffer regex; | 44 | [[static struct re_pattern_buffer regex; |
45 | unsigned char folded_chars[UCHAR_MAX + 1]; | 45 | unsigned char folded_chars[UCHAR_MAX + 1]; |
46 | int i; | 46 | int i; |
47 | const char *s; | 47 | const char *s; |
48 | struct re_registers regs; | 48 | struct re_registers regs; |
49 | 49 | ||
50 | #if HAVE_LOCALE_H | 50 | #if HAVE_LOCALE_H |
51 | /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html | 51 | /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html |
52 | This test needs valgrind to catch the bug on Debian | 52 | This test needs valgrind to catch the bug on Debian |
53 | GNU/Linux 3.1 x86, but it might catch the bug better | 53 | GNU/Linux 3.1 x86, but it might catch the bug better |
54 | on other platforms and it shouldn't hurt to try the | 54 | on other platforms and it shouldn't hurt to try the |
55 | test here. */ | 55 | test here. */ |
56 | if (setlocale (LC_ALL, "en_US.UTF-8")) | 56 | if (setlocale (LC_ALL, "en_US.UTF-8")) |
57 | { | 57 | { |
58 | static char const pat[] = "insert into"; | 58 | static char const pat[] = "insert into"; |
59 | static char const data[] = | 59 | static char const data[] = |
60 | "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; | 60 | "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; |
61 | re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE | 61 | re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE |
62 | | RE_ICASE); | 62 | | RE_ICASE); |
63 | memset (®ex, 0, sizeof regex); | 63 | memset (®ex, 0, sizeof regex); |
64 | s = re_compile_pattern (pat, sizeof pat - 1, ®ex); | 64 | s = re_compile_pattern (pat, sizeof pat - 1, ®ex); |
65 | if (s) | 65 | if (s) |
66 | return 1; | 66 | return 1; |
67 | if (re_search (®ex, data, sizeof data - 1, | 67 | if (re_search (®ex, data, sizeof data - 1, |
68 | 0, sizeof data - 1, ®s) | 68 | 0, sizeof data - 1, ®s) |
69 | != -1) | 69 | != -1) |
70 | return 1; | 70 | return 1; |
71 | if (! setlocale (LC_ALL, "C")) | 71 | if (! setlocale (LC_ALL, "C")) |
72 | return 1; | 72 | return 1; |
73 | } | 73 | } |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | /* This test is from glibc bug 3957, reported by Andrew Mackey. */ | 76 | /* This test is from glibc bug 3957, reported by Andrew Mackey. */ |
77 | re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); | 77 | re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); |
78 | memset (®ex, 0, sizeof regex); | 78 | memset (®ex, 0, sizeof regex); |
79 | s = re_compile_pattern ("a[^x]b", 6, ®ex); | 79 | s = re_compile_pattern ("a[^x]b", 6, ®ex); |
80 | if (s) | 80 | if (s) |
81 | return 1; | 81 | return 1; |
82 | 82 | ||
83 | /* This should fail, but succeeds for glibc-2.5. */ | 83 | /* This should fail, but succeeds for glibc-2.5. */ |
84 | if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) | 84 | if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) |
85 | return 1; | 85 | return 1; |
86 | 86 | ||
87 | /* This regular expression is from Spencer ere test number 75 | 87 | /* This regular expression is from Spencer ere test number 75 |
88 | in grep-2.3. */ | 88 | in grep-2.3. */ |
89 | re_set_syntax (RE_SYNTAX_POSIX_EGREP); | 89 | re_set_syntax (RE_SYNTAX_POSIX_EGREP); |
90 | memset (®ex, 0, sizeof regex); | 90 | memset (®ex, 0, sizeof regex); |
91 | for (i = 0; i <= UCHAR_MAX; i++) | 91 | for (i = 0; i <= UCHAR_MAX; i++) |
92 | folded_chars[i] = i; | 92 | folded_chars[i] = i; |
93 | regex.translate = folded_chars; | 93 | regex.translate = folded_chars; |
94 | s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); | 94 | s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); |
95 | /* This should fail with _Invalid character class name_ error. */ | 95 | /* This should fail with _Invalid character class name_ error. */ |
96 | if (!s) | 96 | if (!s) |
97 | return 1; | 97 | return 1; |
98 | 98 | ||
99 | /* This should succeed, but does not for glibc-2.1.3. */ | 99 | /* Ensure that [b-a] is diagnosed as invalid, when |
100 | memset (®ex, 0, sizeof regex); | 100 | using RE_NO_EMPTY_RANGES. */ |
101 | s = re_compile_pattern ("{1", 2, ®ex); | 101 | re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES); |
102 | 102 | memset (®ex, 0, sizeof regex); | |
103 | if (s) | 103 | s = re_compile_pattern ("a[b-a]", 6, ®ex); |
104 | return 1; | 104 | if (s == 0) |
105 | 105 | return 1; | |
106 | /* The following example is derived from a problem report | 106 | |
107 | against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ | 107 | /* This should succeed, but does not for glibc-2.1.3. */ |
108 | memset (®ex, 0, sizeof regex); | 108 | memset (®ex, 0, sizeof regex); |
109 | s = re_compile_pattern ("[an\371]*n", 7, ®ex); | 109 | s = re_compile_pattern ("{1", 2, ®ex); |
110 | if (s) | 110 | |
111 | return 1; | 111 | if (s) |
112 | 112 | return 1; | |
113 | /* This should match, but does not for glibc-2.2.1. */ | 113 | |
114 | if (re_match (®ex, "an", 2, 0, ®s) != 2) | 114 | /* The following example is derived from a problem report |
115 | return 1; | 115 | against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ |
116 | 116 | memset (®ex, 0, sizeof regex); | |
117 | memset (®ex, 0, sizeof regex); | 117 | s = re_compile_pattern ("[an\371]*n", 7, ®ex); |
118 | s = re_compile_pattern ("x", 1, ®ex); | 118 | if (s) |
119 | if (s) | 119 | return 1; |
120 | return 1; | 120 | |
121 | 121 | /* This should match, but does not for glibc-2.2.1. */ | |
122 | /* glibc-2.2.93 does not work with a negative RANGE argument. */ | 122 | if (re_match (®ex, "an", 2, 0, ®s) != 2) |
123 | if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) | 123 | return 1; |
124 | return 1; | 124 | |
125 | 125 | memset (®ex, 0, sizeof regex); | |
126 | /* The version of regex.c in older versions of gnulib | 126 | s = re_compile_pattern ("x", 1, ®ex); |
127 | ignored RE_ICASE. Detect that problem too. */ | 127 | if (s) |
128 | re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); | 128 | return 1; |
129 | memset (®ex, 0, sizeof regex); | 129 | |
130 | s = re_compile_pattern ("x", 1, ®ex); | 130 | /* glibc-2.2.93 does not work with a negative RANGE argument. */ |
131 | if (s) | 131 | if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) |
132 | return 1; | 132 | return 1; |
133 | 133 | ||
134 | if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) | 134 | /* The version of regex.c in older versions of gnulib |
135 | return 1; | 135 | ignored RE_ICASE. Detect that problem too. */ |
136 | 136 | re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); | |
137 | /* Catch a bug reported by Vin Shelton in | 137 | memset (®ex, 0, sizeof regex); |
138 | http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html | 138 | s = re_compile_pattern ("x", 1, ®ex); |
139 | */ | 139 | if (s) |
140 | re_set_syntax (RE_SYNTAX_POSIX_BASIC | 140 | return 1; |
141 | & ~RE_CONTEXT_INVALID_DUP | 141 | |
142 | & ~RE_NO_EMPTY_RANGES); | 142 | if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) |
143 | memset (®ex, 0, sizeof regex); | 143 | return 1; |
144 | s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); | 144 | |
145 | if (s) | 145 | /* Catch a bug reported by Vin Shelton in |
146 | return 1; | 146 | http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html |
147 | 147 | */ | |
148 | /* REG_STARTEND was added to glibc on 2004-01-15. | 148 | re_set_syntax (RE_SYNTAX_POSIX_BASIC |
149 | Reject older versions. */ | 149 | & ~RE_CONTEXT_INVALID_DUP |
150 | if (! REG_STARTEND) | 150 | & ~RE_NO_EMPTY_RANGES); |
151 | return 1; | 151 | memset (®ex, 0, sizeof regex); |
152 | 152 | s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); | |
153 | /* Reject hosts whose regoff_t values are too narrow. | 153 | if (s) |
154 | These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t | 154 | return 1; |
155 | and 32-bit int. */ | 155 | |
156 | if (sizeof (regoff_t) < sizeof (ptrdiff_t) | 156 | /* REG_STARTEND was added to glibc on 2004-01-15. |
157 | || sizeof (regoff_t) < sizeof (ssize_t)) | 157 | Reject older versions. */ |
158 | return 1; | 158 | if (! REG_STARTEND) |
159 | 159 | return 1; | |
160 | return 0;]])], | 160 | |
161 | /* Reject hosts whose regoff_t values are too narrow. | ||
162 | These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t | ||
163 | and 32-bit int. */ | ||
164 | if (sizeof (regoff_t) < sizeof (ptrdiff_t) | ||
165 | || sizeof (regoff_t) < sizeof (ssize_t)) | ||
166 | return 1; | ||
167 | |||
168 | return 0;]])], | ||
161 | [gl_cv_func_re_compile_pattern_working=yes], | 169 | [gl_cv_func_re_compile_pattern_working=yes], |
162 | [gl_cv_func_re_compile_pattern_working=no], | 170 | [gl_cv_func_re_compile_pattern_working=no], |
163 | dnl When crosscompiling, assume it is not working. | 171 | dnl When crosscompiling, assume it is not working. |
@@ -213,6 +221,7 @@ AC_DEFUN([gl_REGEX], | |||
213 | AC_DEFUN([gl_PREREQ_REGEX], | 221 | AC_DEFUN([gl_PREREQ_REGEX], |
214 | [ | 222 | [ |
215 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | 223 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
224 | AC_REQUIRE([AC_C_INLINE]) | ||
216 | AC_REQUIRE([AC_C_RESTRICT]) | 225 | AC_REQUIRE([AC_C_RESTRICT]) |
217 | AC_REQUIRE([AC_TYPE_MBSTATE_T]) | 226 | AC_REQUIRE([AC_TYPE_MBSTATE_T]) |
218 | AC_CHECK_HEADERS([libintl.h]) | 227 | AC_CHECK_HEADERS([libintl.h]) |