aboutsummaryrefslogtreecommitdiff
path: root/libiberty/argv.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2011-09-28 19:04:30 +0000
committerDoug Evans <devans@gcc.gnu.org>2011-09-28 19:04:30 +0000
commitbe50fcea4e4482bff587119732223f1d4639f47b (patch)
treefdfb0d01e1c901837ac5426759f458176364fa86 /libiberty/argv.c
parentd92aed064711dceb6caf355d064759224ce9b42a (diff)
downloadgcc-be50fcea4e4482bff587119732223f1d4639f47b.zip
gcc-be50fcea4e4482bff587119732223f1d4639f47b.tar.gz
gcc-be50fcea4e4482bff587119732223f1d4639f47b.tar.bz2
libiberty.h (countargv): Declare.
include/ * libiberty.h (countargv): Declare. libiberty/ * argv.c (countargv): New function. From-SVN: r179318
Diffstat (limited to 'libiberty/argv.c')
-rw-r--r--libiberty/argv.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libiberty/argv.c b/libiberty/argv.c
index 8476c8f..ca53f91 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. */