extensions: port better to MINUX 3, HP-UX, autoheader 2.62
[gnulib.git] / m4 / regex.m4
index 2f5bd09..ae89e31 100644 (file)
@@ -1,4 +1,4 @@
-# serial 62
+# serial 63
 
 # Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc.
 #
@@ -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_FUNCS_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_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,6 +49,11 @@ 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.  */
+            signal (SIGALRM, SIG_DFL);
+            alarm (2);
+#endif
             if (setlocale (LC_ALL, "en_US.UTF-8"))
               {
                 {
@@ -82,7 +93,7 @@ AC_DEFUN([gl_REGEX],
                     result |= 1;
                   else if (re_search (&regex, data, sizeof data - 1,
                                       0, sizeof data - 1, 0)
-                           != 20)
+                           != 21)
                     result |= 1;
                 }