From efbd8572b569730fefffd469a123ca864baeae60 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 14 Aug 2020 19:51:56 +0200 Subject: [PATCH] strdup: Assume the function exists. * m4/strdup.m4 (gl_FUNC_STRDUP, gl_FUNC_STRDUP_POSIX): Don't test whether strdup exists. * modules/strdup (Files): Remove lib/strdup.c. (configure.ac): Don't compile strdup.c. * modules/strdup-posix (Depends-on, configure.ac): Don't test ac_cv_func_strdup. * doc/posix-functions/strdup.texi: Update. * lib/unistr/u8-strdup.c: Assume HAVE_STRDUP is 1. * modules/unistr/u8-strdup (Files): Remove lib/unistr/u-strdup.h. (Depends-on): Remove unistr/u8-strlen. --- ChangeLog | 14 ++++++++++++++ doc/posix-functions/strdup.texi | 2 -- lib/unistr/u8-strdup.c | 13 +------------ m4/strdup.m4 | 10 +++------- modules/strdup | 5 ----- modules/strdup-posix | 4 ++-- modules/unistr/u8-strdup | 2 -- 7 files changed, 20 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 884be61ee1..8b0f287063 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2020-08-14 Bruno Haible + + strdup: Assume the function exists. + * m4/strdup.m4 (gl_FUNC_STRDUP, gl_FUNC_STRDUP_POSIX): Don't test + whether strdup exists. + * modules/strdup (Files): Remove lib/strdup.c. + (configure.ac): Don't compile strdup.c. + * modules/strdup-posix (Depends-on, configure.ac): Don't test + ac_cv_func_strdup. + * doc/posix-functions/strdup.texi: Update. + * lib/unistr/u8-strdup.c: Assume HAVE_STRDUP is 1. + * modules/unistr/u8-strdup (Files): Remove lib/unistr/u-strdup.h. + (Depends-on): Remove unistr/u8-strlen. + 2020-08-13 Bruno Haible sys_random: Work around an uClibc bug. diff --git a/doc/posix-functions/strdup.texi b/doc/posix-functions/strdup.texi index 23f49c7270..2f337aaec1 100644 --- a/doc/posix-functions/strdup.texi +++ b/doc/posix-functions/strdup.texi @@ -9,8 +9,6 @@ Gnulib module: strdup or strdup-posix Portability problems fixed by either Gnulib module @code{strdup} or @code{strdup-posix}: @itemize @item -This function is missing on some old platforms. -@item This function has no prototype in @code{} on some old platforms. @end itemize diff --git a/lib/unistr/u8-strdup.c b/lib/unistr/u8-strdup.c index d3b4c55e6d..663dacbc9e 100644 --- a/lib/unistr/u8-strdup.c +++ b/lib/unistr/u8-strdup.c @@ -20,21 +20,10 @@ /* Specification. */ #include "unistr.h" -#if HAVE_STRDUP - -# include +#include uint8_t * u8_strdup (const uint8_t *s) { return (uint8_t *) strdup ((const char *) s); } - -#else - -# define FUNC u8_strdup -# define UNIT uint8_t -# define U_STRLEN u8_strlen -# include "u-strdup.h" - -#endif diff --git a/m4/strdup.m4 b/m4/strdup.m4 index 2d1fcc416a..6340209422 100644 --- a/m4/strdup.m4 +++ b/m4/strdup.m4 @@ -1,4 +1,4 @@ -# strdup.m4 serial 13 +# strdup.m4 serial 14 dnl Copyright (C) 2002-2020 Free Software Foundation, Inc. @@ -9,7 +9,6 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRDUP], [ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_CHECK_FUNCS_ONCE([strdup]) AC_CHECK_DECLS_ONCE([strdup]) if test $ac_cv_have_decl_strdup = no; then HAVE_DECL_STRDUP=0 @@ -20,11 +19,8 @@ AC_DEFUN([gl_FUNC_STRDUP_POSIX], [ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) - AC_CHECK_FUNCS_ONCE([strdup]) - if test $ac_cv_func_strdup = yes; then - if test $gl_cv_func_malloc_posix != yes; then - REPLACE_STRDUP=1 - fi + if test $gl_cv_func_malloc_posix != yes; then + REPLACE_STRDUP=1 fi AC_CHECK_DECLS_ONCE([strdup]) if test $ac_cv_have_decl_strdup = no; then diff --git a/modules/strdup b/modules/strdup index 619ec01e93..fecdc554ba 100644 --- a/modules/strdup +++ b/modules/strdup @@ -8,7 +8,6 @@ Notice: This module is obsolete. But you may want to use the strdup-posix module. Files: -lib/strdup.c m4/strdup.m4 Depends-on: @@ -16,10 +15,6 @@ string configure.ac: gl_FUNC_STRDUP -if test $ac_cv_func_strdup = no; then - AC_LIBOBJ([strdup]) - gl_PREREQ_STRDUP -fi gl_STRING_MODULE_INDICATOR([strdup]) Makefile.am: diff --git a/modules/strdup-posix b/modules/strdup-posix index 846baf2eb8..a6381f7ac3 100644 --- a/modules/strdup-posix +++ b/modules/strdup-posix @@ -7,11 +7,11 @@ m4/strdup.m4 Depends-on: string -malloc-posix [test $ac_cv_func_strdup = no || test $REPLACE_STRDUP = 1] +malloc-posix [test $REPLACE_STRDUP = 1] configure.ac: gl_FUNC_STRDUP_POSIX -if test $ac_cv_func_strdup = no || test $REPLACE_STRDUP = 1; then +if test $REPLACE_STRDUP = 1; then AC_LIBOBJ([strdup]) gl_PREREQ_STRDUP fi diff --git a/modules/unistr/u8-strdup b/modules/unistr/u8-strdup index d8da47ea4f..598adbb10d 100644 --- a/modules/unistr/u8-strdup +++ b/modules/unistr/u8-strdup @@ -3,11 +3,9 @@ Copy UTF-8 string. Files: lib/unistr/u8-strdup.c -lib/unistr/u-strdup.h Depends-on: unistr/base -unistr/u8-strlen configure.ac: AC_CHECK_FUNCS_ONCE([strdup]) -- 2.39.5