include/
* libiberty.h (countargv): Declare.
libiberty/
* argv.c (countargv): New function.
From-SVN: r179318
+2011-09-28 Doug Evans <dje@google.com>
+
+ * libiberty.h (countargv): Declare.
+
2011-09-26 Cary Coutant <ccoutant@google.com>
PR lto/47247
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
+2011-09-28 Doug Evans <dje@google.com>
+
+ * argv.c (countargv): New function.
+
2011-09-23 Cary Coutant <ccoutant@google.com>
PR 40831
}
}
+/*
+
+@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. */