diff options
author | vapier <vapier@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-05 20:23:30 +0000 |
---|---|---|
committer | vapier <vapier@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-01-05 20:23:30 +0000 |
commit | e2e4b9a0b88f75f6b354ca217ec5e296f737a5d5 (patch) | |
tree | e33cdcaa1dabbad9bd07bef692c837f46907a560 /libiberty | |
parent | 233a53ed985a0f91c5d9ff5c99f89bec592cc51b (diff) |
libiberty: {count,dup,write}argv: constify argv input slightly
Would be more useful if we could use "const char * const *", but there's
a long standing bug where gcc warns about incompatible pointers when you
try to pass in "char **". We can at least constify the array itself as
gcc will not warn in that case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232089 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 6 | ||||
-rw-r--r-- | libiberty/argv.c | 12 | ||||
-rw-r--r-- | libiberty/functions.texi | 6 |
3 files changed, 15 insertions, 9 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 3cc90d17e99..1d2ee4ca4f5 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,5 +1,11 @@ 2016-01-05 Mike Frysinger <vapier@gentoo.org> + * argv.c (dupargv): Change arg to char * const *. Update comment. + (writeargv, countargv): Likewise. + * functions.texi (dupargv, writeargv, countargv): Likewise. + +2016-01-05 Mike Frysinger <vapier@gentoo.org> + * argv.c (dupargv): Replace strlen/xmalloc/strcpy with xstrdup. 2015-12-28 Patrick Palka <ppalka@gcc.gnu.org> diff --git a/libiberty/argv.c b/libiberty/argv.c index 5c3dd70b042..994dd3531c0 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -49,7 +49,7 @@ Boston, MA 02110-1301, USA. */ /* -@deftypefn Extension char** dupargv (char **@var{vector}) +@deftypefn Extension char** dupargv (char * const *@var{vector}) Duplicate an argument vector. Simply scans through @var{vector}, duplicating each argument until the terminating @code{NULL} is found. @@ -62,7 +62,7 @@ argument vector. */ char ** -dupargv (char **argv) +dupargv (char * const *argv) { int argc; char **copy; @@ -279,7 +279,7 @@ char **buildargv (const char *input) /* -@deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file}) +@deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file}) Write each member of ARGV, handling all necessary quoting, to the file named by FILE, separated by whitespace. Return 0 on success, non-zero @@ -290,7 +290,7 @@ if an error occurred while writing to FILE. */ int -writeargv (char **argv, FILE *f) +writeargv (char * const *argv, FILE *f) { int status = 0; @@ -463,7 +463,7 @@ expandargv (int *argcp, char ***argvp) /* -@deftypefn Extension int countargv (char **@var{argv}) +@deftypefn Extension int countargv (char * const *@var{argv}) Return the number of elements in @var{argv}. Returns zero if @var{argv} is NULL. @@ -473,7 +473,7 @@ Returns zero if @var{argv} is NULL. */ int -countargv (char **argv) +countargv (char * const *argv) { int argc; diff --git a/libiberty/functions.texi b/libiberty/functions.texi index b5f4e809d06..24dcc373ac0 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -176,7 +176,7 @@ Concatenate zero or more of strings and return the result in freshly @end deftypefn @c argv.c:470 -@deftypefn Extension int countargv (char **@var{argv}) +@deftypefn Extension int countargv (char * const *@var{argv}) Return the number of elements in @var{argv}. Returns zero if @var{argv} is NULL. @@ -213,7 +213,7 @@ make it easy to compose the values of multiple blocks. @end deftypefn @c argv.c:52 -@deftypefn Extension char** dupargv (char **@var{vector}) +@deftypefn Extension char** dupargv (char * const *@var{vector}) Duplicate an argument vector. Simply scans through @var{vector}, duplicating each argument until the terminating @code{NULL} is found. @@ -1915,7 +1915,7 @@ does the return value. The third argument is unused in @libib{}. @end deftypefn @c argv.c:286 -@deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file}) +@deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file}) Write each member of ARGV, handling all necessary quoting, to the file named by FILE, separated by whitespace. Return 0 on success, non-zero |