+2020-08-14 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
sys_random: Work around an uClibc bug.
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{<string.h>} on some old platforms.
@end itemize
/* Specification. */
#include "unistr.h"
-#if HAVE_STRDUP
-
-# include <string.h>
+#include <string.h>
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
-# strdup.m4 serial 13
+# strdup.m4 serial 14
dnl Copyright (C) 2002-2020 Free Software Foundation, Inc.
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
[
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
This module is obsolete. But you may want to use the strdup-posix module.
Files:
-lib/strdup.c
m4/strdup.m4
Depends-on:
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:
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
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])