strstr, strcasestr: replace on platforms with broken memchr
[gnulib.git] / m4 / strcasestr.m4
index e1e5390..d641958 100644 (file)
@@ -1,20 +1,25 @@
-# strcasestr.m4 serial 12
-dnl Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+# strcasestr.m4 serial 13
+dnl Copyright (C) 2005, 2007, 2008, 2009 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.
+dnl Check that strcasestr is present and works.
 AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
 [
   dnl Persuade glibc <string.h> to declare strcasestr().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_MEMCHR])
   AC_REPLACE_FUNCS([strcasestr])
   if test $ac_cv_func_strcasestr = no; then
     HAVE_STRCASESTR=0
     gl_PREREQ_STRCASESTR
+  elif test "$gl_cv_func_memchr_works" != yes; then
+    REPLACE_STRCASESTR=1
+    AC_LIBOBJ([strcasestr])
+    gl_PREREQ_STRCASESTR
   fi
 ]) # gl_FUNC_STRCASESTR_SIMPLE