aboutsummaryrefslogtreecommitdiff
path: root/libiberty/argv.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2011-09-28 20:01:45 +0000
committerDJ Delorie <dj@redhat.com>2011-09-28 20:01:45 +0000
commit514c97d3e0e09f75366b973f214441d8cd019c8f (patch)
tree37ae136d2a2c6096a1f67576084ae8bbd0ff17ff /libiberty/argv.c
parentfe10a582b69fc09ce4775071aa619b0a6fc5dd1a (diff)
downloadgdb-514c97d3e0e09f75366b973f214441d8cd019c8f.zip
gdb-514c97d3e0e09f75366b973f214441d8cd019c8f.tar.gz
gdb-514c97d3e0e09f75366b973f214441d8cd019c8f.tar.bz2
merge from gcc
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. */