bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module strdup-posix


From: Bruno Haible
Subject: new module strdup-posix
Date: Sun, 21 Sep 2008 14:55:24 +0200
User-agent: KMail/1.5.4

Simon Josefsson wrote:
> right now strdup doesn't make sure ENOMEM is supported, and it seems
> unclear whether the modules that depend on strdup actually require that
> behaviour from the strdup module.  So as far as I can tell there is no
> reason for the explicit dependency today.

At least one module, getpass, requires strdup to set errno, because getpass()
is documented to let the user distinguish among various failures [1].

[1] http://opengroup.org/onlinepubs/007908775/xsh/getpass.html

I'm therefore adding a new module 'strdup-posix', and make 'getpass' depend
on it.


2008-09-21  Bruno Haible  <address@hidden>

        * 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.

======================= modules/strdup-posix =============================
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
==========================================================================
--- MODULES.html.sh.orig        2008-09-21 14:44:44.000000000 +0200
+++ MODULES.html.sh     2008-09-21 14:29:37.000000000 +0200
@@ -2121,6 +2121,7 @@
   func_module sleep
   func_module snprintf-posix
   func_module sprintf-posix
+  func_module strdup-posix
   func_module string
   func_module strings
   func_module tempname
--- doc/posix-functions/strdup.texi.orig        2008-09-21 14:44:44.000000000 
+0200
+++ doc/posix-functions/strdup.texi     2008-09-21 14:27:51.000000000 +0200
@@ -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 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:
address@hidden
address@hidden itemize
--- lib/string.in.h.orig        2008-09-21 14:44:44.000000000 +0200
+++ lib/string.in.h     2008-09-21 14:23:01.000000000 +0200
@@ -167,7 +167,11 @@
 
 /* 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
--- m4/strdup.m4.orig   2008-09-21 14:44:44.000000000 +0200
+++ m4/strdup.m4        2008-09-21 14:38:20.000000000 +0200
@@ -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 @@
   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], [:])
--- m4/string_h.m4.orig 2008-09-21 14:44:44.000000000 +0200
+++ m4/string_h.m4      2008-09-21 14:25:10.000000000 +0200
@@ -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 @@
   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])
 ])
--- modules/getpass.orig        2008-09-21 14:44:44.000000000 +0200
+++ modules/getpass     2008-09-21 14:26:06.000000000 +0200
@@ -10,6 +10,7 @@
 fseeko
 getline
 stdbool
+strdup-posix
 
 configure.ac:
 gl_FUNC_GETPASS
--- modules/strdup.orig 2008-09-21 14:44:44.000000000 +0200
+++ modules/strdup      2008-09-21 14:30:54.000000000 +0200
@@ -7,7 +7,6 @@
 
 Depends-on:
 string
-malloc-posix
 
 configure.ac:
 gl_FUNC_STRDUP
--- modules/string.orig 2008-09-21 14:44:44.000000000 +0200
+++ modules/string      2008-09-21 14:23:37.000000000 +0200
@@ -76,6 +76,7 @@
              -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' \





reply via email to

[Prev in Thread] Current Thread [Next in Thread]