source: trunk/essentials/sys-apps/grep/m4/regex.m4

Last change on this file was 2557, checked in by bird, 19 years ago

grep 2.5.1a

File size: 2.2 KB
Line 
1#serial 5001
2
3dnl Initially derived from code in GNU grep.
4dnl Mostly written by Jim Meyering.
5
6dnl Usage: jm_INCLUDED_REGEX([lib/regex.c])
7dnl
8AC_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 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,
23 AC_TRY_RUN(
24 changequote(<<, >>)dnl
25 <<
26#include <stdio.h>
27#include <regex.h>
28 int
29 main ()
30 {
31 static struct re_pattern_buffer regex;
32 const char *s;
33 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
34 /* Add this third left square bracket, [, to balance the
35 three right ones below. Otherwise autoconf-2.14 chokes. */
36 s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
37 /* This should fail with _Invalid character class name_ error. */
38 if (!s)
39 exit (1);
40
41 /* This should succeed, but doesn't for e.g. glibc-2.1.3. */
42 s = re_compile_pattern ("{1", 2, &regex);
43
44 exit (s ? 1 : 0);
45 }
46 >>,
47 changequote([, ])dnl
48
49 jm_cv_func_working_re_compile_pattern=yes,
50 jm_cv_func_working_re_compile_pattern=no,
51 dnl When crosscompiling, assume it's broken.
52 jm_cv_func_working_re_compile_pattern=no))
53 if test $jm_cv_func_working_re_compile_pattern = yes; then
54 ac_use_included_regex=no
55 fi
56
57 test -n "$1" || AC_MSG_ERROR([missing argument])
58 syscmd([test -f $1])
59 ifelse(sysval, 0,
60 [
61
62 AC_ARG_WITH(included-regex,
63 [ --without-included-regex don't compile regex; this is the default on
64 systems with version 2 of the GNU C library
65 (use with caution on other system)],
66 jm_with_regex=$withval,
67 jm_with_regex=$ac_use_included_regex)
68 if test "$jm_with_regex" = yes; then
69 AC_LIBOBJ(regex)
70 fi
71 ],
72 )
73 ]
74)
Note: See TracBrowser for help on using the repository browser.