diff options
Diffstat (limited to 'm4/regex.m4')
-rw-r--r-- | m4/regex.m4 | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/m4/regex.m4 b/m4/regex.m4 index ae89e3113..08bd46a96 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,6 +1,6 @@ -# serial 63 +# serial 65 -# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -27,7 +27,8 @@ AC_DEFUN([gl_REGEX], # 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_FUNCS_ONCE([alarm]) + 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( @@ -37,9 +38,19 @@ AC_DEFUN([gl_REGEX], #include <locale.h> #include <limits.h> #include <string.h> - #if HAVE_ALARM - # include <unistd.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; @@ -49,11 +60,18 @@ AC_DEFUN([gl_REGEX], const char *s; struct re_registers regs; -#if HAVE_ALARM - /* Some builds of glibc go into an infinite loop on this test. */ + /* 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")) { { @@ -84,17 +102,28 @@ AC_DEFUN([gl_REGEX], */ static char const pat[] = "[^x]x"; static char const data[] = - "\xe1\x80\x80\xe1\x80\xbb\xe1\x80\xbd\xe1\x80\x94\xe1\x80" - "\xba\xe1\x80\xaf\xe1\x80\x95\xe1\x80\xbax"; + /* <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 (®ex, 0, sizeof regex); s = re_compile_pattern (pat, sizeof pat - 1, ®ex); if (s) result |= 1; - else if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, 0) - != 21) - result |= 1; + else + { + i = re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, 0); + if (i != 0 && i != 21) + result |= 1; + } } if (! setlocale (LC_ALL, "C")) @@ -255,7 +284,8 @@ AC_DEFUN([gl_PREREQ_REGEX], 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 wcscoll]) + AC_CHECK_FUNCS_ONCE([isblank iswctype]) AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) ]) |