]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libiberty.h (countargv): Declare.
authorDoug Evans <dje@google.com>
Wed, 28 Sep 2011 19:04:30 +0000 (19:04 +0000)
committerDoug Evans <devans@gcc.gnu.org>
Wed, 28 Sep 2011 19:04:30 +0000 (19:04 +0000)
include/
* libiberty.h (countargv): Declare.

libiberty/
* argv.c (countargv): New function.

From-SVN: r179318

include/ChangeLog
include/libiberty.h
libiberty/ChangeLog
libiberty/argv.c

index 3cc8996068888721b6b46e09b1ced97945e4b0bb..a09c287a612619e39cc09f32a3202d5aca6d0d7a 100644 (file)
@@ -1,3 +1,7 @@
+2011-09-28  Doug Evans  <dje@google.com>
+
+       * libiberty.h (countargv): Declare.
+
 2011-09-26  Cary Coutant  <ccoutant@google.com>
 
        PR lto/47247
index 32eb83a049eefec2a29f9eef2ab3aaadf72379d7..cacde800ea3dda438ea8292ab4b9354a63ad048b 100644 (file)
@@ -91,6 +91,10 @@ extern void expandargv PARAMS ((int *, char ***));
 
 extern int writeargv PARAMS ((char **, FILE *));
 
+/* Return the number of elements in argv.  */
+
+extern int countargv (char**);
+
 /* Return the last component of a path name.  Note that we can't use a
    prototype here because the parameter is declared inconsistently
    across different systems, sometimes as "char *" and sometimes as
index 0547f9b08ed401a953c877319a1560bf3507b128..ccee83fb3a2278e65626b1d3c0d1e599c5ca7564 100644 (file)
@@ -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
index 8476c8fda9e155b765e5262b1087c3bbb3a7cc05..ca53f91493dbfc82797c4f2411c27c5b9a7fead6 100644 (file)
@@ -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. */