mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
gnulib: added strcasestr
This commit is contained in:
@@ -8,6 +8,7 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CHECK_FUNCS_ONCE([getdtablesize])
|
||||
m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
|
||||
AC_CHECK_FUNCS_ONCE([dup2])
|
||||
if test $ac_cv_func_dup2 = no; then
|
||||
@@ -23,6 +24,11 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>]],
|
||||
[int result = 0;
|
||||
#ifdef HAVE_GETDTABLESIZE
|
||||
int bad_fd = getdtablesize ();
|
||||
#else
|
||||
int bad_fd = 1000000;
|
||||
#endif
|
||||
#ifdef FD_CLOEXEC
|
||||
if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
|
||||
result |= 1;
|
||||
@@ -37,7 +43,7 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||
if (dup2 (0, 0) != -1)
|
||||
result |= 8;
|
||||
/* Many gnulib modules require POSIX conformance of EBADF. */
|
||||
if (dup2 (2, 1000000) == -1 && errno != EBADF)
|
||||
if (dup2 (2, bad_fd) == -1 && errno != EBADF)
|
||||
result |= 16;
|
||||
/* Flush out some cygwin core dumps. */
|
||||
if (dup2 (2, -1) != -1 || errno != EBADF)
|
||||
@@ -56,7 +62,9 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||
linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
|
||||
# closed fd may yield -EBADF instead of -1 / errno=EBADF.
|
||||
gl_cv_func_dup2_works="guessing no" ;;
|
||||
freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
|
||||
aix* | freebsd*)
|
||||
# on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
|
||||
# not EBADF.
|
||||
gl_cv_func_dup2_works="guessing no" ;;
|
||||
haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
|
||||
gl_cv_func_dup2_works="guessing no" ;;
|
||||
|
||||
@@ -19,13 +19,28 @@ AC_DEFUN([gl_EXTERN_INLINE],
|
||||
'reference to static identifier "f" in extern inline function'.
|
||||
This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
|
||||
|
||||
Suppress the use of extern inline on problematic Apple configurations.
|
||||
OS X 10.8 and earlier mishandle it; see, e.g.,
|
||||
<http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
|
||||
Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
|
||||
on configurations that mistakenly use 'static inline' to implement
|
||||
functions or macros in standard C headers like <ctype.h>. For example,
|
||||
if isdigit is mistakenly implemented via a static inline function,
|
||||
a program containing an extern inline function that calls isdigit
|
||||
may not work since the C standard prohibits extern inline functions
|
||||
from calling static functions. This bug is known to occur on:
|
||||
|
||||
OS X 10.8 and earlier; see:
|
||||
http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html
|
||||
|
||||
DragonFly; see
|
||||
http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log
|
||||
|
||||
FreeBSD; see:
|
||||
http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html
|
||||
|
||||
OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
|
||||
for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
|
||||
Perhaps Apple will fix this some day. */
|
||||
#if (defined __APPLE__ \
|
||||
Assume DragonFly and FreeBSD will be similar. */
|
||||
#if (((defined __APPLE__ && defined __MACH__) \
|
||||
|| defined __DragonFly__ || defined __FreeBSD__) \
|
||||
&& (defined __header_inline \
|
||||
? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
|
||||
&& ! defined __clang__) \
|
||||
@@ -33,19 +48,19 @@ AC_DEFUN([gl_EXTERN_INLINE],
|
||||
&& (defined __GNUC__ || defined __cplusplus)) \
|
||||
|| (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
|
||||
&& defined __GNUC__ && ! defined __cplusplus))))
|
||||
# define _GL_EXTERN_INLINE_APPLE_BUG
|
||||
# define _GL_EXTERN_INLINE_STDHEADER_BUG
|
||||
#endif
|
||||
#if ((__GNUC__ \
|
||||
? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
|
||||
: (199901L <= __STDC_VERSION__ \
|
||||
&& !defined __HP_cc \
|
||||
&& !(defined __SUNPRO_C && __STDC__))) \
|
||||
&& !defined _GL_EXTERN_INLINE_APPLE_BUG)
|
||||
&& !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
|
||||
# define _GL_INLINE inline
|
||||
# define _GL_EXTERN_INLINE extern inline
|
||||
# define _GL_EXTERN_INLINE_IN_USE
|
||||
#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
|
||||
&& !defined _GL_EXTERN_INLINE_APPLE_BUG)
|
||||
&& !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
|
||||
# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
|
||||
/* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
|
||||
# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
|
||||
|
||||
@@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CHECK_FUNCS_ONCE([fcntl])
|
||||
AC_CHECK_FUNCS_ONCE([fcntl getdtablesize])
|
||||
if test $ac_cv_func_fcntl = no; then
|
||||
gl_REPLACE_FCNTL
|
||||
else
|
||||
@@ -28,11 +28,21 @@ AC_DEFUN([gl_FUNC_FCNTL],
|
||||
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
|
||||
[gl_cv_func_fcntl_f_dupfd_works],
|
||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
#ifdef HAVE_GETDTABLESIZE
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
]], [[int result = 0;
|
||||
#ifdef HAVE_GETDTABLESIZE
|
||||
int bad_fd = getdtablesize ();
|
||||
#else
|
||||
int bad_fd = 1000000;
|
||||
#endif
|
||||
if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
|
||||
if (errno != EINVAL) result |= 2;
|
||||
if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
|
||||
if (errno != EINVAL) result |= 8;
|
||||
return result;
|
||||
]])],
|
||||
[gl_cv_func_fcntl_f_dupfd_works=yes],
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
# Specification in the form of a command-line invocation:
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --no-libtool --macro-prefix=gl base64 c-ctype c-strcase cloexec getline getpass havelib memmem minmax
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --no-libtool --macro-prefix=gl base64 c-ctype c-strcase cloexec getline getpass havelib memmem minmax strcasestr
|
||||
|
||||
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||
gl_LOCAL_DIR([])
|
||||
@@ -41,6 +41,7 @@ gl_MODULES([
|
||||
havelib
|
||||
memmem
|
||||
minmax
|
||||
strcasestr
|
||||
])
|
||||
gl_AVOID([])
|
||||
gl_SOURCE_BASE([gl])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# gnulib-common.m4 serial 34
|
||||
# gnulib-common.m4 serial 35
|
||||
dnl Copyright (C) 2007-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
@@ -49,6 +49,16 @@ AC_DEFUN([gl_COMMON_BODY], [
|
||||
is a misnomer outside of parameter lists. */
|
||||
#define _UNUSED_PARAMETER_ _GL_UNUSED
|
||||
|
||||
/* gcc supports the "unused" attribute on possibly unused labels, and
|
||||
g++ has since version 4.5. Note to support C++ as well as C,
|
||||
_GL_UNUSED_LABEL should be used with a trailing ; */
|
||||
#if !defined __cplusplus || __GNUC__ > 4 \
|
||||
|| (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||
# define _GL_UNUSED_LABEL _GL_UNUSED
|
||||
#else
|
||||
# define _GL_UNUSED_LABEL
|
||||
#endif
|
||||
|
||||
/* The __pure__ attribute was added in gcc 2.96. */
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
|
||||
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
@@ -379,3 +389,59 @@ AC_DEFUN([gl_CACHE_VAL_SILENT],
|
||||
# AS_VAR_COPY was added in autoconf 2.63b
|
||||
m4_define_default([AS_VAR_COPY],
|
||||
[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
|
||||
|
||||
# AC_PROG_SED was added in autoconf 2.59b
|
||||
m4_ifndef([AC_PROG_SED],
|
||||
[AC_DEFUN([AC_PROG_SED],
|
||||
[AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
|
||||
[dnl ac_script should not contain more than 99 commands (for HP-UX sed),
|
||||
dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
|
||||
ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
|
||||
for ac_i in 1 2 3 4 5 6 7; do
|
||||
ac_script="$ac_script$as_nl$ac_script"
|
||||
done
|
||||
echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
|
||||
AS_UNSET([ac_script])
|
||||
if test -z "$SED"; then
|
||||
ac_path_SED_found=false
|
||||
_AS_PATH_WALK([], [
|
||||
for ac_prog in sed gsed; do
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
|
||||
AS_EXECUTABLE_P(["$ac_path_SED"]) || continue
|
||||
case `"$ac_path_SED" --version 2>&1` in
|
||||
*GNU*) ac_cv_path_SED=$ac_path_SED ac_path_SED_found=:;;
|
||||
*)
|
||||
ac_count=0
|
||||
_AS_ECHO_N([0123456789]) >conftest.in
|
||||
while :
|
||||
do
|
||||
cat conftest.in conftest.in >conftest.tmp
|
||||
mv conftest.tmp conftest.in
|
||||
cp conftest.in conftest.nl
|
||||
echo >> conftest.nl
|
||||
"$ac_path_SED" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
|
||||
diff conftest.out conftest.nl >/dev/null 2>&1 || break
|
||||
ac_count=`expr $ac_count + 1`
|
||||
if test $ac_count -gt ${ac_path_SED_max-0}; then
|
||||
# Best so far, but keep looking for better
|
||||
ac_cv_path_SED=$ac_path_SED
|
||||
ac_path_SED_max=$ac_count
|
||||
fi
|
||||
test $ac_count -gt 10 && break
|
||||
done
|
||||
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
|
||||
esac
|
||||
$ac_path_SED_found && break 3
|
||||
done
|
||||
done])
|
||||
if test -z "$ac_cv_path_SED"; then
|
||||
AC_ERROR([no acceptable sed could be found in \$PATH])
|
||||
fi
|
||||
else
|
||||
ac_cv_path_SED=$SED
|
||||
fi
|
||||
SED="$ac_cv_path_SED"
|
||||
AC_SUBST([SED])dnl
|
||||
rm -f conftest.sed
|
||||
])])])
|
||||
|
||||
@@ -85,8 +85,12 @@ AC_DEFUN([gl_EARLY],
|
||||
# Code from module stdint:
|
||||
# Code from module stdio:
|
||||
# Code from module stdlib:
|
||||
# Code from module strcase:
|
||||
# Code from module strcasestr:
|
||||
# Code from module strcasestr-simple:
|
||||
# Code from module strdup-posix:
|
||||
# Code from module string:
|
||||
# Code from module strings:
|
||||
# Code from module sys_stat:
|
||||
# Code from module sys_time:
|
||||
# Code from module sys_types:
|
||||
@@ -224,6 +228,26 @@ AC_DEFUN([gl_INIT],
|
||||
gl_STDINT_H
|
||||
gl_STDIO_H
|
||||
gl_STDLIB_H
|
||||
gl_STRCASE
|
||||
if test $HAVE_STRCASECMP = 0; then
|
||||
AC_LIBOBJ([strcasecmp])
|
||||
gl_PREREQ_STRCASECMP
|
||||
fi
|
||||
if test $HAVE_STRNCASECMP = 0; then
|
||||
AC_LIBOBJ([strncasecmp])
|
||||
gl_PREREQ_STRNCASECMP
|
||||
fi
|
||||
gl_FUNC_STRCASESTR
|
||||
if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
|
||||
AC_LIBOBJ([strcasestr])
|
||||
gl_PREREQ_STRCASESTR
|
||||
fi
|
||||
gl_FUNC_STRCASESTR_SIMPLE
|
||||
if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
|
||||
AC_LIBOBJ([strcasestr])
|
||||
gl_PREREQ_STRCASESTR
|
||||
fi
|
||||
gl_STRING_MODULE_INDICATOR([strcasestr])
|
||||
gl_FUNC_STRDUP_POSIX
|
||||
if test $ac_cv_func_strdup = no || test $REPLACE_STRDUP = 1; then
|
||||
AC_LIBOBJ([strdup])
|
||||
@@ -231,6 +255,7 @@ AC_DEFUN([gl_INIT],
|
||||
fi
|
||||
gl_STRING_MODULE_INDICATOR([strdup])
|
||||
gl_HEADER_STRING_H
|
||||
gl_HEADER_STRINGS_H
|
||||
gl_HEADER_SYS_STAT_H
|
||||
AC_PROG_MKDIR_P
|
||||
gl_HEADER_SYS_TIME_H
|
||||
@@ -427,8 +452,12 @@ AC_DEFUN([gl_FILE_LIST], [
|
||||
lib/stdio.in.h
|
||||
lib/stdlib.in.h
|
||||
lib/str-two-way.h
|
||||
lib/strcasecmp.c
|
||||
lib/strcasestr.c
|
||||
lib/strdup.c
|
||||
lib/string.in.h
|
||||
lib/strings.in.h
|
||||
lib/strncasecmp.c
|
||||
lib/sys_stat.in.h
|
||||
lib/sys_time.in.h
|
||||
lib/sys_types.in.h
|
||||
@@ -478,8 +507,11 @@ AC_DEFUN([gl_FILE_LIST], [
|
||||
m4/stdint.m4
|
||||
m4/stdio_h.m4
|
||||
m4/stdlib_h.m4
|
||||
m4/strcase.m4
|
||||
m4/strcasestr.m4
|
||||
m4/strdup.m4
|
||||
m4/string_h.m4
|
||||
m4/strings_h.m4
|
||||
m4/sys_socket_h.m4
|
||||
m4/sys_stat_h.m4
|
||||
m4/sys_time_h.m4
|
||||
|
||||
45
gl/m4/strcase.m4
Normal file
45
gl/m4/strcase.m4
Normal file
@@ -0,0 +1,45 @@
|
||||
# strcase.m4 serial 11
|
||||
dnl Copyright (C) 2002, 2005-2014 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_STRCASE],
|
||||
[
|
||||
gl_FUNC_STRCASECMP
|
||||
gl_FUNC_STRNCASECMP
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRCASECMP],
|
||||
[
|
||||
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
|
||||
AC_CHECK_FUNCS([strcasecmp])
|
||||
if test $ac_cv_func_strcasecmp = no; then
|
||||
HAVE_STRCASECMP=0
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRNCASECMP],
|
||||
[
|
||||
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
|
||||
AC_CHECK_FUNCS([strncasecmp])
|
||||
if test $ac_cv_func_strncasecmp = yes; then
|
||||
HAVE_STRNCASECMP=1
|
||||
else
|
||||
HAVE_STRNCASECMP=0
|
||||
fi
|
||||
AC_CHECK_DECLS([strncasecmp])
|
||||
if test $ac_cv_have_decl_strncasecmp = no; then
|
||||
HAVE_DECL_STRNCASECMP=0
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strcasecmp.c.
|
||||
AC_DEFUN([gl_PREREQ_STRCASECMP], [
|
||||
:
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strncasecmp.c.
|
||||
AC_DEFUN([gl_PREREQ_STRNCASECMP], [
|
||||
:
|
||||
])
|
||||
142
gl/m4/strcasestr.m4
Normal file
142
gl/m4/strcasestr.m4
Normal file
@@ -0,0 +1,142 @@
|
||||
# strcasestr.m4 serial 21
|
||||
dnl Copyright (C) 2005, 2007-2014 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 Check that strcasestr is present and works.
|
||||
AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
|
||||
[
|
||||
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
|
||||
|
||||
dnl Persuade glibc <string.h> to declare strcasestr().
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
AC_REQUIRE([gl_FUNC_MEMCHR])
|
||||
AC_CHECK_FUNCS([strcasestr])
|
||||
if test $ac_cv_func_strcasestr = no; then
|
||||
HAVE_STRCASESTR=0
|
||||
else
|
||||
if test "$gl_cv_func_memchr_works" != yes; then
|
||||
REPLACE_STRCASESTR=1
|
||||
else
|
||||
dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092.
|
||||
AC_CACHE_CHECK([whether strcasestr works],
|
||||
[gl_cv_func_strcasestr_works_always],
|
||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <string.h> /* for strcasestr */
|
||||
#define P "_EF_BF_BD"
|
||||
#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
|
||||
#define NEEDLE P P P P P
|
||||
]], [[return !!strcasestr (HAYSTACK, NEEDLE);
|
||||
]])],
|
||||
[gl_cv_func_strcasestr_works_always=yes],
|
||||
[gl_cv_func_strcasestr_works_always=no],
|
||||
[dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
|
||||
dnl affected, since it uses different source code for strcasestr
|
||||
dnl than glibc.
|
||||
dnl Assume that it works on all other platforms, even if it is not
|
||||
dnl linear.
|
||||
AC_EGREP_CPP([Lucky user],
|
||||
[
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <features.h>
|
||||
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
|
||||
|| defined __UCLIBC__
|
||||
Lucky user
|
||||
#endif
|
||||
#elif defined __CYGWIN__
|
||||
#include <cygwin/version.h>
|
||||
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
|
||||
Lucky user
|
||||
#endif
|
||||
#else
|
||||
Lucky user
|
||||
#endif
|
||||
],
|
||||
[gl_cv_func_strcasestr_works_always="guessing yes"],
|
||||
[gl_cv_func_strcasestr_works_always="guessing no"])
|
||||
])
|
||||
])
|
||||
case "$gl_cv_func_strcasestr_works_always" in
|
||||
*yes) ;;
|
||||
*)
|
||||
REPLACE_STRCASESTR=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
]) # gl_FUNC_STRCASESTR_SIMPLE
|
||||
|
||||
dnl Additionally, check that strcasestr is efficient.
|
||||
AC_DEFUN([gl_FUNC_STRCASESTR],
|
||||
[
|
||||
AC_REQUIRE([gl_FUNC_STRCASESTR_SIMPLE])
|
||||
if test $HAVE_STRCASESTR = 1 && test $REPLACE_STRCASESTR = 0; then
|
||||
AC_CACHE_CHECK([whether strcasestr works in linear time],
|
||||
[gl_cv_func_strcasestr_linear],
|
||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <signal.h> /* for signal */
|
||||
#include <string.h> /* for strcasestr */
|
||||
#include <stdlib.h> /* for malloc */
|
||||
#include <unistd.h> /* for alarm */
|
||||
static void quit (int sig) { exit (sig + 128); }
|
||||
]], [[
|
||||
int result = 0;
|
||||
size_t m = 1000000;
|
||||
char *haystack = (char *) malloc (2 * m + 2);
|
||||
char *needle = (char *) malloc (m + 2);
|
||||
/* Failure to compile this test due to missing alarm is okay,
|
||||
since all such platforms (mingw) also lack strcasestr. */
|
||||
signal (SIGALRM, quit);
|
||||
alarm (5);
|
||||
/* Check for quadratic performance. */
|
||||
if (haystack && needle)
|
||||
{
|
||||
memset (haystack, 'A', 2 * m);
|
||||
haystack[2 * m] = 'B';
|
||||
haystack[2 * m + 1] = 0;
|
||||
memset (needle, 'A', m);
|
||||
needle[m] = 'B';
|
||||
needle[m + 1] = 0;
|
||||
if (!strcasestr (haystack, needle))
|
||||
result |= 1;
|
||||
}
|
||||
return result;
|
||||
]])],
|
||||
[gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
|
||||
[dnl Only glibc > 2.12 and cygwin > 1.7.7 are known to have a
|
||||
dnl strcasestr that works in linear time.
|
||||
AC_EGREP_CPP([Lucky user],
|
||||
[
|
||||
#include <features.h>
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
|
||||
&& !defined __UCLIBC__
|
||||
Lucky user
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
#include <cygwin/version.h>
|
||||
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
|
||||
Lucky user
|
||||
#endif
|
||||
#endif
|
||||
],
|
||||
[gl_cv_func_strcasestr_linear="guessing yes"],
|
||||
[gl_cv_func_strcasestr_linear="guessing no"])
|
||||
])
|
||||
])
|
||||
case "$gl_cv_func_strcasestr_linear" in
|
||||
*yes) ;;
|
||||
*)
|
||||
REPLACE_STRCASESTR=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
]) # gl_FUNC_STRCASESTR
|
||||
|
||||
# Prerequisites of lib/strcasestr.c.
|
||||
AC_DEFUN([gl_PREREQ_STRCASESTR], [
|
||||
:
|
||||
])
|
||||
52
gl/m4/strings_h.m4
Normal file
52
gl/m4/strings_h.m4
Normal file
@@ -0,0 +1,52 @@
|
||||
# Configure a replacement for <strings.h>.
|
||||
# serial 6
|
||||
|
||||
# Copyright (C) 2007, 2009-2014 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.
|
||||
|
||||
AC_DEFUN([gl_HEADER_STRINGS_H],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
|
||||
dnl once only, before all statements that occur in other macros.
|
||||
AC_REQUIRE([gl_HEADER_STRINGS_H_BODY])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
|
||||
[
|
||||
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
|
||||
|
||||
gl_CHECK_NEXT_HEADERS([strings.h])
|
||||
if test $ac_cv_header_strings_h = yes; then
|
||||
HAVE_STRINGS_H=1
|
||||
else
|
||||
HAVE_STRINGS_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_STRINGS_H])
|
||||
|
||||
dnl Check for declarations of anything we want to poison if the
|
||||
dnl corresponding gnulib module is not in use.
|
||||
gl_WARN_ON_USE_PREPARE([[
|
||||
/* Minix 3.1.8 has a bug: <sys/types.h> must be included before
|
||||
<strings.h>. */
|
||||
#include <sys/types.h>
|
||||
#include <strings.h>
|
||||
]], [ffs strcasecmp strncasecmp])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
|
||||
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_FFS=0; AC_SUBST([GNULIB_FFS])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_FFS=1; AC_SUBST([HAVE_FFS])
|
||||
HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
|
||||
HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP])
|
||||
])
|
||||
Reference in New Issue
Block a user