bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] Re: Add strdup.h.


From: Simon Josefsson
Subject: [Bug-gnulib] Re: Add strdup.h.
Date: Fri, 23 Jan 2004 17:06:45 +0100
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> How about this version?
>
> It's better, but still some nits:
>
> - strdup.c should #include strdup.h, to check the interface.

I didn't do that because strdup.c is from libc, but I now see the
gnulib version isn't in sync anyway.  I added:

#ifndef _LIBC
/* Get specification. */
#include "strdup.h"
#endif

> - strdup.h doesn't need to #include <config.h>; this is usually done
>   in the .c file that uses it.

Oops, removed.

> - The comment in strdup.m4 should say
>     # Prerequisites of lib/strdup.h and lib/strdup.c.

Done.

> - The "Include:" section of modules/strdup should mention "strdup.h".
>   This is for the documentation in MODULES.html.

Done.

> - path-concat.c and user-spec.c should be updated to #include "strdup.h",
>   and their modules should depend on 'strdup'.

They already depend on the strdup module, but I fixed the include.
Btw, user-spec.c defines a macro V_STRDUP, which is the same as
strdupa on glibc platforms.  Perhaps a new gnulib module strdupa would
be useful, but I'm not sure how it should be implemented (I rather
dislike all the alloca stuff because of portability).

Thanks.
? lib/strdup.h
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/ChangeLog,v
retrieving revision 1.128
diff -u -p -r1.128 ChangeLog
--- ChangeLog   20 Jan 2004 17:05:34 -0000      1.128
+++ ChangeLog   23 Jan 2004 16:02:15 -0000
@@ -1,3 +1,7 @@
+2004-01-18  Simon Josefsson  <address@hidden>
+
+       * modules/strdup (Files, Makefile.am): Add strdup.h.
+
 2004-01-20  Bruno Haible  <address@hidden>
 
        * modules/setenv: Depend on allocsa instead of alloca.
Index: lib/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.634
diff -u -p -r1.634 ChangeLog
--- lib/ChangeLog       21 Jan 2004 22:18:24 -0000      1.634
+++ lib/ChangeLog       23 Jan 2004 16:02:16 -0000
@@ -1,3 +1,7 @@
+2004-01-18  Simon Josefsson  <address@hidden>
+
+       * strdup.h: Add.
+
 2004-01-21  Jim Meyering  <address@hidden>
 
        * mktime.c (__mktime_internal) [!_LIBC]: Define to mktime_internal
Index: lib/path-concat.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/path-concat.c,v
retrieving revision 1.17
diff -u -p -r1.17 path-concat.c
--- lib/path-concat.c   9 Sep 2003 23:25:33 -0000       1.17
+++ lib/path-concat.c   23 Jan 2004 16:02:16 -0000
@@ -1,6 +1,6 @@
 /* path-concat.c -- concatenate two arbitrary pathnames
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
    Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -35,10 +35,7 @@
 # include <unistd.h>
 #endif
 
-#ifndef strdup
-char *strdup ();
-#endif
-
+#include "strdup.h"
 #include "dirname.h"
 #include "xalloc.h"
 #include "path-concat.h"
Index: lib/strdup.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strdup.c,v
retrieving revision 1.14
diff -u -p -r1.14 strdup.c
--- lib/strdup.c        13 Sep 2003 22:13:36 -0000      1.14
+++ lib/strdup.c        23 Jan 2004 16:02:16 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003 Free Software
+/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 Free Software
    Foundation, Inc.
 
    This file is part of the GNU C Library.
@@ -19,6 +19,11 @@
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
+#endif
+
+#ifndef _LIBC
+/* Get specification. */
+#include "strdup.h"
 #endif
 
 #include <stdlib.h>
Index: lib/userspec.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/userspec.c,v
retrieving revision 1.39
diff -u -p -r1.39 userspec.c
--- lib/userspec.c      3 Nov 2003 15:03:24 -0000       1.39
+++ lib/userspec.c      23 Jan 2004 16:02:16 -0000
@@ -1,5 +1,5 @@
 /* userspec.c -- Parse a user and group string.
-   Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2003 Free Software
+   Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2004 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -41,6 +41,7 @@
 # include <unistd.h>
 #endif
 
+#include "strdup.h"
 #include "userspec.h"
 #include "posixver.h"
 #include "xalloc.h"
@@ -108,10 +109,6 @@ struct group *getgrgid ();
    ISDIGIT_LOCALE unless it's important to use the locale's definition
    of `digit' even when the host does not conform to POSIX.  */
 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
-
-#ifndef strdup
-char *strdup ();
-#endif
 
 /* Return nonzero if STR represents an unsigned decimal integer,
    otherwise return 0. */
Index: m4/strdup.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strdup.m4,v
retrieving revision 1.2
diff -u -p -r1.2 strdup.m4
--- m4/strdup.m4        12 Sep 2003 18:24:51 -0000      1.2
+++ m4/strdup.m4        23 Jan 2004 16:02:16 -0000
@@ -1,5 +1,5 @@
-# strdup.m4 serial 2
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# strdup.m4 serial 3
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -14,8 +14,7 @@ AC_DEFUN([gl_FUNC_STRDUP],
   fi
 ])
 
-# Prerequisites of lib/strdup.c.
+# Prerequisites of lib/strdup.h and lib/strdup.c.
 AC_DEFUN([gl_PREREQ_STRDUP], [
-  :
+  AC_CHECK_DECLS(strdup)
 ])
-
Index: modules/strdup
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strdup,v
retrieving revision 1.3
diff -u -p -r1.3 strdup
--- modules/strdup      20 Jan 2003 10:02:38 -0000      1.3
+++ modules/strdup      23 Jan 2004 16:02:16 -0000
@@ -2,6 +2,7 @@ Description:
 strdup() function: duplicate a string.
 
 Files:
+lib/strdup.h
 lib/strdup.c
 m4/strdup.m4
 
@@ -11,8 +12,10 @@ configure.ac:
 gl_FUNC_STRDUP
 
 Makefile.am:
+lib_SOURCES += strdup.h
 
 Include:
+"strdup.h"
 
 Maintainer:
 all, glibc

reply via email to

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