bug-libtool
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] Add missing argz_* functions from glibc


From: Jim Meyering
Subject: Re: [PATCH 2/2] Add missing argz_* functions from glibc
Date: Wed, 04 Jun 2008 00:57:16 +0200

David Lutterkort <address@hidden> wrote:
> On Tue, 2008-06-03 at 19:12 +0200, Jim Meyering wrote:
>> I've included a still-preliminary patch below, in case you'd like to test it.
>> [I say preliminary because it effectively removes the C++-accommodating
>> code that's in the old version and because it's totally untested.
>> Adding C++ syntax is trivial, if anyone is interested. ]
>
> I've given your patch a quick spin, and ran into the following issues:
>
>       * __attribute_pure__ in argz.h is not defined
>       * all the prototypes in argz.h are duplicated (you need to remove
>         the __ prototypes, not rewrite them to ones without __)
>       * dependencies of the argz module on mempcpy, stpcpy, strndup, and
>         strnlen are missing
>       * m4/argz.m4 doesn't check for the new functions added from libc;
>         it only checks and sets HAVE_ macros for the old ones.
>
> Apart from these, it works nicely, and I managed to build my test
> program on FreeBSD and have it pass all its tests.

Thanks for the feedback!
I've fixed the first three things.
I did notice the tests for the 7 existing symbols,
but was reluctant to add the new ones since all functions go
back so far.  I checked and see that argz_replace was
added about 11 years ago, before glibc-2.0.95, so I doubt
any useful system will have all of the existing 7 but lack
any of the remaining functions.  So, for now at least,
I'm inclined to leave that test as is.

Here's an incremental patch,
to be applied on top of the first one.

>From 49ee8f54cc19f94f9d812de11a8d6b5dc375564f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 4 Jun 2008 00:51:53 +0200
Subject: [PATCH] more argz tweaks

* config/README (glibc_dir): Also remove __attribute_pure__.
Remove each __argz_* declaration.
* modules/argz (Depends-on): Add mempcpy, stpcpy, strndup, strnlen.
Suggested by David Lutterkort.
---
 config/README |   10 +++++--
 lib/argz.in.h |   75 +++++++++++++++++++-------------------------------------
 modules/argz  |    6 ++++-
 3 files changed, 38 insertions(+), 53 deletions(-)

diff --git a/config/README b/config/README
index 9e09cfd..60380fd 100644
--- a/config/README
+++ b/config/README
@@ -24,8 +24,12 @@ gcc -E -Itmp a-gen.c > a-gen.i

 perl -ni -e '/^#/ or print' a-gen.i argz.i

-perl -pe 's/__(restrict|const|argz_|st|mem)/$1/g;s/\s*__THROW//' \
+perl -pe 's/__(restrict|const|st|mem)/$1/g;' \
+    -e 's/\s*__THROW//;' \
+    -e 's/\s*__attribute_pure__//;' \
   $glibc_dir/string/argz.h \
+  | perl -ne \
+    '/^(#include <features\.h>|__(?:BEGIN|END)_DECLS)/ or print' \
+  | perl -0x3b -pe 's/extern \S+ \*?__argz_(.|\n)*?\)\n*;//' \
+  | perl -pe 's/__(argz_next)/$1/g;' \
   > argz.in.h
-perl -ni -e \
-  '/^(#include <features\.h>|__(?:BEGIN|END)_DECLS)/ or print' argz.in.h
diff --git a/lib/argz.in.h b/lib/argz.in.h
index 462537d..e89f029 100644
--- a/lib/argz.in.h
+++ b/lib/argz.in.h
@@ -38,8 +38,7 @@ typedef int error_t;
 /* Make a '\0' separated arg vector from a unix argv vector, returning it in
    ARGZ, and the total length in LEN.  If a memory allocation error occurs,
    ENOMEM is returned, otherwise 0.  The result can be destroyed using free. */
-extern error_t argz_create (char *const __argv[], char **restrict __argz,
-                             size_t *restrict __len);
+
 extern error_t argz_create (char *const __argv[], char **restrict __argz,
                            size_t *restrict __len);

