summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-08-05 18:41:20 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2018-08-05 19:36:09 -0700
commitd904cc83f3036db96107a3976cee1a0112547de6 (patch)
tree7186eee577f0112462a024368c014819c4055152 /m4
parente5652268a993ad9117f7253553c143d60460eb8f (diff)
downloademacs-d904cc83f3036db96107a3976cee1a0112547de6.tar.gz
Use Gnulib regex for lib-src
Emacs regular expressions forked from everyone else long ago. This makes it official and should allow simplification later. etags.c now uses the glibc regex API, falling back on a Gnulib-supplied substitute lib/regex.c if necessary. Emacs proper now uses its own regular expression module. Although this patch may look dauntingly large, most of it was generated automatically by admin/merge-gnulib and contains an exact copy of the glibc regex source, and the by-hand changes do not grow the Emacs source code. * admin/merge-gnulib (GNULIB_MODULES): Add regex. (AVOIDED_MODULES): Add btowc, langinfo, lock, mbrtowc, mbsinit, nl_langinfo, wchar, wcrtomb, wctype-h. * lib-src/Makefile.in (regex-emacs.o): Remove; Gnulib does it now. (etags_deps, etags_libs): Remove regex-emacs.o. * lib-src/etags.c: Go back to including regex.h. (add_regex): Use unsigned char translation array, since glibc regex requires that. * lib/Makefile.in (not_emacs_OBJECTS, for_emacs_OBJECTS): New macros. (libegnu_a_OBJECTS): Use them, to avoid building e-regex.o. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/regcomp.c, lib/regex.c, lib/regex.h, lib/regex_internal.c: * lib/regex_internal.h, lib/regexec.c, m4/builtin-expect.m4: * m4/eealloc.m4, m4/glibc21.m4, m4/mbstate_t.m4, m4/regex.m4: New files, copied from Gnulib. * src/regex-emacs.h, src/conf_post.h: (RE_TRANSLATE_TYPE, RE_TRANSLATE, RE_TRANSLATE_P): Move from src/conf_post.h to src/regex-emacs.h, so that they don’t interfere with compiling lib/regex.c.
Diffstat (limited to 'm4')
-rw-r--r--m4/builtin-expect.m449
-rw-r--r--m4/eealloc.m431
-rw-r--r--m4/glibc21.m434
-rw-r--r--m4/gnulib-comp.m430
-rw-r--r--m4/mbstate_t.m441
-rw-r--r--m4/regex.m4300
6 files changed, 485 insertions, 0 deletions
diff --git a/m4/builtin-expect.m4 b/m4/builtin-expect.m4
new file mode 100644
index 00000000000..a1eaf965b45
--- /dev/null
+++ b/m4/builtin-expect.m4
@@ -0,0 +1,49 @@
+dnl Check for __builtin_expect.
+
+dnl Copyright 2016-2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN([gl___BUILTIN_EXPECT],
+[
+ AC_CACHE_CHECK([for __builtin_expect],
+ [gl_cv___builtin_expect],
+ [AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([[
+ int
+ main (int argc, char **argv)
+ {
+ argc = __builtin_expect (argc, 100);
+ return argv[argc != 100][0];
+ }]])],
+ [gl_cv___builtin_expect=yes],
+ [AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([[
+ #include <builtins.h>
+ int
+ main (int argc, char **argv)
+ {
+ argc = __builtin_expect (argc, 100);
+ return argv[argc != 100][0];
+ }]])],
+ [gl_cv___builtin_expect="in <builtins.h>"],
+ [gl_cv___builtin_expect=no])])])
+ if test "$gl_cv___builtin_expect" = yes; then
+ AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
+ elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
+ AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
+ fi
+ AH_VERBATIM([HAVE___BUILTIN_EXPECT],
+ [/* Define to 1 if the compiler supports __builtin_expect,
+ and to 2 if <builtins.h> does. */
+#undef HAVE___BUILTIN_EXPECT
+#ifndef HAVE___BUILTIN_EXPECT
+# define __builtin_expect(e, c) (e)
+#elif HAVE___BUILTIN_EXPECT == 2
+# include <builtins.h>
+#endif
+ ])
+])
diff --git a/m4/eealloc.m4 b/m4/eealloc.m4
new file mode 100644
index 00000000000..a5a4e267d8e
--- /dev/null
+++ b/m4/eealloc.m4
@@ -0,0 +1,31 @@
+# eealloc.m4 serial 3
+dnl Copyright (C) 2003, 2009-2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_EEALLOC],
+[
+ AC_REQUIRE([gl_EEMALLOC])
+ AC_REQUIRE([gl_EEREALLOC])
+])
+
+AC_DEFUN([gl_EEMALLOC],
+[
+ _AC_FUNC_MALLOC_IF(
+ [gl_cv_func_malloc_0_nonnull=1],
+ [gl_cv_func_malloc_0_nonnull=0])
+ AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull],
+ [If malloc(0) is != NULL, define this to 1. Otherwise define this
+ to 0.])
+])
+
+AC_DEFUN([gl_EEREALLOC],
+[
+ _AC_FUNC_REALLOC_IF(
+ [gl_cv_func_realloc_0_nonnull=1],
+ [gl_cv_func_realloc_0_nonnull=0])
+ AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull],
+ [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this
+ to 0.])
+])
diff --git a/m4/glibc21.m4 b/m4/glibc21.m4
new file mode 100644
index 00000000000..126aa1a959e
--- /dev/null
+++ b/m4/glibc21.m4
@@ -0,0 +1,34 @@
+# glibc21.m4 serial 5
+dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2018 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Test for the GNU C Library, version 2.1 or newer, or uClibc.
+# From Bruno Haible.
+
+AC_DEFUN([gl_GLIBC21],
+ [
+ AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
+ [ac_cv_gnu_library_2_1],
+ [AC_EGREP_CPP([Lucky],
+ [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
+ Lucky GNU user
+ #endif
+#endif
+#ifdef __UCLIBC__
+ Lucky user
+#endif
+ ],
+ [ac_cv_gnu_library_2_1=yes],
+ [ac_cv_gnu_library_2_1=no])
+ ]
+ )
+ AC_SUBST([GLIBC21])
+ GLIBC21="$ac_cv_gnu_library_2_1"
+ ]
+)
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 494c77c7c4e..61aabaa3427 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -48,6 +48,7 @@ AC_DEFUN([gl_EARLY],
# Code from module allocator:
# Code from module at-internal:
# Code from module binary-io:
+ # Code from module builtin-expect:
# Code from module byteswap:
# Code from module c-ctype:
# Code from module c-strcase:
@@ -129,6 +130,7 @@ AC_DEFUN([gl_EARLY],
# Code from module qcopy-acl:
# Code from module readlink:
# Code from module readlinkat:
+ # Code from module regex:
# Code from module root-uid:
# Code from module sig2str:
# Code from module signal-h:
@@ -358,6 +360,11 @@ AC_DEFUN([gl_INIT],
AC_LIBOBJ([readlinkat])
fi
gl_UNISTD_MODULE_INDICATOR([readlinkat])
+ gl_REGEX
+ if test $ac_use_included_regex = yes; then
+ AC_LIBOBJ([regex])
+ gl_PREREQ_REGEX
+ fi
gl_FUNC_SIG2STR
if test $ac_cv_func_sig2str = no; then
AC_LIBOBJ([sig2str])
@@ -425,6 +432,7 @@ AC_DEFUN([gl_INIT],
gl_UTIMENS
AC_C_VARARRAYS
gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
+ gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=false
gl_gnulib_enabled_cloexec=false
gl_gnulib_enabled_dirfd=false
gl_gnulib_enabled_dosname=false
@@ -448,6 +456,13 @@ AC_DEFUN([gl_INIT],
func_gl_gnulib_m4code_open
fi
}
+ func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547 ()
+ {
+ if ! $gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547; then
+ gl___BUILTIN_EXPECT
+ gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=true
+ fi
+ }
func_gl_gnulib_m4code_cloexec ()
{
if ! $gl_gnulib_enabled_cloexec; then
@@ -651,6 +666,9 @@ AC_DEFUN([gl_INIT],
if test $HAVE_READLINKAT = 0; then
func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
fi
+ if test $ac_use_included_regex = yes; then
+ func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547
+ fi
if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
func_gl_gnulib_m4code_strtoll
fi
@@ -659,6 +677,7 @@ AC_DEFUN([gl_INIT],
fi
m4_pattern_allow([^gl_GNULIB_ENABLED_])
AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547], [$gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547])
AM_CONDITIONAL([gl_GNULIB_ENABLED_cloexec], [$gl_gnulib_enabled_cloexec])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname])
@@ -924,6 +943,12 @@ AC_DEFUN([gl_FILE_LIST], [
lib/qcopy-acl.c
lib/readlink.c
lib/readlinkat.c
+ lib/regcomp.c
+ lib/regex.c
+ lib/regex.h
+ lib/regex_internal.c
+ lib/regex_internal.h
+ lib/regexec.c
lib/root-uid.h
lib/set-permissions.c
lib/sha1.c
@@ -980,6 +1005,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/absolute-header.m4
m4/acl.m4
m4/alloca.m4
+ m4/builtin-expect.m4
m4/byteswap.m4
m4/c-strtod.m4
m4/clock_time.m4
@@ -991,6 +1017,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/dirent_h.m4
m4/dirfd.m4
m4/dup2.m4
+ m4/eealloc.m4
m4/environ.m4
m4/errno_h.m4
m4/euidaccess.m4
@@ -1018,6 +1045,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/gettime.m4
m4/gettimeofday.m4
m4/gl-openssl.m4
+ m4/glibc21.m4
m4/gnulib-common.m4
m4/group-member.m4
m4/ieee754-h.m4
@@ -1030,6 +1058,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/lstat.m4
m4/manywarnings-c++.m4
m4/manywarnings.m4
+ m4/mbstate_t.m4
m4/md5.m4
m4/memrchr.m4
m4/minmax.m4
@@ -1048,6 +1077,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/putenv.m4
m4/readlink.m4
m4/readlinkat.m4
+ m4/regex.m4
m4/sha1.m4
m4/sha256.m4
m4/sha512.m4
diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4
new file mode 100644
index 00000000000..004aa0d17c8
--- /dev/null
+++ b/m4/mbstate_t.m4
@@ -0,0 +1,41 @@
+# mbstate_t.m4 serial 13
+dnl Copyright (C) 2000-2002, 2008-2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# From Paul Eggert.
+
+# BeOS 5 has <wchar.h> but does not define mbstate_t,
+# so you can't declare an object of that type.
+# Check for this incompatibility with Standard C.
+
+# AC_TYPE_MBSTATE_T
+# -----------------
+AC_DEFUN([AC_TYPE_MBSTATE_T],
+[
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
+
+ AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT[
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+ <wchar.h>.
+ BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+ included before <wchar.h>. */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>]],
+ [[mbstate_t x; return sizeof x;]])],
+ [ac_cv_type_mbstate_t=yes],
+ [ac_cv_type_mbstate_t=no])])
+ if test $ac_cv_type_mbstate_t = yes; then
+ AC_DEFINE([HAVE_MBSTATE_T], [1],
+ [Define to 1 if <wchar.h> declares mbstate_t.])
+ else
+ AC_DEFINE([mbstate_t], [int],
+ [Define to a type if <wchar.h> does not define.])
+ fi
+])
diff --git a/m4/regex.m4 b/m4/regex.m4
new file mode 100644
index 00000000000..055d71b5aaa
--- /dev/null
+++ b/m4/regex.m4
@@ -0,0 +1,300 @@
+# serial 67
+
+# Copyright (C) 1996-2001, 2003-2018 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+dnl Initially derived from code in GNU grep.
+dnl Mostly written by Jim Meyering.
+
+AC_PREREQ([2.50])
+
+AC_DEFUN([gl_REGEX],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_ARG_WITH([included-regex],
+ [AS_HELP_STRING([--without-included-regex],
+ [don't compile regex; this is the default on systems
+ with recent-enough versions of the GNU C Library
+ (use with caution on other systems).])])
+
+ case $with_included_regex in #(
+ yes|no) ac_use_included_regex=$with_included_regex
+ ;;
+ '')
+ # If the system regex support is good enough that it passes the
+ # following run test, then default to *not* using the included regex.c.
+ # If cross compiling, assume the test would fail and use the included
+ # regex.c.
+ AC_CHECK_DECLS_ONCE([alarm])
+ AC_CHECK_HEADERS_ONCE([malloc.h])
+ AC_CACHE_CHECK([for working re_compile_pattern],
+ [gl_cv_func_re_compile_pattern_working],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <regex.h>
+
+ #include <locale.h>
+ #include <limits.h>
+ #include <string.h>
+
+ #if defined M_CHECK_ACTION || HAVE_DECL_ALARM
+ # include <signal.h>
+ # include <unistd.h>
+ #endif
+
+ #if HAVE_MALLOC_H
+ # include <malloc.h>
+ #endif
+
+ #ifdef M_CHECK_ACTION
+ /* Exit with distinguishable exit code. */
+ static void sigabrt_no_core (int sig) { raise (SIGTERM); }
+ #endif
+ ]],
+ [[int result = 0;
+ static struct re_pattern_buffer regex;
+ unsigned char folded_chars[UCHAR_MAX + 1];
+ int i;
+ const char *s;
+ struct re_registers regs;
+
+ /* Some builds of glibc go into an infinite loop on this
+ test. Use alarm to force death, and mallopt to avoid
+ malloc recursion in diagnosing the corrupted heap. */
+#if HAVE_DECL_ALARM
+ signal (SIGALRM, SIG_DFL);
+ alarm (2);
+#endif
+#ifdef M_CHECK_ACTION
+ signal (SIGABRT, sigabrt_no_core);
+ mallopt (M_CHECK_ACTION, 2);
+#endif
+
+ if (setlocale (LC_ALL, "en_US.UTF-8"))
+ {
+ {
+ /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
+ This test needs valgrind to catch the bug on Debian
+ GNU/Linux 3.1 x86, but it might catch the bug better
+ on other platforms and it shouldn't hurt to try the
+ test here. */
+ static char const pat[] = "insert into";
+ static char const data[] =
+ "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
+ re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE
+ | RE_ICASE);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern (pat, sizeof pat - 1, &regex);
+ if (s)
+ result |= 1;
+ else if (re_search (&regex, data, sizeof data - 1,
+ 0, sizeof data - 1, &regs)
+ != -1)
+ result |= 1;
+ regfree (&regex);
+ }
+
+ {
+ /* This test is from glibc bug 15078.
+ The test case is from Andreas Schwab in
+ <https://sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
+ */
+ static char const pat[] = "[^x]x";
+ static char const data[] =
+ /* <U1000><U103B><U103D><U1014><U103A><U102F><U1015><U103A> */
+ "\xe1\x80\x80"
+ "\xe1\x80\xbb"
+ "\xe1\x80\xbd"
+ "\xe1\x80\x94"
+ "\xe1\x80\xba"
+ "\xe1\x80\xaf"
+ "\xe1\x80\x95"
+ "\xe1\x80\xba"
+ "x";
+ re_set_syntax (0);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern (pat, sizeof pat - 1, &regex);
+ if (s)
+ result |= 1;
+ else
+ {
+ i = re_search (&regex, data, sizeof data - 1,
+ 0, sizeof data - 1, 0);
+ if (i != 0 && i != 21)
+ result |= 1;
+ }
+ regfree (&regex);
+ }
+
+ if (! setlocale (LC_ALL, "C"))
+ return 1;
+ }
+
+ /* This test is from glibc bug 3957, reported by Andrew Mackey. */
+ re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("a[^x]b", 6, &regex);
+ if (s)
+ result |= 2;
+ /* This should fail, but succeeds for glibc-2.5. */
+ else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
+ result |= 2;
+
+ /* This regular expression is from Spencer ere test number 75
+ in grep-2.3. */
+ re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+ memset (&regex, 0, sizeof regex);
+ for (i = 0; i <= UCHAR_MAX; i++)
+ folded_chars[i] = i;
+ regex.translate = folded_chars;
+ s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
+ /* This should fail with _Invalid character class name_ error. */
+ if (!s)
+ result |= 4;
+
+ /* Ensure that [b-a] is diagnosed as invalid, when
+ using RE_NO_EMPTY_RANGES. */
+ re_set_syntax (RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("a[b-a]", 6, &regex);
+ if (s == 0)
+ result |= 8;
+
+ /* This should succeed, but does not for glibc-2.1.3. */
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("{1", 2, &regex);
+ if (s)
+ result |= 8;
+
+ /* The following example is derived from a problem report
+ against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("[an\371]*n", 7, &regex);
+ if (s)
+ result |= 8;
+ /* This should match, but does not for glibc-2.2.1. */
+ else if (re_match (&regex, "an", 2, 0, &regs) != 2)
+ result |= 8;
+
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("x", 1, &regex);
+ if (s)
+ result |= 8;
+ /* glibc-2.2.93 does not work with a negative RANGE argument. */
+ else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
+ result |= 8;
+
+ /* The version of regex.c in older versions of gnulib
+ ignored RE_ICASE. Detect that problem too. */
+ re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("x", 1, &regex);
+ if (s)
+ result |= 16;
+ else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
+ result |= 16;
+
+ /* Catch a bug reported by Vin Shelton in
+ https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html
+ */
+ re_set_syntax (RE_SYNTAX_POSIX_BASIC
+ & ~RE_CONTEXT_INVALID_DUP
+ & ~RE_NO_EMPTY_RANGES);
+ memset (&regex, 0, sizeof regex);
+ s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex);
+ if (s)
+ result |= 32;
+
+ /* REG_STARTEND was added to glibc on 2004-01-15.
+ Reject older versions. */
+ if (! REG_STARTEND)
+ result |= 64;
+
+#if 0
+ /* It would be nice to reject hosts whose regoff_t values are too
+ narrow (including glibc on hosts with 64-bit ptrdiff_t and
+ 32-bit int), but we should wait until glibc implements this
+ feature. Otherwise, support for equivalence classes and
+ multibyte collation symbols would always be broken except
+ when compiling --without-included-regex. */
+ if (sizeof (regoff_t) < sizeof (ptrdiff_t)
+ || sizeof (regoff_t) < sizeof (ssize_t))
+ result |= 64;
+#endif
+
+ return result;
+ ]])],
+ [gl_cv_func_re_compile_pattern_working=yes],
+ [gl_cv_func_re_compile_pattern_working=no],
+ [case "$host_os" in
+ # Guess no on native Windows.
+ mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;;
+ # Otherwise, assume it is not working.
+ *) gl_cv_func_re_compile_pattern_working="guessing no" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_re_compile_pattern_working" in #(
+ *yes) ac_use_included_regex=no;; #(
+ *no) ac_use_included_regex=yes;;
+ esac
+ ;;
+ *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
+ ;;
+ esac
+
+ if test $ac_use_included_regex = yes; then
+ AC_DEFINE([_REGEX_INCLUDE_LIMITS_H], [1],
+ [Define if you want <regex.h> to include <limits.h>, so that it
+ consistently overrides <limits.h>'s RE_DUP_MAX.])
+ AC_DEFINE([_REGEX_LARGE_OFFSETS], [1],
+ [Define if you want regoff_t to be at least as wide POSIX requires.])
+ AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
+ [Define to rpl_re_syntax_options if the replacement should be used.])
+ AC_DEFINE([re_set_syntax], [rpl_re_set_syntax],
+ [Define to rpl_re_set_syntax if the replacement should be used.])
+ AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern],
+ [Define to rpl_re_compile_pattern if the replacement should be used.])
+ AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap],
+ [Define to rpl_re_compile_fastmap if the replacement should be used.])
+ AC_DEFINE([re_search], [rpl_re_search],
+ [Define to rpl_re_search if the replacement should be used.])
+ AC_DEFINE([re_search_2], [rpl_re_search_2],
+ [Define to rpl_re_search_2 if the replacement should be used.])
+ AC_DEFINE([re_match], [rpl_re_match],
+ [Define to rpl_re_match if the replacement should be used.])
+ AC_DEFINE([re_match_2], [rpl_re_match_2],
+ [Define to rpl_re_match_2 if the replacement should be used.])
+ AC_DEFINE([re_set_registers], [rpl_re_set_registers],
+ [Define to rpl_re_set_registers if the replacement should be used.])
+ AC_DEFINE([re_comp], [rpl_re_comp],
+ [Define to rpl_re_comp if the replacement should be used.])
+ AC_DEFINE([re_exec], [rpl_re_exec],
+ [Define to rpl_re_exec if the replacement should be used.])
+ AC_DEFINE([regcomp], [rpl_regcomp],
+ [Define to rpl_regcomp if the replacement should be used.])
+ AC_DEFINE([regexec], [rpl_regexec],
+ [Define to rpl_regexec if the replacement should be used.])
+ AC_DEFINE([regerror], [rpl_regerror],
+ [Define to rpl_regerror if the replacement should be used.])
+ AC_DEFINE([regfree], [rpl_regfree],
+ [Define to rpl_regfree if the replacement should be used.])
+ fi
+])
+
+# Prerequisites of lib/regex.c and lib/regex_internal.c.
+AC_DEFUN([gl_PREREQ_REGEX],
+[
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+ AC_REQUIRE([AC_C_INLINE])
+ AC_REQUIRE([AC_C_RESTRICT])
+ AC_REQUIRE([AC_TYPE_MBSTATE_T])
+ AC_REQUIRE([gl_EEMALLOC])
+ AC_REQUIRE([gl_GLIBC21])
+ AC_CHECK_HEADERS([libintl.h])
+ AC_CHECK_FUNCS_ONCE([isblank iswctype])
+ AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
+])