>From 707090c9ed6a16bc4b152be300578761e34b2bed Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 8 Jul 2020 03:19:54 +0200 Subject: [PATCH 2/3] memchr: Remove support for some very old platforms. * m4/memchr-obsolete.m4: Remove file. * modules/memchr-obsolete: Remove file. * m4/memchr.m4 (gl_FUNC_MEMCHR): Assume module 'memchr-obsolete' is absent. Don't define HAVE_MEMCHR. * lib/string.in.h (memchr): Assume HAVE_MEMCHR is 1. * modules/memchr (Depends-on): Remove memchr-obsolete. (configure.ac): Assume HAVE_MEMCHR is 1. * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Don't initialize HAVE_MEMCHR. * modules/string (Makefile.am): Don't substitute HAVE_MEMCHR. * doc/posix-functions/memchr.texi: Don't mention module 'memchr-obsolete'. * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Assume HAVE_MEMCHR is 1. * m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Assume HAVE_MEMCHR is 1. * modules/strnlen (Depends-on): Remove memchr-obsolete. --- ChangeLog | 17 +++++++++++ doc/posix-functions/memchr.texi | 10 ++----- lib/string.in.h | 5 ---- m4/memchr-obsolete.m4 | 11 ------- m4/memchr.m4 | 66 +++++++++++++++++------------------------ m4/strcasestr.m4 | 4 +-- m4/string_h.m4 | 3 +- m4/strstr.m4 | 4 +-- modules/memchr | 3 +- modules/memchr-obsolete | 28 ----------------- modules/string | 1 - modules/strnlen | 1 - 12 files changed, 53 insertions(+), 100 deletions(-) delete mode 100644 m4/memchr-obsolete.m4 delete mode 100644 modules/memchr-obsolete diff --git a/ChangeLog b/ChangeLog index 8d0ccf5..a1642ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2020-07-07 Bruno Haible + memchr: Remove support for some very old platforms. + * m4/memchr-obsolete.m4: Remove file. + * modules/memchr-obsolete: Remove file. + * m4/memchr.m4 (gl_FUNC_MEMCHR): Assume module 'memchr-obsolete' is + absent. Don't define HAVE_MEMCHR. + * lib/string.in.h (memchr): Assume HAVE_MEMCHR is 1. + * modules/memchr (Depends-on): Remove memchr-obsolete. + (configure.ac): Assume HAVE_MEMCHR is 1. + * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Don't initialize + HAVE_MEMCHR. + * modules/string (Makefile.am): Don't substitute HAVE_MEMCHR. + * doc/posix-functions/memchr.texi: Don't mention module + 'memchr-obsolete'. + * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Assume HAVE_MEMCHR is 1. + * m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Assume HAVE_MEMCHR is 1. + * modules/strnlen (Depends-on): Remove memchr-obsolete. + dup2: Remove support for some very old platforms. * m4/dup2-obsolete.m4: Remove file. * modules/dup2-obsolete: Remove file. diff --git a/doc/posix-functions/memchr.texi b/doc/posix-functions/memchr.texi index 38d5b66..5ceb71f 100644 --- a/doc/posix-functions/memchr.texi +++ b/doc/posix-functions/memchr.texi @@ -4,9 +4,9 @@ POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/memchr.html} -Gnulib module: memchr or memchr-obsolete +Gnulib module: memchr -Portability problems fixed by either Gnulib module @code{memchr} or @code{memchr-obsolete}: +Portability problems fixed by Gnulib: @itemize @item This function dereferences too much memory on some platforms: @@ -17,12 +17,6 @@ of an @code{unsigned char} on some platforms: Android 5.0. @end itemize -Portability problems fixed by Gnulib module @code{memchr-obsolete}: -@itemize -@item -This function is missing on some older platforms. -@end itemize - Portability problems not fixed by Gnulib: @itemize @end itemize diff --git a/lib/string.in.h b/lib/string.in.h index 77ccf94..c18efa7 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -134,11 +134,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else -# if ! @HAVE_MEMCHR@ -_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif /* On some systems, this function is defined as an overloaded function: extern "C" { const void * std::memchr (const void *, int, size_t); } extern "C++" { void * std::memchr (void *, int, size_t); } */ diff --git a/m4/memchr-obsolete.m4 b/m4/memchr-obsolete.m4 deleted file mode 100644 index 7305a77..0000000 --- a/m4/memchr-obsolete.m4 +++ /dev/null @@ -1,11 +0,0 @@ -# memchr-obsolete.m4 serial 1 -dnl Copyright (C) 2011-2020 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_MEMCHR_OBSOLETE], -[ - dnl The real code is in memchr.m4. - : -]) diff --git a/m4/memchr.m4 b/m4/memchr.m4 index 91eec88..81e8f98 100644 --- a/m4/memchr.m4 +++ b/m4/memchr.m4 @@ -1,4 +1,4 @@ -# memchr.m4 serial 15 +# memchr.m4 serial 16 dnl Copyright (C) 2002-2004, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,26 +14,17 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], AC_CHECK_FUNCS_ONCE([mprotect]) AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ - dnl These days, we assume memchr is present. But if support for old - dnl platforms is desired: - AC_CHECK_FUNCS_ONCE([memchr]) - if test $ac_cv_func_memchr = no; then - HAVE_MEMCHR=0 - fi - ]) - if test $HAVE_MEMCHR = 1; then - # Detect platform-specific bugs in some versions of glibc: - # memchr should not dereference anything with length 0 - # https://bugzilla.redhat.com/show_bug.cgi?id=499689 - # memchr should not dereference overestimated length after a match - # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 - # https://sourceware.org/bugzilla/show_bug.cgi?id=10162 - # memchr should cast the second argument to 'unsigned char'. - # This bug exists in Android 4.3. - # Assume that memchr works on platforms that lack mprotect. - AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + # Detect platform-specific bugs in some versions of glibc: + # memchr should not dereference anything with length 0 + # https://bugzilla.redhat.com/show_bug.cgi?id=499689 + # memchr should not dereference overestimated length after a match + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 + # https://sourceware.org/bugzilla/show_bug.cgi?id=10162 + # memchr should cast the second argument to 'unsigned char'. + # This bug exists in Android 4.3. + # Assume that memchr works on platforms that lack mprotect. + AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include #if HAVE_SYS_MMAN_H # include @@ -87,23 +78,22 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], } return result; ]])], - [gl_cv_func_memchr_works=yes], - [gl_cv_func_memchr_works=no], - [case "$host_os" in - # Guess no on Android. - linux*-android*) gl_cv_func_memchr_works="guessing no" ;; - # Guess yes on native Windows. - mingw*) gl_cv_func_memchr_works="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;; - esac - ]) - ]) - case "$gl_cv_func_memchr_works" in - *yes) ;; - *) REPLACE_MEMCHR=1 ;; - esac - fi + [gl_cv_func_memchr_works=yes], + [gl_cv_func_memchr_works=no], + [case "$host_os" in + # Guess no on Android. + linux*-android*) gl_cv_func_memchr_works="guessing no" ;; + # Guess yes on native Windows. + mingw*) gl_cv_func_memchr_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) + case "$gl_cv_func_memchr_works" in + *yes) ;; + *) REPLACE_MEMCHR=1 ;; + esac ]) # Prerequisites of lib/memchr.c. diff --git a/m4/strcasestr.m4 b/m4/strcasestr.m4 index 4c2275f..ee22873 100644 --- a/m4/strcasestr.m4 +++ b/m4/strcasestr.m4 @@ -1,4 +1,4 @@ -# strcasestr.m4 serial 25 +# strcasestr.m4 serial 26 dnl Copyright (C) 2005, 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE], if test $ac_cv_func_strcasestr = no; then HAVE_STRCASESTR=0 else - if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then + if test $REPLACE_MEMCHR = 1; then REPLACE_STRCASESTR=1 else dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092 diff --git a/m4/string_h.m4 b/m4/string_h.m4 index cc51337..516b346 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -5,7 +5,7 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 23 +# serial 24 # Written by Paul Eggert. @@ -87,7 +87,6 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO]) HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) - HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR]) HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) diff --git a/m4/strstr.m4 b/m4/strstr.m4 index a2ec337..5291107 100644 --- a/m4/strstr.m4 +++ b/m4/strstr.m4 @@ -1,4 +1,4 @@ -# strstr.m4 serial 21 +# strstr.m4 serial 22 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], [ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MEMCHR]) - if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then + if test $REPLACE_MEMCHR = 1; then REPLACE_STRSTR=1 else dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092 diff --git a/modules/memchr b/modules/memchr index ed80e0c..3a413a2 100644 --- a/modules/memchr +++ b/modules/memchr @@ -10,11 +10,10 @@ m4/mmap-anon.m4 Depends-on: extensions string -memchr-obsolete configure.ac: gl_FUNC_MEMCHR -if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then +if test $REPLACE_MEMCHR = 1; then AC_LIBOBJ([memchr]) gl_PREREQ_MEMCHR fi diff --git a/modules/memchr-obsolete b/modules/memchr-obsolete deleted file mode 100644 index c1a6e43..0000000 --- a/modules/memchr-obsolete +++ /dev/null @@ -1,28 +0,0 @@ -Description: -memchr() function for old platforms. - -Status: -obsolete - -Notice: -This module is obsolete. - -Files: -m4/memchr-obsolete.m4 - -Depends-on: -memchr - -configure.ac: -gl_FUNC_MEMCHR_OBSOLETE - -Makefile.am: - -Include: - - -License: -LGPLv2+ - -Maintainer: -all diff --git a/modules/string b/modules/string index 67209d5..bc87bc8 100644 --- a/modules/string +++ b/modules/string @@ -73,7 +73,6 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ - -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ diff --git a/modules/strnlen b/modules/strnlen index c781671..ea5658a 100644 --- a/modules/strnlen +++ b/modules/strnlen @@ -8,7 +8,6 @@ m4/strnlen.m4 Depends-on: string extensions -memchr-obsolete [test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1] configure.ac: gl_FUNC_STRNLEN -- 2.7.4