3 dnl Initially derived from code in GNU grep.
4 dnl Mostly written by Jim Meyering.
6 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
8 AC_DEFUN([jm_INCLUDED_REGEX],
10 dnl Even packages that don't use regex.c can use this macro.
11 dnl Of course, for them it doesn't do anything.
13 # Assume we'll default to using the included regex.c.
14 ac_use_included_regex=yes
16 # However, if the system regex support is good enough that it passes the
17 # the following run test, then default to *not* using the included regex.c.
18 # If cross compiling, assume the test would fail and use the included
19 # regex.c. The first failing regular expression is from `Spencer ere
20 # test #75' in grep-2.3.
21 AC_CACHE_CHECK([for working re_compile_pattern],
22 jm_cv_func_working_re_compile_pattern,
30 static struct re_pattern_buffer regex;
32 struct re_registers regs;
33 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
34 memset (®ex, 0, sizeof (regex));
35 [s = re_compile_pattern ("a[[:@:>@:]]b\n", 9, ®ex);]
36 /* This should fail with _Invalid character class name_ error. */
40 /* This should succeed, but doesn't for e.g. glibc-2.1.3. */
41 memset (®ex, 0, sizeof (regex));
42 s = re_compile_pattern ("{1", 2, ®ex);
47 /* The following example is derived from a problem report
48 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
49 memset (®ex, 0, sizeof (regex));
50 s = re_compile_pattern ("[[anĂ¹]]*n", 7, ®ex);
54 /* This should match, but doesn't for e.g. glibc-2.2.1. */
55 if (re_match (®ex, "an", 2, 0, ®s) != 2)
61 jm_cv_func_working_re_compile_pattern=yes,
62 jm_cv_func_working_re_compile_pattern=no,
63 dnl When crosscompiling, assume it's broken.
64 jm_cv_func_working_re_compile_pattern=no))
65 if test $jm_cv_func_working_re_compile_pattern = yes; then
66 ac_use_included_regex=no
69 test -n "$1" || AC_MSG_ERROR([missing argument])
70 m4_syscmd([test -f $1])
73 AC_ARG_WITH(included-regex,
74 [ --without-included-regex don't compile regex; this is the default on
75 systems with version 2 of the GNU C library
76 (use with caution on other system)],
77 jm_with_regex=$withval,
78 jm_with_regex=$ac_use_included_regex)
79 if test "$jm_with_regex" = yes; then