aboutsummaryrefslogtreecommitdiff
path: root/libiberty
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
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')
-rw-r--r--libiberty/ChangeLog4
-rw-r--r--libiberty/argv.c23
2 files changed, 27 insertions, 0 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 0547f9b..ccee83f 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2011-09-28 Doug Evans <dje@google.com>
+
+ * argv.c (countargv): New function.
+
2011-09-23 Cary Coutant <ccoutant@google.com>
PR 40831
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. */