[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
strdup: Assume the function exists
From: |
Bruno Haible |
Subject: |
strdup: Assume the function exists |
Date: |
Fri, 14 Aug 2020 19:53:14 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; ) |
Nowadays, all platforms have strdup - or, on native Windows, _strdup - in libc.
Testing for it at configure time is therefore obselete. This test is
complicating the support for native Windows, so I'm removing it.
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.
diff --git a/doc/posix-functions/strdup.texi b/doc/posix-functions/strdup.texi
index 23f49c7..2f337aa 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{<string.h>} on some old platforms.
@end itemize
diff --git a/lib/unistr/u8-strdup.c b/lib/unistr/u8-strdup.c
index d3b4c55..663dacb 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 <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
diff --git a/m4/strdup.m4 b/m4/strdup.m4
index 2d1fcc4..6340209 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 619ec01..fecdc55 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 846baf2..a6381f7 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 d8da47e..598adbb 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])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- strdup: Assume the function exists,
Bruno Haible <=