@@ -47,66 +46,52 @@ extern error_t argz_create (char *const __argv[], char 
**restrict __argz,
    STRING, returning it in ARGZ, and the total length in LEN.  If a
    memory allocation error occurs, ENOMEM is returned, otherwise 0.
    The result can be destroyed using free.  */
-extern error_t argz_create_sep (const char *restrict string,
-                                 int __sep, char **restrict __argz,
-                                 size_t *restrict __len);
+
 extern error_t argz_create_sep (const char *restrict string,
                                int __sep, char **restrict __argz,
                                size_t *restrict __len);

 /* Returns the number of strings in ARGZ.  */
+
 extern size_t argz_count (const char *__argz, size_t __len)
- __attribute_pure__;
-extern size_t argz_count (const char *__argz, size_t __len)
- __attribute_pure__;
+;

 /* Puts pointers to each string in ARGZ into ARGV, which must be large enough
    to hold them all.  */
-extern void argz_extract (const char *restrict __argz, size_t __len,
-                           char **restrict __argv);
+
 extern void argz_extract (const char *restrict __argz, size_t __len,
                          char **restrict __argv);

 /* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
    except the last into the character SEP.  */
-extern void argz_stringify (char *__argz, size_t __len, int __sep);
+
 extern void argz_stringify (char *__argz, size_t __len, int __sep);

 /* Append BUF, of length BUF_LEN to the argz vector in ARGZ & ARGZ_LEN.  */
+
 extern error_t argz_append (char **restrict __argz,
-                             size_t *restrict argz_len,
-                             const char *restrict __buf, size_t _buf_len)
-;
-extern error_t argz_append (char **restrict __argz,
-                           size_t *restrict argz_len,
+                           size_t *restrict __argz_len,
                            const char *restrict __buf, size_t __buf_len)
 ;

 /* Append STR to the argz vector in ARGZ & ARGZ_LEN.  */
+
 extern error_t argz_add (char **restrict __argz,
-                          size_t *restrict argz_len,
-                          const char *restrict str);
-extern error_t argz_add (char **restrict __argz,
-                        size_t *restrict argz_len,
+                        size_t *restrict __argz_len,
                         const char *restrict str);

 /* Append SEP separated list in STRING to the argz vector in ARGZ &
    ARGZ_LEN.  */
+
 extern error_t argz_add_sep (char **restrict __argz,
-                              size_t *restrict argz_len,
-                              const char *restrict string, int __delim)
-;
-extern error_t argz_add_sep (char **restrict __argz,
-                            size_t *restrict argz_len,
+                            size_t *restrict __argz_len,
                             const char *restrict string, int __delim)
 ;

 /* Delete ENTRY from ARGZ & ARGZ_LEN, if it appears there.  */
+
 extern void argz_delete (char **restrict __argz,
-                          size_t *restrict argz_len,
-                          char *restrict __entry);
-extern void argz_delete (char **restrict __argz,
-                        size_t *restrict argz_len,
+                        size_t *restrict __argz_len,
                         char *restrict __entry);

 /* Insert ENTRY into ARGZ & ARGZ_LEN before BEFORE, which should be an
@@ -115,25 +100,18 @@ extern void argz_delete (char **restrict __argz,
    ARGZ, ENTRY) will insert ENTRY at the beginning of ARGZ.  If BEFORE is not
    in ARGZ, EINVAL is returned, else if memory can't be allocated for the new
    ARGZ, ENOMEM is returned, else 0.  */
+
 extern error_t argz_insert (char **restrict __argz,
-                             size_t *restrict argz_len,
-                             char *restrict __before,
-                             const char *restrict __entry);
-extern error_t argz_insert (char **restrict __argz,
-                           size_t *restrict argz_len,
+                           size_t *restrict __argz_len,
                            char *restrict __before,
                            const char *restrict __entry);

 /* Replace any occurrences of the string STR in ARGZ with WITH, reallocating
    ARGZ as necessary.  If REPLACE_COUNT is non-zero, *REPLACE_COUNT will be
    incremented by number of replacements performed.  */
+
 extern error_t argz_replace (char **restrict __argz,
-                              size_t *restrict argz_len,
-                              const char *restrict str,
-                              const char *restrict __with,
-                              unsigned int *restrict __replace_count);
-extern error_t argz_replace (char **restrict __argz,
-                            size_t *restrict argz_len,
+                            size_t *restrict __argz_len,
                             const char *restrict str,
                             const char *restrict __with,
                             unsigned int *restrict __replace_count);
@@ -152,31 +130,30 @@ extern error_t argz_replace (char **restrict __argz,
     for (entry = argz; entry; entry = argz_next (argz, argz_len, entry))
       ...;
 */
-extern char *argz_next (const char *restrict __argz, size_t argz_len,
-                         const char *restrict __entry);
-extern char *argz_next (const char *restrict __argz, size_t argz_len,
+
+extern char *argz_next (const char *restrict __argz, size_t __argz_len,
                        const char *restrict __entry);

 #ifdef __USE_EXTERN_INLINES
 __extern_inline char *
-__NTH (argz_next (const char *__argz, size_t argz_len,
+__NTH (argz_next (const char *__argz, size_t __argz_len,
                    const char *__entry))
 {
   if (__entry)
     {
-      if (__entry < __argz + argz_len)
+      if (__entry < __argz + __argz_len)
        __entry = strchr (__entry, '\0') + 1;

-      return __entry >= __argz + argz_len ? (char *) NULL : (char *) __entry;
+      return __entry >= __argz + __argz_len ? (char *) NULL : (char *) __entry;
     }
   else
-    return argz_len > 0 ? (char *) __argz : 0;
+    return __argz_len > 0 ? (char *) __argz : 0;
 }
 __extern_inline char *
-__NTH (argz_next (const char *__argz, size_t argz_len,
+__NTH (argz_next (const char *__argz, size_t __argz_len,
                  const char *__entry))
 {
-  return argz_next (__argz, argz_len, __entry);
+  return argz_next (__argz, __argz_len, __entry);
 }
 #endif /* Use extern inlines.  */

diff --git a/modules/argz b/modules/argz
index 601abb7..19d884b 100644
--- a/modules/argz
+++ b/modules/argz
@@ -7,6 +7,10 @@ lib/argz.c
 m4/argz.m4

 Depends-on:
+mempcpy
+stpcpy
+strndup
+strnlen

 configure.ac:
 gl_FUNC_ARGZ
@@ -30,4 +34,4 @@ License:
 LGPLv2+

 Maintainer:
address@hidden
+all
--
1.5.6.rc1.2.g5648b




reply via email to

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