/[cvs]/ccvs/m4/regex.m4
ViewVC logotype

Diff of /ccvs/m4/regex.m4

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by dprice, Fri Aug 12 20:57:46 2005 UTC revision 1.5 by dprice, Sun Sep 4 05:58:36 2005 UTC
# Line 1  Line 1 
1  #serial 24  #serial 29
2    
3  # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free  # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
4  # Software Foundation, Inc.  # Software Foundation, Inc.
# Line 10  Line 10 
10  dnl Initially derived from code in GNU grep.  dnl Initially derived from code in GNU grep.
11  dnl Mostly written by Jim Meyering.  dnl Mostly written by Jim Meyering.
12    
13    AC_PREREQ([2.50])
14    
15  AC_DEFUN([gl_REGEX],  AC_DEFUN([gl_REGEX],
16  [  [
17    gl_INCLUDED_REGEX([lib/regex.c])    AC_REQUIRE([AC_SYS_LARGEFILE]) dnl for a sufficently-wide off_t
18  ])    AC_DEFINE([_REGEX_LARGE_OFFSETS], 1,
19        [Define if you want regoff_t to be at least as wide POSIX requires.])
20  dnl Usage: gl_INCLUDED_REGEX([lib/regex.c])  
21  dnl    AC_LIBSOURCES(
22  AC_DEFUN([gl_INCLUDED_REGEX],      [regcomp.c, regex.c, regex.h,
23    [       regex_internal.c, regex_internal.h, regexec.c])
24      AC_LIBSOURCES(  
25        [regcomp.c, regex.c, regex.h,    AC_ARG_WITH([included-regex],
26         regex_internal.c, regex_internal.h, regexec.c])      [AC_HELP_STRING([--without-included-regex],
27                        [don't compile regex; this is the default on
28      dnl Even packages that don't use regex.c can use this macro.                       systems with recent-enough versions of the GNU C
29      dnl Of course, for them it doesn't do anything.                       Library (use with caution on other systems)])])
30    
31      # Assume we'll default to using the included regex.c.    case $with_included_regex in
32      ac_use_included_regex=yes    yes|no) ac_use_included_regex=$with_included_regex
33            ;;
34      # However, if the system regex support is good enough that it passes the    '')
35      # the following run test, then default to *not* using the included regex.c.      # If the system regex support is good enough that it passes the the
36        # following run test, then default to *not* using the included regex.c.
37      # If cross compiling, assume the test would fail and use the included      # If cross compiling, assume the test would fail and use the included
38      # regex.c.  The first failing regular expression is from `Spencer ere      # regex.c.  The first failing regular expression is from `Spencer ere
39      # test #75' in grep-2.3.      # test #75' in grep-2.3.
40      AC_CACHE_CHECK([for working re_compile_pattern],      AC_CACHE_CHECK([for working re_compile_pattern],
41                     [gl_cv_func_working_re_compile_pattern],                     [gl_cv_func_re_compile_pattern_broken],
42        [AC_RUN_IFELSE(        [AC_RUN_IFELSE(
43           [AC_LANG_PROGRAM(          [AC_LANG_PROGRAM(
44              [AC_INCLUDES_DEFAULT            [AC_INCLUDES_DEFAULT
45               #include <regex.h>],             #include <regex.h>],
46              [[static struct re_pattern_buffer regex;            [[static struct re_pattern_buffer regex;
47                const char *s;              const char *s;
48                struct re_registers regs;              struct re_registers regs;
49                re_set_syntax (RE_SYNTAX_POSIX_EGREP);              /* Use the POSIX-compliant spelling with leading REG_,
50                memset (&regex, 0, sizeof (regex));                 rather than the traditional GNU spelling with leading RE_,
51                s = re_compile_pattern ("a[:@:>@:]b\n", 9, &regex);                 so that we reject older libc implementations.  */
52                /* This should fail with _Invalid character class name_ error.  */              re_set_syntax (REG_SYNTAX_POSIX_EGREP);
53                if (!s)              memset (&regex, 0, sizeof (regex));
54                  exit (1);              s = re_compile_pattern ("a[:@:>@:]b\n", 9, &regex);
55                /* This should fail with _Invalid character class name_ error.  */
56                /* This should succeed, but does not for e.g. glibc-2.1.3.  */              if (!s)
57                memset (&regex, 0, sizeof (regex));                exit (1);
58                s = re_compile_pattern ("{1", 2, &regex);  
59                /* This should succeed, but does not for e.g. glibc-2.1.3.  */
60                if (s)              memset (&regex, 0, sizeof (regex));
61                  exit (1);              s = re_compile_pattern ("{1", 2, &regex);
62    
63                /* The following example is derived from a problem report              if (s)
64                   against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>.  */                exit (1);
65                memset (&regex, 0, sizeof (regex));  
66                s = re_compile_pattern ("[an\371]*n", 7, &regex);              /* The following example is derived from a problem report
67                if (s)                 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>.  */
68                  exit (1);              memset (&regex, 0, sizeof (regex));
69                s = re_compile_pattern ("[an\371]*n", 7, &regex);
70                /* This should match, but does not for e.g. glibc-2.2.1.  */              if (s)
71                if (re_match (&regex, "an", 2, 0, &regs) != 2)                exit (1);
72                  exit (1);  
73                /* This should match, but does not for e.g. glibc-2.2.1.  */
74                memset (&regex, 0, sizeof (regex));              if (re_match (&regex, "an", 2, 0, &regs) != 2)
75                s = re_compile_pattern ("x", 1, &regex);                exit (1);
76                if (s)  
77                  exit (1);              memset (&regex, 0, sizeof (regex));
78                s = re_compile_pattern ("x", 1, &regex);
79                /* The version of regex.c in e.g. GNU libc-2.2.93 did not              if (s)
80                   work with a negative RANGE argument.  */                exit (1);
81                if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)  
82                  exit (1);              /* The version of regex.c in e.g. GNU libc-2.2.93 did not
83                   work with a negative RANGE argument.  */
84                /* The version of regex.c in older versions of gnulib              if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
85                 * ignored RE_ICASE.  Detect that problem too. */                exit (1);
86                memset (&regex, 0, sizeof (regex));  
87                re_set_syntax(RE_SYNTAX_EMACS|RE_ICASE);              /* The version of regex.c in older versions of gnulib
88                s = re_compile_pattern ("x", 1, &regex);                 ignored REG_IGNORE_CASE (which was then called RE_ICASE).
89                if (s)                 Detect that problem too.  */
90                  exit (1);              memset (&regex, 0, sizeof (regex));
91                re_set_syntax (REG_SYNTAX_EMACS | REG_IGNORE_CASE);
92                if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)              s = re_compile_pattern ("x", 1, &regex);
93                  exit (1);              if (s)
94                  exit (1);
95                /* REG_STARTEND was added to glibc on 2004-01-15.  
96                   Reject older versions.  */              if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
97                if (! REG_STARTEND)                exit (1);
98                  exit (1);  
99                /* REG_STARTEND was added to glibc on 2004-01-15.
100                exit (0);]])],                 Reject older versions.  */
101           [gl_cv_func_working_re_compile_pattern=yes],              if (! REG_STARTEND)
102           [gl_cv_func_working_re_compile_pattern=no],                exit (1);
103           dnl When crosscompiling, assume it is broken.  
104           [gl_cv_func_working_re_compile_pattern=no])])              /* Reject hosts whose regoff_t values are too narrow.
105      if test $gl_cv_func_working_re_compile_pattern = yes; then                 These include glibc 2.3.5 on hosts with 64-bit off_t
106        ac_use_included_regex=no                 and 32-bit int, and Solaris 10 on hosts with 32-bit int
107      fi                 and _FILE_OFFSET_BITS=64.  */
108                if (sizeof (regoff_t) < sizeof (off_t))
109      test -n "$1" || AC_MSG_ERROR([missing argument])                exit (1);
110      m4_syscmd([test -f '$1'])  
111      ifelse(m4_sysval, 0,              exit (0);]])],
112        [         [gl_cv_func_re_compile_pattern_broken=no],
113          AC_ARG_WITH([included-regex],         [gl_cv_func_re_compile_pattern_broken=yes],
114            [  --without-included-regex don't compile regex; this is the default on         dnl When crosscompiling, assume it is broken.
115                            systems with recent-enough versions of the GNU C         [gl_cv_func_re_compile_pattern_broken=yes])])
116                            Library (use with caution on other systems)],      ac_use_included_regex=$gl_cv_func_re_compile_pattern_broken
117            [gl_with_regex=$withval],      ;;
118            [gl_with_regex=$ac_use_included_regex])    *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
119          if test "X$gl_with_regex" = Xyes; then      ;;
120            AC_LIBOBJ([regex])    esac
121            gl_PREREQ_REGEX  
122          fi    if test $ac_use_included_regex = yes; then
123        ],      AC_LIBOBJ([regex])
124      )      gl_PREREQ_REGEX
125    ]    fi
126  )  ])
127    
128  # Prerequisites of lib/regex.c and lib/regex_internal.c.  # Prerequisites of lib/regex.c and lib/regex_internal.c.
129  AC_DEFUN([gl_PREREQ_REGEX],  AC_DEFUN([gl_PREREQ_REGEX],
130  [  [
131      AC_REQUIRE([AC_GNU_SOURCE])
132    AC_REQUIRE([gl_C_RESTRICT])    AC_REQUIRE([gl_C_RESTRICT])
133    AC_REQUIRE([AM_LANGINFO_CODESET])    AC_REQUIRE([AM_LANGINFO_CODESET])
134    AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h])    AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h])

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26