Mercurial > hg > octave-lyh > gnulib-hg
changeset 9726:4f5ee8490cd3
Sync from Libtool:
* libltdl/argz.c (argz_add, argz_count): New functions.
* libltdl/argz.in.h: Declare them.
Report by Juan Manuel Guerrero <juan.guerrero@gmx.de>.
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Wed, 27 Feb 2008 00:09:20 +0100 |
parents | 95c015b62dbc |
children | 7c1260f0aac3 |
files | ChangeLog lib/argz.c lib/argz.in.h |
diffstat | 3 files changed, 41 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-26 Karl Berry <karl@freefriends.org> + + Sync from Libtool: + * libltdl/argz.c (argz_add, argz_count): New functions. + * libltdl/argz.in.h: Declare them. + Report by Juan Manuel Guerrero <juan.guerrero@gmx.de>. + 2008-02-22 Bruno Haible <bruno@clisp.org> * m4/time_r.m4 (gl_TIME_R): Also check that localtime_r's return type
--- a/lib/argz.c +++ b/lib/argz.c @@ -1,6 +1,6 @@ /* argz.c -- argz implementation for non-glibc systems - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc. Written by Gary V. Vaughan, 2004 NOTE: The canonical source of this file is maintained with the @@ -76,6 +76,14 @@ } +/* Add a string to the argz vector. */ +error_t +argz_add (char **pargz, size_t *pargz_len, const char *str) +{ + return argz_append (pargz, pargz_len, str, strlen (str) + 1); +} + + error_t argz_create_sep (const char *str, int delim, char **pargz, size_t *pargz_len) { @@ -223,3 +231,24 @@ } } } + + +/* Count number of elements (null bytes) in argz vector. */ + +size_t +argz_count (const char *argz, size_t argz_len) +{ + size_t count = 0; + + assert ((argz && argz_len) || (!argz && !argz_len)); + + while (argz_len > 0) + { + size_t part_len = strlen (argz); + argz += part_len + 1; + argz_len -= part_len + 1; + count++; + } + + return count; +}
--- a/lib/argz.in.h +++ b/lib/argz.in.h @@ -1,6 +1,6 @@ /* lt__argz.h -- internal argz interface for non-glibc systems - Copyright (C) 2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc. Written by Gary V. Vaughan, 2004 NOTE: The canonical source of this file is maintained with the @@ -49,6 +49,8 @@ LT_SCOPE error_t argz_append (char **pargz, size_t *pargz_len, const char *buf, size_t buf_len); +LT_SCOPE error_t argz_add (char **pargz, size_t *pargz_len, + const char *str); LT_SCOPE error_t argz_create_sep(const char *str, int delim, char **pargz, size_t *pargz_len); LT_SCOPE error_t argz_insert (char **pargz, size_t *pargz_len, @@ -56,6 +58,7 @@ LT_SCOPE char * argz_next (char *argz, size_t argz_len, const char *entry); LT_SCOPE void argz_stringify (char *argz, size_t argz_len, int sep); +LT_SCOPE size_t argz_count (const char *argz, size_t argz_len); #if defined(__cplusplus) }