diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-01-14 15:35:48 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-01-14 15:35:48 +0100 |
commit | 4dc80d0fcd34b7b36a64a007a8a6b81b1b9c136e (patch) | |
tree | 7e265478c7cccfb94b6cc626f13cb69f2c71e64e /lgl | |
parent | a033a9d515ccdcdb3a60a757d916059b9c8bb6a0 (diff) | |
download | gnutls-4dc80d0fcd34b7b36a64a007a8a6b81b1b9c136e.tar.gz |
Use gnulib's memmem-simple instead.
Diffstat (limited to 'lgl')
-rw-r--r-- | lgl/Makefile.am | 6 | ||||
-rw-r--r-- | lgl/m4/alloca.m4 | 8 | ||||
-rw-r--r-- | lgl/m4/gnulib-cache.m4 | 4 | ||||
-rw-r--r-- | lgl/m4/gnulib-comp.m4 | 2 | ||||
-rw-r--r-- | lgl/m4/memmem.m4 | 24 | ||||
-rw-r--r-- | lgl/string.in.h | 32 |
6 files changed, 50 insertions, 26 deletions
diff --git a/lgl/Makefile.am b/lgl/Makefile.am index e4146a26de..51974b107b 100644 --- a/lgl/Makefile.am +++ b/lgl/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=liblgnu --source-base=lgl --m4-base=lgl/m4 --doc-base=doc --aux-dir=build-aux --lgpl=2 --libtool --macro-prefix=lgl crypto/gc crypto/gc-arcfour crypto/gc-arctwo crypto/gc-camellia crypto/gc-des crypto/gc-hmac-md5 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-pbkdf2-sha1 crypto/gc-random crypto/gc-rijndael crypto/gc-sha1 gettext memmem memmove minmax read-file snprintf socklen stdint strverscmp sys_socket sys_stat time_r unistd vasprintf +# Reproduce by: gnulib-tool --import --dir=. --lib=liblgnu --source-base=lgl --m4-base=lgl/m4 --doc-base=doc --aux-dir=build-aux --lgpl=2 --libtool --macro-prefix=lgl crypto/gc crypto/gc-arcfour crypto/gc-arctwo crypto/gc-camellia crypto/gc-des crypto/gc-hmac-md5 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-pbkdf2-sha1 crypto/gc-random crypto/gc-rijndael crypto/gc-sha1 gettext memmem-simple memmove minmax read-file snprintf socklen stdint strverscmp sys_socket sys_stat time_r unistd vasprintf AUTOMAKE_OPTIONS = 1.5 gnits @@ -248,14 +248,14 @@ EXTRA_liblgnu_la_SOURCES += memcmp.c ## end gnulib module memcmp -## begin gnulib module memmem +## begin gnulib module memmem-simple EXTRA_DIST += memmem.c EXTRA_liblgnu_la_SOURCES += memmem.c -## end gnulib module memmem +## end gnulib module memmem-simple ## begin gnulib module memmove diff --git a/lgl/m4/alloca.m4 b/lgl/m4/alloca.m4 index eb62e0e7a5..95f54a6d48 100644 --- a/lgl/m4/alloca.m4 +++ b/lgl/m4/alloca.m4 @@ -1,5 +1,5 @@ -# alloca.m4 serial 7 -dnl Copyright (C) 2002-2004, 2006 Free Software Foundation, Inc. +# alloca.m4 serial 8 +dnl Copyright (C) 2002-2004, 2006, 2007 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. @@ -39,10 +39,6 @@ AC_DEFUN([gl_FUNC_ALLOCA], ALLOCA_H=alloca.h fi AC_SUBST([ALLOCA_H]) - - AC_DEFINE(HAVE_ALLOCA_H, 1, - [Define HAVE_ALLOCA_H for backward compatibility with older code - that includes <alloca.h> only if HAVE_ALLOCA_H is defined.]) ]) # Prerequisites of lib/alloca.c. diff --git a/lgl/m4/gnulib-cache.m4 b/lgl/m4/gnulib-cache.m4 index 8bfc9736e7..d181fda0c9 100644 --- a/lgl/m4/gnulib-cache.m4 +++ b/lgl/m4/gnulib-cache.m4 @@ -15,11 +15,11 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=liblgnu --source-base=lgl --m4-base=lgl/m4 --doc-base=doc --aux-dir=build-aux --lgpl=2 --libtool --macro-prefix=lgl crypto/gc crypto/gc-arcfour crypto/gc-arctwo crypto/gc-camellia crypto/gc-des crypto/gc-hmac-md5 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-pbkdf2-sha1 crypto/gc-random crypto/gc-rijndael crypto/gc-sha1 gettext memmem memmove minmax read-file snprintf socklen stdint strverscmp sys_socket sys_stat time_r unistd vasprintf +# gnulib-tool --import --dir=. --lib=liblgnu --source-base=lgl --m4-base=lgl/m4 --doc-base=doc --aux-dir=build-aux --lgpl=2 --libtool --macro-prefix=lgl crypto/gc crypto/gc-arcfour crypto/gc-arctwo crypto/gc-camellia crypto/gc-des crypto/gc-hmac-md5 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-pbkdf2-sha1 crypto/gc-random crypto/gc-rijndael crypto/gc-sha1 gettext memmem-simple memmove minmax read-file snprintf socklen stdint strverscmp sys_socket sys_stat time_r unistd vasprintf # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) -gl_MODULES([crypto/gc crypto/gc-arcfour crypto/gc-arctwo crypto/gc-camellia crypto/gc-des crypto/gc-hmac-md5 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-pbkdf2-sha1 crypto/gc-random crypto/gc-rijndael crypto/gc-sha1 gettext memmem memmove minmax read-file snprintf socklen stdint strverscmp sys_socket sys_stat time_r unistd vasprintf]) +gl_MODULES([crypto/gc crypto/gc-arcfour crypto/gc-arctwo crypto/gc-camellia crypto/gc-des crypto/gc-hmac-md5 crypto/gc-md2 crypto/gc-md4 crypto/gc-md5 crypto/gc-pbkdf2-sha1 crypto/gc-random crypto/gc-rijndael crypto/gc-sha1 gettext memmem-simple memmove minmax read-file snprintf socklen stdint strverscmp sys_socket sys_stat time_r unistd vasprintf]) gl_AVOID([]) gl_SOURCE_BASE([lgl]) gl_M4_BASE([lgl/m4]) diff --git a/lgl/m4/gnulib-comp.m4 b/lgl/m4/gnulib-comp.m4 index 273922a4e2..5b51020aa1 100644 --- a/lgl/m4/gnulib-comp.m4 +++ b/lgl/m4/gnulib-comp.m4 @@ -78,7 +78,7 @@ AC_DEFUN([lgl_INIT], AC_SUBST([LTLIBINTL]) gl_FUNC_MEMCHR gl_FUNC_MEMCMP - gl_FUNC_MEMMEM + gl_FUNC_MEMMEM_SIMPLE gl_STRING_MODULE_INDICATOR([memmem]) gl_FUNC_MEMMOVE gl_MINMAX diff --git a/lgl/m4/memmem.m4 b/lgl/m4/memmem.m4 index 9767354ad2..7f3aa3c70f 100644 --- a/lgl/m4/memmem.m4 +++ b/lgl/m4/memmem.m4 @@ -1,10 +1,11 @@ -# memmem.m4 serial 7 +# memmem.m4 serial 9 dnl Copyright (C) 2002, 2003, 2004, 2007, 2008 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_FUNC_MEMMEM], +dnl Check that memmem is present. +AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], [ dnl Persuade glibc <string.h> to declare memmem(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) @@ -14,7 +15,15 @@ AC_DEFUN([gl_FUNC_MEMMEM], AC_CHECK_DECLS_ONCE(memmem) if test $ac_cv_have_decl_memmem = no; then HAVE_DECL_MEMMEM=0 - else + fi + gl_PREREQ_MEMMEM +]) # gl_FUNC_MEMMEM_SIMPLE + +dnl Additionally, check that memmem is efficient and handles empty needles. +AC_DEFUN([gl_FUNC_MEMMEM], +[ + AC_REQUIRE([gl_FUNC_MEMMEM_SIMPLE]) + if test $ac_cv_have_decl_memmem = yes; then AC_CACHE_CHECK([whether memmem works in linear time], [gl_cv_func_memmem_works], [AC_RUN_IFELSE([AC_LANG_PROGRAM([ @@ -28,6 +37,7 @@ AC_DEFUN([gl_FUNC_MEMMEM], /* Failure to compile this test due to missing alarm is okay, since all such platforms (mingw) also lack memmem. */ alarm (5); + /* Check for quadratic performance. */ if (haystack && needle) { memset (haystack, 'A', 2 * m); @@ -36,18 +46,18 @@ AC_DEFUN([gl_FUNC_MEMMEM], needle[m] = 'B'; result = memmem (haystack, 2 * m + 1, needle, m + 1); } + /* Check for empty needle behavior. */ return !result || !memmem ("a", 1, 0, 0);]])], [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no], [dnl pessimistically assume the worst, since even glibc 2.6.1 dnl has quadratic complexity in its memmem - gl_cv_func_memmem_works=no])]) - if test $gl_cv_func_memmem_works = no; then + gl_cv_func_memmem_works="guessing no"])]) + if test "$gl_cv_func_memmem_works" != yes; then REPLACE_MEMMEM=1 AC_LIBOBJ([memmem]) fi fi - gl_PREREQ_MEMMEM -]) +]) # gl_FUNC_MEMMEM # Prerequisites of lib/memmem.c. AC_DEFUN([gl_PREREQ_MEMMEM], [:]) diff --git a/lgl/string.in.h b/lgl/string.in.h index 779bb6c0cf..eb6a20f876 100644 --- a/lgl/string.in.h +++ b/lgl/string.in.h @@ -1,6 +1,6 @@ /* A GNU-like <string.h>. - Copyright (C) 1995-1996, 2001-2007 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -25,6 +25,18 @@ #define _GL_STRING_H +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +# define __attribute__(Spec) /* empty */ +# endif +/* The attribute __pure__ was added in gcc 2.96. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) +# define __pure__ /* empty */ +# endif +#endif + + /* The definition of GL_LINK_WARNING is copied here. */ @@ -40,7 +52,8 @@ extern "C" { # endif # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@ extern void *memmem (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len); + void const *__needle, size_t __needle_len) + __attribute__ ((__pure__)); # endif #elif defined GNULIB_POSIXCHECK # undef memmem @@ -68,7 +81,8 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src, /* Search backwards through a block for a byte (specified as an int). */ #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ -extern void *memrchr (void const *, int, size_t); +extern void *memrchr (void const *, int, size_t) + __attribute__ ((__pure__)); # endif #elif defined GNULIB_POSIXCHECK # undef memrchr @@ -121,7 +135,8 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src, /* Find the first occurrence of C in S or the final NUL byte. */ #if @GNULIB_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@ -extern char *strchrnul (char const *__s, int __c_in); +extern char *strchrnul (char const *__s, int __c_in) + __attribute__ ((__pure__)); # endif #elif defined GNULIB_POSIXCHECK # undef strchrnul @@ -166,7 +181,8 @@ extern char *strndup (char const *__string, size_t __n); return MAXLEN. */ #if @GNULIB_STRNLEN@ # if ! @HAVE_DECL_STRNLEN@ -extern size_t strnlen (char const *__string, size_t __maxlen); +extern size_t strnlen (char const *__string, size_t __maxlen) + __attribute__ ((__pure__)); # endif #elif defined GNULIB_POSIXCHECK # undef strnlen @@ -192,7 +208,8 @@ extern size_t strnlen (char const *__string, size_t __maxlen); /* Find the first occurrence in S of any character in ACCEPT. */ #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ -extern char *strpbrk (char const *__s, char const *__accept); +extern char *strpbrk (char const *__s, char const *__accept) + __attribute__ ((__pure__)); # endif # if defined GNULIB_POSIXCHECK /* strpbrk() assumes the second argument is a list of single-byte characters. @@ -288,7 +305,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim); /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive comparison. */ #if ! @HAVE_STRCASESTR@ -extern char *strcasestr (const char *haystack, const char *needle); +extern char *strcasestr (const char *haystack, const char *needle) + __attribute__ ((__pure__)); #endif #if defined GNULIB_POSIXCHECK /* strcasestr() does not work with multibyte strings: |