>From d0d7a45d51609f7a69dbeffbc11c086cfa267bb8 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?=
Date: Wed, 23 Jun 2010 00:42:54 +0100 Subject: [PATCH] memmem: rearrange memmem and expand memmem-simple modules Move all functional checks to memmem-simple so that one has a fully functional memmem by using just this module. Restrict the memmem module to performance checks only. Document exactly how the memmem and memmem-simple modules relate to each other. * m4/memmem.m4 (gl_FUNC_MEMMEM_SIMPLE, gl_FUNC_MEMMEM): Move the empty needle check from the memmem module to memmem-simple. Also expand the empty needle check to ensure the correct pointer is returned, not just a non NULL pointer. * doc/glibc-functions/memmem.texi: Rearrange the portability documentation to correlate with the rearranged checks. --- ChangeLog | 14 ++++++++++ doc/glibc-functions/memmem.texi | 13 ++++++--- m4/memmem.m4 | 53 +++++++++++++++++++++++++++++++------- 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 182d7b2..ab40f8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-06-23 Pádraig Brady + + memmem, memmem-simple: reorganize and expand empty needle check + * m4/memmem.m4 (gl_FUNC_MEMMEM_SIMPLE, gl_FUNC_MEMMEM): Move all + functional checks to memmem-simple so that one has a fully functional + memmem by using just this module. + Restrict the performance only check to the memmem module. + Also expand the empty needle check to ensure the correct + pointer is returned, not just a non NULL pointer. + * doc/glibc-functions/memmem.texi: Rearrange the portability + documentation to correlate with the rearranged checks. + Clarify exactly how the memmem and memmem-simple modules + relate to each other. + 2010-06-22 Eric Blake memmem: slight optimization diff --git a/doc/glibc-functions/memmem.texi b/doc/glibc-functions/memmem.texi index c7e3d73..9515d2e 100644 --- a/doc/glibc-functions/memmem.texi +++ b/doc/glibc-functions/memmem.texi @@ -4,6 +4,10 @@ Gnulib module: memmem or memmem-simple +Both modules implement the same replacement for the @code{memmem} function +with the memmem module providing a replacement on more platforms where +the existing @code{memmem} function has a quadratic worst-case complexity. + Portability problems fixed by either Gnulib module @code{memmem-simple} or @code{memmem}: @itemize @@ -13,18 +17,19 @@ MacOS X 10.3, FreeBSD 5.2.1, OpenBSD 4.0, AIX 4.3.2, HP-UX 11, IRIX 6.5, OSF/1 5 @item This function has reversed arguments on some older platforms: Linux libc 5.0.9 address@hidden itemize - -Portability problems fixed by Gnulib module @code{memmem}: address@hidden @item This function returns incorrect values in some cases, such as when given an empty needle: glibc <= 2.0, Cygwin 1.5.x. address@hidden itemize + +Performance problems fixed by Gnulib module @code{memmem}: address@hidden @item This function has quadratic instead of linear worst-case complexity on some platforms: glibc 2.8, FreeBSD 6.2, NetBSD 3.0, AIX 5.1, Cygwin 1.5.x. +Note for small needles the replacement may be slower. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/memmem.m4 b/m4/memmem.m4 index c6506ee..7a134c6 100644 --- a/m4/memmem.m4 +++ b/m4/memmem.m4 @@ -1,11 +1,11 @@ -# memmem.m4 serial 14 +# memmem.m4 serial 15 dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010 Free Software dnl 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 memmem is present. +dnl Check that memmem is present and functional. AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], [ dnl Persuade glibc