diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 11:07:18 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 11:07:18 +0000 |
commit | bd7029a99b0c2974265c6665638ef14a052f42ab (patch) | |
tree | f5661ba73366d81ef6e91f889ea7fec5ebe07b6b /gl/m4/regex.m4 | |
parent | f99612320d6eda67644c07be04bb21aa4d7789db (diff) | |
download | monitoring-plugins-bd7029a99b0c2974265c6665638ef14a052f42ab.tar.gz |
Sync to latest Gnulib
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1925 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl/m4/regex.m4')
-rw-r--r-- | gl/m4/regex.m4 | 80 |
1 files changed, 52 insertions, 28 deletions
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4 index 25da645e..7da6efed 100644 --- a/gl/m4/regex.m4 +++ b/gl/m4/regex.m4 | |||
@@ -1,4 +1,4 @@ | |||
1 | #serial 42 | 1 | #serial 48 |
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, |
4 | # 2006, 2007 Free Software Foundation, Inc. | 4 | # 2006, 2007 Free Software Foundation, Inc. |
@@ -18,9 +18,12 @@ AC_DEFUN([gl_REGEX], | |||
18 | 18 | ||
19 | AC_ARG_WITH([included-regex], | 19 | AC_ARG_WITH([included-regex], |
20 | [AC_HELP_STRING([--without-included-regex], | 20 | [AC_HELP_STRING([--without-included-regex], |
21 | [don't compile regex; this is the default on | 21 | [don't compile regex; this is the default on 32-bit |
22 | systems with recent-enough versions of the GNU C | 22 | systems with recent-enough versions of the GNU C |
23 | Library (use with caution on other systems)])]) | 23 | Library (use with caution on other systems). |
24 | On systems with 64-bit ptrdiff_t and 32-bit int, | ||
25 | --with-included-regex is the default, in case | ||
26 | regex functions operate on very long strings (>2GB)])]) | ||
24 | 27 | ||
25 | case $with_included_regex in #( | 28 | case $with_included_regex in #( |
26 | yes|no) ac_use_included_regex=$with_included_regex | 29 | yes|no) ac_use_included_regex=$with_included_regex |
@@ -29,8 +32,7 @@ AC_DEFUN([gl_REGEX], | |||
29 | # If the system regex support is good enough that it passes the | 32 | # 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. | 33 | # 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 | 34 | # If cross compiling, assume the test would fail and use the included |
32 | # regex.c. The first failing regular expression is from `Spencer ere | 35 | # regex.c. |
33 | # test #75' in grep-2.3. | ||
34 | AC_CACHE_CHECK([for working re_compile_pattern], | 36 | AC_CACHE_CHECK([for working re_compile_pattern], |
35 | [gl_cv_func_re_compile_pattern_working], | 37 | [gl_cv_func_re_compile_pattern_working], |
36 | [AC_RUN_IFELSE( | 38 | [AC_RUN_IFELSE( |
@@ -74,68 +76,91 @@ AC_DEFUN([gl_REGEX], | |||
74 | } | 76 | } |
75 | #endif | 77 | #endif |
76 | 78 | ||
79 | /* This test is from glibc bug 3957, reported by Andrew Mackey. */ | ||
80 | re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); | ||
81 | memset (®ex, 0, sizeof regex); | ||
82 | s = re_compile_pattern ("a[^x]b", 6, ®ex); | ||
83 | if (s) | ||
84 | return 1; | ||
85 | |||
86 | /* This should fail, but succeeds for glibc-2.5. */ | ||
87 | if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) | ||
88 | return 1; | ||
89 | |||
90 | /* This regular expression is from Spencer ere test number 75 | ||
91 | in grep-2.3. */ | ||
77 | re_set_syntax (RE_SYNTAX_POSIX_EGREP); | 92 | re_set_syntax (RE_SYNTAX_POSIX_EGREP); |
78 | memset (®ex, 0, sizeof (regex)); | 93 | memset (®ex, 0, sizeof regex); |
79 | for (i = 0; i <= UCHAR_MAX; i++) | 94 | for (i = 0; i <= UCHAR_MAX; i++) |
80 | folded_chars[i] = i; | 95 | folded_chars[i] = i; |
81 | regex.translate = folded_chars; | 96 | regex.translate = folded_chars; |
82 | s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); | 97 | s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, ®ex); |
83 | /* This should fail with _Invalid character class name_ error. */ | 98 | /* This should fail with _Invalid character class name_ error. */ |
84 | if (!s) | 99 | if (!s) |
85 | exit (1); | 100 | return 1; |
86 | 101 | ||
87 | /* This should succeed, but does not for e.g. glibc-2.1.3. */ | 102 | /* This should succeed, but does not for glibc-2.1.3. */ |
88 | memset (®ex, 0, sizeof (regex)); | 103 | memset (®ex, 0, sizeof regex); |
89 | s = re_compile_pattern ("{1", 2, ®ex); | 104 | s = re_compile_pattern ("{1", 2, ®ex); |
90 | 105 | ||
91 | if (s) | 106 | if (s) |
92 | exit (1); | 107 | return 1; |
93 | 108 | ||
94 | /* The following example is derived from a problem report | 109 | /* The following example is derived from a problem report |
95 | against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ | 110 | against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ |
96 | memset (®ex, 0, sizeof (regex)); | 111 | memset (®ex, 0, sizeof regex); |
97 | s = re_compile_pattern ("[an\371]*n", 7, ®ex); | 112 | s = re_compile_pattern ("[an\371]*n", 7, ®ex); |
98 | if (s) | 113 | if (s) |
99 | exit (1); | 114 | return 1; |
100 | 115 | ||
101 | /* This should match, but does not for e.g. glibc-2.2.1. */ | 116 | /* This should match, but does not for glibc-2.2.1. */ |
102 | if (re_match (®ex, "an", 2, 0, ®s) != 2) | 117 | if (re_match (®ex, "an", 2, 0, ®s) != 2) |
103 | exit (1); | 118 | return 1; |
104 | 119 | ||
105 | memset (®ex, 0, sizeof (regex)); | 120 | memset (®ex, 0, sizeof regex); |
106 | s = re_compile_pattern ("x", 1, ®ex); | 121 | s = re_compile_pattern ("x", 1, ®ex); |
107 | if (s) | 122 | if (s) |
108 | exit (1); | 123 | return 1; |
109 | 124 | ||
110 | /* The version of regex.c in e.g. GNU libc-2.2.93 did not | 125 | /* glibc-2.2.93 does not work with a negative RANGE argument. */ |
111 | work with a negative RANGE argument. */ | ||
112 | if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) | 126 | if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) |
113 | exit (1); | 127 | return 1; |
114 | 128 | ||
115 | /* The version of regex.c in older versions of gnulib | 129 | /* The version of regex.c in older versions of gnulib |
116 | ignored RE_ICASE. Detect that problem too. */ | 130 | ignored RE_ICASE. Detect that problem too. */ |
117 | memset (®ex, 0, sizeof (regex)); | ||
118 | re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); | 131 | re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); |
132 | memset (®ex, 0, sizeof regex); | ||
119 | s = re_compile_pattern ("x", 1, ®ex); | 133 | s = re_compile_pattern ("x", 1, ®ex); |
120 | if (s) | 134 | if (s) |
121 | exit (1); | 135 | return 1; |
122 | 136 | ||
123 | if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) | 137 | if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) |
124 | exit (1); | 138 | return 1; |
139 | |||
140 | /* Catch a bug reported by Vin Shelton in | ||
141 | http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html | ||
142 | */ | ||
143 | re_set_syntax (RE_SYNTAX_POSIX_BASIC | ||
144 | & ~RE_CONTEXT_INVALID_DUP | ||
145 | & ~RE_NO_EMPTY_RANGES); | ||
146 | memset (®ex, 0, sizeof regex); | ||
147 | s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); | ||
148 | if (s) | ||
149 | return 1; | ||
125 | 150 | ||
126 | /* REG_STARTEND was added to glibc on 2004-01-15. | 151 | /* REG_STARTEND was added to glibc on 2004-01-15. |
127 | Reject older versions. */ | 152 | Reject older versions. */ |
128 | if (! REG_STARTEND) | 153 | if (! REG_STARTEND) |
129 | exit (1); | 154 | return 1; |
130 | 155 | ||
131 | /* Reject hosts whose regoff_t values are too narrow. | 156 | /* Reject hosts whose regoff_t values are too narrow. |
132 | These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t | 157 | These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t |
133 | and 32-bit int. */ | 158 | and 32-bit int. */ |
134 | if (sizeof (regoff_t) < sizeof (ptrdiff_t) | 159 | if (sizeof (regoff_t) < sizeof (ptrdiff_t) |
135 | || sizeof (regoff_t) < sizeof (ssize_t)) | 160 | || sizeof (regoff_t) < sizeof (ssize_t)) |
136 | exit (1); | 161 | return 1; |
137 | 162 | ||
138 | exit (0);]])], | 163 | return 0;]])], |
139 | [gl_cv_func_re_compile_pattern_working=yes], | 164 | [gl_cv_func_re_compile_pattern_working=yes], |
140 | [gl_cv_func_re_compile_pattern_working=no], | 165 | [gl_cv_func_re_compile_pattern_working=no], |
141 | dnl When crosscompiling, assume it is not working. | 166 | dnl When crosscompiling, assume it is not working. |
@@ -190,9 +215,8 @@ AC_DEFUN([gl_REGEX], | |||
190 | # Prerequisites of lib/regex.c and lib/regex_internal.c. | 215 | # Prerequisites of lib/regex.c and lib/regex_internal.c. |
191 | AC_DEFUN([gl_PREREQ_REGEX], | 216 | AC_DEFUN([gl_PREREQ_REGEX], |
192 | [ | 217 | [ |
193 | AC_REQUIRE([AC_GNU_SOURCE]) | 218 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
194 | AC_REQUIRE([AC_C_RESTRICT]) | 219 | AC_REQUIRE([AC_C_RESTRICT]) |
195 | AC_REQUIRE([AM_LANGINFO_CODESET]) | 220 | AC_CHECK_FUNCS_ONCE([isblank iswctype mbrtowc wcrtomb wcscoll]) |
196 | AC_CHECK_FUNCS_ONCE([iswctype mbrtowc mempcpy wcrtomb wcscoll]) | ||
197 | AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) | 221 | AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) |
198 | ]) | 222 | ]) |