changeset 9571:72670d754431

Fix memmem test for mingw. * modules/memmem-tests (configure.ac): Check for alarm. * tests/test-memmem.c (main): Avoid alarm on platforms that lack it. * doc/functions/memmem.texi: New file. * doc/gnulib.texi (Function Substitutes): Add memmem. Reported by Bruno Haible. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Sat, 05 Jan 2008 04:47:05 -0700
parents 6858419c4f22
children b3a856f09e7f
files ChangeLog doc/functions/memmem.texi doc/gnulib.texi modules/memmem-tests tests/test-memmem.c
diffstat 5 files changed, 48 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-01-05  Eric Blake  <ebb9@byu.net>
+
+	Fix memmem test for mingw.
+	* modules/memmem-tests (configure.ac): Check for alarm.
+	* tests/test-memmem.c (main): Avoid alarm on platforms that lack
+	it.
+	* doc/functions/memmem.texi: New file.
+	* doc/gnulib.texi (Function Substitutes): Add memmem.
+	Reported by Bruno Haible.
+
 2008-01-04  Bruno Haible  <bruno@clisp.org>
 
 	* m4/strcase.m4 (gl_FUNC_STRCASECMP, gl_FUNC_STRNCASECMP):
new file mode 100644
--- /dev/null
+++ b/doc/functions/memmem.texi
@@ -0,0 +1,28 @@
+@node memmem
+@section @code{memmem}
+@findex memmem
+
+Unspecified by POSIX, but comparable to @code{strstr}.
+
+Gnulib module: memmem
+
+Portability problems fixed by Gnulib:
+@itemize
+@item
+This function fails to return the start of the haystack for an empty
+needle on some platforms:
+Cygwin 1.5.x
+
+@item
+This function has quadratic instead of linear complexity on some
+platforms:
+glibc <= 2.6.1
+
+@item
+This function is missing on some platforms:
+Mingw, OpenBSD 4.0
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -17,7 +17,8 @@
 which is a library of common routines intended to be shared at the
 source level.
 
-Copyright @copyright{} 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software
+Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.1 or
@@ -1174,6 +1175,7 @@
 * memchr::
 * memcmp::
 * memcpy::
+* memmem::
 * memmove::
 * memset::
 * mkdir::
--- a/modules/memmem-tests
+++ b/modules/memmem-tests
@@ -4,6 +4,7 @@
 Depends-on:
 
 configure.ac:
+AC_CHECK_DECLS_ONCE([alarm])
 
 Makefile.am:
 TESTS += test-memmem
--- a/tests/test-memmem.c
+++ b/tests/test-memmem.c
@@ -37,9 +37,14 @@
 int
 main (int argc, char *argv[])
 {
+#if HAVE_DECL_ALARM
   /* Declare failure if test takes too long, by using default abort
-     caused by SIGALRM.  */
+     caused by SIGALRM.  All known platforms that lack alarm also lack
+     memmem, and the replacement memmem is known to not take too
+     long.  */
   alarm (10);
+#endif
+
   {
     const char input[] = "foo";
     const char *result = memmem (input, strlen (input), "", 0);