(jm_INCLUDED_REGEX): Remove now-unnecessary uses of changequote.
[gnulib.git] / m4 / regex.m4
1 #serial 6
2
3 dnl Initially derived from code in GNU grep.
4 dnl Mostly written by Jim Meyering.
5
6 dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
7 dnl
8 AC_DEFUN(jm_INCLUDED_REGEX,
9   [
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.
12
13     # Assume we'll default to using the included regex.c.
14     ac_use_included_regex=yes
15
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 failing regular expression is from `Spencer ere test #75'
20     # in grep-2.3.
21     AC_CACHE_CHECK([for working re_compile_pattern],
22                    jm_cv_func_working_re_compile_pattern,
23       AC_TRY_RUN(
24 [#include <stdio.h>
25 #include <regex.h>
26           int
27           main ()
28           {
29             static struct re_pattern_buffer regex;
30             const char *s;
31             re_set_syntax (RE_SYNTAX_POSIX_EGREP);
32             /* Add this third left square bracket, [, to balance the
33                three right ones below.  Otherwise autoconf-2.14 chokes.  */
34             s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
35             /* This should fail with _Invalid character class name_ error.  */
36             exit (s ? 0 : 1);
37           }
38         ],
39                jm_cv_func_working_re_compile_pattern=yes,
40                jm_cv_func_working_re_compile_pattern=no,
41                dnl When crosscompiling, assume it's broken.
42                jm_cv_func_working_re_compile_pattern=no))
43     if test $jm_cv_func_working_re_compile_pattern = yes; then
44       ac_use_included_regex=no
45     fi
46
47     test -n "$1" || AC_MSG_ERROR([missing argument])
48     syscmd([test -f $1])
49     ifelse(sysval, 0,
50       [
51
52         AC_ARG_WITH(included-regex,
53         [  --without-included-regex don't compile regex; this is the default on
54                           systems with version 2 of the GNU C library
55                           (use with caution on other system)],
56                     jm_with_regex=$withval,
57                     jm_with_regex=$ac_use_included_regex)
58         if test "$jm_with_regex" = yes; then
59           AC_SUBST(LIBOBJS)
60           LIBOBJS="$LIBOBJS regex.$ac_objext"
61         fi
62       ],
63     )
64   ]
65 )