diff options
Diffstat (limited to 'libiberty/argv.c')
-rw-r--r-- | libiberty/argv.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libiberty/argv.c b/libiberty/argv.c index 8476c8fda9e..ca53f91493d 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -492,6 +492,29 @@ expandargv (int *argcp, char ***argvp) } } +/* + +@deftypefn Extension int countargv (char **@var{argv}) + +Return the number of elements in @var{argv}. +Returns zero if @var{argv} is NULL. + +@end deftypefn + +*/ + +int +countargv (char **argv) +{ + int argc; + + if (argv == NULL) + return 0; + for (argc = 0; argv[argc] != NULL; argc++) + continue; + return argc; +} + #ifdef MAIN /* Simple little test driver. */ |