summaryrefslogtreecommitdiff
path: root/libiberty
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
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')
-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 0547f9b08ed..ccee83fb3a2 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 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. */