Mercurial > gnulib
comparison m4/strcasestr.m4 @ 10189:2304e9103317
Work around environments that (stupidly) ignore SIGALRM.
* m4/strstr.m4 (gl_FUNC_STRSTR): Reset SIGALRM to default handling
before using alarm().
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
* m4/memmem.m4 (gl_FUNC_MEMMEM): Likewise.
Reported by Ian Beckwith <ianb@erislabs.net>.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 09 Jun 2008 16:21:34 -0600 |
parents | 44e8848f6ce8 |
children | 59047bad770e |
comparison
equal
deleted
inserted
replaced
10188:d97126852324 | 10189:2304e9103317 |
---|---|
1 # strcasestr.m4 serial 11 | 1 # strcasestr.m4 serial 12 |
2 dnl Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. | 2 dnl Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. |
3 dnl This file is free software; the Free Software Foundation | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | 4 dnl gives unlimited permission to copy and/or distribute it, |
5 dnl with or without modifications, as long as this notice is preserved. | 5 dnl with or without modifications, as long as this notice is preserved. |
6 | 6 |
24 AC_REQUIRE([gl_FUNC_STRCASESTR_SIMPLE]) | 24 AC_REQUIRE([gl_FUNC_STRCASESTR_SIMPLE]) |
25 if test $ac_cv_func_strcasestr = yes; then | 25 if test $ac_cv_func_strcasestr = yes; then |
26 AC_CACHE_CHECK([whether strcasestr works in linear time], | 26 AC_CACHE_CHECK([whether strcasestr works in linear time], |
27 [gl_cv_func_strcasestr_linear], | 27 [gl_cv_func_strcasestr_linear], |
28 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | 28 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
29 #include <signal.h> /* for signal */ | |
29 #include <string.h> /* for memmem */ | 30 #include <string.h> /* for memmem */ |
30 #include <stdlib.h> /* for malloc */ | 31 #include <stdlib.h> /* for malloc */ |
31 #include <unistd.h> /* for alarm */ | 32 #include <unistd.h> /* for alarm */ |
32 ]], [[size_t m = 1000000; | 33 ]], [[size_t m = 1000000; |
33 char *haystack = (char *) malloc (2 * m + 2); | 34 char *haystack = (char *) malloc (2 * m + 2); |
34 char *needle = (char *) malloc (m + 2); | 35 char *needle = (char *) malloc (m + 2); |
35 void *result = 0; | 36 void *result = 0; |
36 /* Failure to compile this test due to missing alarm is okay, | 37 /* Failure to compile this test due to missing alarm is okay, |
37 since all such platforms (mingw) also lack strcasestr. */ | 38 since all such platforms (mingw) also lack strcasestr. */ |
39 signal (SIGALRM, SIG_DFL); | |
38 alarm (5); | 40 alarm (5); |
39 /* Check for quadratic performance. */ | 41 /* Check for quadratic performance. */ |
40 if (haystack && needle) | 42 if (haystack && needle) |
41 { | 43 { |
42 memset (haystack, 'A', 2 * m); | 44 memset (haystack, 'A', 2 * m); |