From b25c432e30d9e69a81cfaeab355c4bdd0c20eb80 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 5 Jan 2008 04:47:05 -0700 Subject: [PATCH] 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 --- ChangeLog | 10 ++++++++++ doc/functions/memmem.texi | 28 ++++++++++++++++++++++++++++ doc/gnulib.texi | 4 +++- modules/memmem-tests | 1 + tests/test-memmem.c | 7 ++++++- 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 doc/functions/memmem.texi diff --git a/ChangeLog b/ChangeLog index bdf61e268..b4be78eca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-01-05 Eric Blake + + 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 * m4/strcase.m4 (gl_FUNC_STRCASECMP, gl_FUNC_STRNCASECMP): diff --git a/doc/functions/memmem.texi b/doc/functions/memmem.texi new file mode 100644 index 000000000..50d73fdea --- /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 diff --git a/doc/gnulib.texi b/doc/gnulib.texi index f46096b8c..deaf52823 100644 --- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -17,7 +17,8 @@ This manual is for GNU Gnulib (updated @value{UPDATED}), 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 @@ If you need this particular function, you may write to * memchr:: * memcmp:: * memcpy:: +* memmem:: * memmove:: * memset:: * mkdir:: diff --git a/modules/memmem-tests b/modules/memmem-tests index 3d79e477e..c9365e906 100644 --- a/modules/memmem-tests +++ b/modules/memmem-tests @@ -4,6 +4,7 @@ tests/test-memmem.c Depends-on: configure.ac: +AC_CHECK_DECLS_ONCE([alarm]) Makefile.am: TESTS += test-memmem diff --git a/tests/test-memmem.c b/tests/test-memmem.c index df3baef89..976f29313 100644 --- 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); -- 2.11.0