summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-09-21 14:54:54 +0200
committerBruno Haible <bruno@clisp.org>2008-09-21 14:54:54 +0200
commitcfa381fc27ccee5fefcab6be96596f63d84d1fa5 (patch)
tree8608e44535e7b6a847463ef072e06608fe50dc52
parent1d6dbd3f560572a6a627beb9e17f53834ca7fa38 (diff)
downloadgnulib-cfa381fc27ccee5fefcab6be96596f63d84d1fa5.tar.gz
New module 'strdup-posix'.
-rw-r--r--ChangeLog17
-rwxr-xr-xMODULES.html.sh1
-rw-r--r--doc/posix-functions/strdup.texi10
-rw-r--r--lib/string.in.h6
-rw-r--r--m4/strdup.m422
-rw-r--r--m4/string_h.m49
-rw-r--r--modules/getpass1
-rw-r--r--modules/strdup1
-rw-r--r--modules/strdup-posix25
-rw-r--r--modules/string1
10 files changed, 81 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index e5acd44e0b..70dee6f8a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2008-09-21 Bruno Haible <bruno@clisp.org>
+
+ * modules/getpass (Depends-on): Add strdup-posix.
+
+ New module 'strdup-posix'.
+ * modules/strdup-posix: New file.
+ * m4/strdup.m4 (gl_FUNC_STRDUP_POSIX): New macro.
+ * lib/string.in.h (strdup): Replace if REPLACE_STRDUP is 1.
+ * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Initialize
+ REPLACE_STRDUP.
+ * modules/string (Makefile.am): Substitute REPLACE_STRDUP.
+ * doc/posix-functions/strdup.texi: Mention module strdup-posix.
+ * MODULES.html.sh (Support for systems lacking POSIX:2001): Add
+ strdup-posix.
+
+ * modules/strdup (Depends-on): Remove malloc-posix.
+
2008-09-20 Bruno Haible <bruno@clisp.org>
* lib/fstrcmp.c: Add data about branch probabilities, from Ralf
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 26dd7d4a79..79b0d2e61b 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2121,6 +2121,7 @@ func_all_modules ()
func_module sleep
func_module snprintf-posix
func_module sprintf-posix
+ func_module strdup-posix
func_module string
func_module strings
func_module tempname
diff --git a/doc/posix-functions/strdup.texi b/doc/posix-functions/strdup.texi
index 4f30f45231..a505546c5e 100644
--- a/doc/posix-functions/strdup.texi
+++ b/doc/posix-functions/strdup.texi
@@ -4,9 +4,9 @@
POSIX specification: @url{http://www.opengroup.org/susv3xsh/strdup.html}
-Gnulib module: strdup
+Gnulib module: strdup or strdup-posix
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{strdup} or @code{strdup-posix}:
@itemize
@item
This function is missing on some old platforms.
@@ -14,10 +14,14 @@ This function is missing on some old platforms.
This function has no prototype in @code{<string.h>} on some old platforms.
@end itemize
-Portability problems not fixed by Gnulib:
+Portability problems fixed by Gnulib module @code{strdup-posix}:
@itemize
@item
Upon failure, the function does not set @code{errno} to @code{ENOMEM} on
some platforms:
mingw.
@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
diff --git a/lib/string.in.h b/lib/string.in.h
index a193d8932e..c8845671ba 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -167,7 +167,11 @@ extern char *strchrnul (char const *__s, int __c_in)
/* Duplicate S, returning an identical malloc'd string. */
#if @GNULIB_STRDUP@
-# if ! @HAVE_DECL_STRDUP@ && ! defined strdup
+# if @REPLACE_STRDUP@
+# undef strdup
+# define strdup rpl_strdup
+# endif
+# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
extern char *strdup (char const *__s);
# endif
#elif defined GNULIB_POSIXCHECK
diff --git a/m4/strdup.m4 b/m4/strdup.m4
index 8796e9e02f..0537def373 100644
--- a/m4/strdup.m4
+++ b/m4/strdup.m4
@@ -1,7 +1,6 @@
-# strdup.m4 serial 9
+# strdup.m4 serial 10
-dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-dnl Foundation, Inc.
+dnl Copyright (C) 2002-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,
@@ -18,5 +17,22 @@ AC_DEFUN([gl_FUNC_STRDUP],
gl_PREREQ_STRDUP
])
+AC_DEFUN([gl_FUNC_STRDUP_POSIX],
+[
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
+ if test $gl_cv_func_malloc_posix != yes; then
+ REPLACE_STRDUP=1
+ AC_LIBOBJ([strdup])
+ else
+ AC_REPLACE_FUNCS(strdup)
+ fi
+ AC_CHECK_DECLS_ONCE(strdup)
+ if test $ac_cv_have_decl_strdup = no; then
+ HAVE_DECL_STRDUP=0
+ fi
+ gl_PREREQ_STRDUP
+])
+
# Prerequisites of lib/strdup.c.
AC_DEFUN([gl_PREREQ_STRDUP], [:])
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index b37f843ab2..2d5553c374 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 5
+# serial 6
# Written by Paul Eggert.
@@ -83,9 +83,10 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
- REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
- REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
- REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
+ REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
+ REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
+ REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
+ REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
])
diff --git a/modules/getpass b/modules/getpass
index 32202197c7..7dba7e6bb2 100644
--- a/modules/getpass
+++ b/modules/getpass
@@ -10,6 +10,7 @@ Depends-on:
fseeko
getline
stdbool
+strdup-posix
configure.ac:
gl_FUNC_GETPASS
diff --git a/modules/strdup b/modules/strdup
index ac5c5f4bad..8a2eaf665a 100644
--- a/modules/strdup
+++ b/modules/strdup
@@ -7,7 +7,6 @@ m4/strdup.m4
Depends-on:
string
-malloc-posix
configure.ac:
gl_FUNC_STRDUP
diff --git a/modules/strdup-posix b/modules/strdup-posix
new file mode 100644
index 0000000000..4a474881b3
--- /dev/null
+++ b/modules/strdup-posix
@@ -0,0 +1,25 @@
+Description:
+strdup() function: duplicate a string.
+
+Files:
+lib/strdup.c
+m4/strdup.m4
+
+Depends-on:
+string
+malloc-posix
+
+configure.ac:
+gl_FUNC_STRDUP_POSIX
+gl_STRING_MODULE_INDICATOR([strdup])
+
+Makefile.am:
+
+Include:
+<string.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all, glibc
diff --git a/modules/string b/modules/string
index bed47ce07f..6283f9eb61 100644
--- a/modules/string
+++ b/modules/string
@@ -76,6 +76,7 @@ string.h: string.in.h
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \