3 dnl Initially derived from code in GNU grep.
4 dnl Mostly written by Jim Meyering.
8 jm_INCLUDED_REGEX([lib/regex.c])
11 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
13 AC_DEFUN([jm_INCLUDED_REGEX],
15 dnl Even packages that don't use regex.c can use this macro.
16 dnl Of course, for them it doesn't do anything.
18 # Assume we'll default to using the included regex.c.
19 ac_use_included_regex=yes
21 # However, if the system regex support is good enough that it passes the
22 # the following run test, then default to *not* using the included regex.c.
23 # If cross compiling, assume the test would fail and use the included
24 # regex.c. The first failing regular expression is from `Spencer ere
25 # test #75' in grep-2.3.
26 AC_CACHE_CHECK([for working re_compile_pattern],
27 jm_cv_func_working_re_compile_pattern,
35 static struct re_pattern_buffer regex;
37 struct re_registers regs;
38 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
39 memset (®ex, 0, sizeof (regex));
40 [s = re_compile_pattern ("a[[:@:>@:]]b\n", 9, ®ex);]
41 /* This should fail with _Invalid character class name_ error. */
45 /* This should succeed, but doesn't for e.g. glibc-2.1.3. */
46 memset (®ex, 0, sizeof (regex));
47 s = re_compile_pattern ("{1", 2, ®ex);
52 /* The following example is derived from a problem report
53 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
54 memset (®ex, 0, sizeof (regex));
55 s = re_compile_pattern ("[[anĂ¹]]*n", 7, ®ex);
59 /* This should match, but doesn't for e.g. glibc-2.2.1. */
60 if (re_match (®ex, "an", 2, 0, ®s) != 2)
66 jm_cv_func_working_re_compile_pattern=yes,
67 jm_cv_func_working_re_compile_pattern=no,
68 dnl When crosscompiling, assume it's broken.
69 jm_cv_func_working_re_compile_pattern=no))
70 if test $jm_cv_func_working_re_compile_pattern = yes; then
71 ac_use_included_regex=no
74 test -n "$1" || AC_MSG_ERROR([missing argument])
75 m4_syscmd([test -f $1])
78 AC_ARG_WITH(included-regex,
79 [ --without-included-regex don't compile regex; this is the default on
80 systems with version 2 of the GNU C library
81 (use with caution on other system)],
82 jm_with_regex=$withval,
83 jm_with_regex=$ac_use_included_regex)
84 if test "$jm_with_regex" = yes; then
93 # Prerequisites of lib/regex.c.
94 AC_DEFUN([jm_PREREQ_REGEX],
96 dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
97 dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
100 dnl Persuade glibc <string.h> to declare mempcpy().
101 AC_REQUIRE([AC_GNU_SOURCE])
103 AC_REQUIRE([AC_FUNC_ALLOCA])
104 AC_REQUIRE([AC_HEADER_STDC])
105 AC_CHECK_HEADERS_ONCE(limits.h string.h wchar.h wctype.h)
106 AC_CHECK_FUNCS_ONCE(isascii mempcpy)
107 AC_CHECK_FUNCS(btowc)