summaryrefslogtreecommitdiff
path: root/argv-array.c
diff options
context:
space:
mode:
Diffstat (limited to 'argv-array.c')
-rw-r--r--argv-array.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/argv-array.c b/argv-array.c
index 5d370fa336..cb5bcd2c06 100644
--- a/argv-array.c
+++ b/argv-array.c
@@ -64,6 +64,26 @@ void argv_array_pop(struct argv_array *array)
array->argc--;
}
+void argv_array_split(struct argv_array *array, const char *to_split)
+{
+ while (isspace(*to_split))
+ to_split++;
+ for (;;) {
+ const char *p = to_split;
+
+ if (!*p)
+ break;
+
+ while (*p && !isspace(*p))
+ p++;
+ argv_array_push_nodup(array, xstrndup(to_split, p - to_split));
+
+ while (isspace(*p))
+ p++;
+ to_split = p;
+ }
+}
+
void argv_array_clear(struct argv_array *array)
{
if (array->argv != empty_argv) {