summaryrefslogtreecommitdiff
path: root/libiberty/argv.c
diff options
context:
space:
mode:
authordevans <devans@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-28 19:04:30 +0000
committerdevans <devans@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-28 19:04:30 +0000
commitc12ded991ed38fc9d4aaaa3cce10695cbcfa6efb (patch)
treefdfb0d01e1c901837ac5426759f458176364fa86 /libiberty/argv.c
parentbe7a395b8a69ca5b53f4a96bdec4eed6c17a1c68 (diff)
downloadgcc-c12ded991ed38fc9d4aaaa3cce10695cbcfa6efb.tar.gz
include/
* libiberty.h (countargv): Declare. libiberty/ * argv.c (countargv): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179318 138bc75d-0d04-0410-961f-82ee72b054a4
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 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. */