diff options
author | Łukasz Stelmach <l.stelmach@samsung.com> | 2014-01-15 13:17:08 +0100 |
---|---|---|
committer | Łukasz Stelmach <l.stelmach@samsung.com> | 2014-01-15 13:17:08 +0100 |
commit | 90b2de102fe4c773f9d6ba2da2065f254a5803b6 (patch) | |
tree | e1fa3d099d6e8eeafd3dd0eef243b8d2f41a0b9b /m4/regex.m4 | |
parent | 20c6d7ec2c817aa561410130efc8c8254fbef2b2 (diff) | |
download | diffutils-90b2de102fe4c773f9d6ba2da2065f254a5803b6.tar.gz diffutils-90b2de102fe4c773f9d6ba2da2065f254a5803b6.tar.bz2 diffutils-90b2de102fe4c773f9d6ba2da2065f254a5803b6.zip |
Imported Upstream version 3.3upstream/3.3
Diffstat (limited to 'm4/regex.m4')
-rw-r--r-- | m4/regex.m4 | 90 |
1 files changed, 64 insertions, 26 deletions
diff --git a/m4/regex.m4 b/m4/regex.m4 index e48fab0..3334c10 100644 --- a/m4/regex.m4 +++ b/m4/regex.m4 @@ -1,6 +1,6 @@ -# serial 59 +# serial 64 -# Copyright (C) 1996-2001, 2003-2011 Free Software Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -27,15 +27,21 @@ 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_DECLS_ONCE([alarm]) AC_CACHE_CHECK([for working re_compile_pattern], [gl_cv_func_re_compile_pattern_working], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( - [AC_INCLUDES_DEFAULT[ - #include <locale.h> - #include <limits.h> - #include <regex.h> - ]], + [[#include <regex.h> + + #include <locale.h> + #include <limits.h> + #include <string.h> + #if HAVE_DECL_ALARM + # include <unistd.h> + # include <signal.h> + #endif + ]], [[int result = 0; static struct re_pattern_buffer regex; unsigned char folded_chars[UCHAR_MAX + 1]; @@ -43,26 +49,54 @@ AC_DEFUN([gl_REGEX], const char *s; struct re_registers regs; - /* http://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. */ +#if HAVE_DECL_ALARM + /* Some builds of glibc go into an infinite loop on this test. */ + signal (SIGALRM, SIG_DFL); + alarm (2); +#endif if (setlocale (LC_ALL, "en_US.UTF-8")) { - 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 (®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, ®s) - != -1) - result |= 1; + { + /* http://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 (®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, ®s) + != -1) + result |= 1; + } + + { + /* This test is from glibc bug 15078. + The test case is from Andreas Schwab in + <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>. + */ + 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"; + 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; + } + if (! setlocale (LC_ALL, "C")) return 1; } @@ -175,6 +209,9 @@ AC_DEFUN([gl_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], @@ -217,7 +254,8 @@ AC_DEFUN([gl_PREREQ_REGEX], AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) + AC_REQUIRE([gl_EEMALLOC]) AC_CHECK_HEADERS([libintl.h]) AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll]) - AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) + AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) ]) |