diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-19 15:24:34 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2015-08-07 15:50:43 +0000 |
commit | 8adaf7bd23baa6e2cd99e9e88e55d0f5f5db29a2 (patch) | |
tree | 708a0dd3995411d49cee3174f340986b9e5587c5 /src/basic/strv.c | |
parent | ffcd3e89d55c870c94aa15ee94dab3e029a586cf (diff) |
strv: convert strv_split_quotes into a generic strv_split_extract
strv_split_extract is to strv_split_quotes as extract_first_word was to
unquote_first_word.
Now there's extract_first_word for extracting a single argument,
extract_many_words for extracting a bounded number of arguments,
and strv_split_extract for extracting an arbitrary number of arguments.
Diffstat (limited to 'src/basic/strv.c')
-rw-r--r-- | src/basic/strv.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/basic/strv.c b/src/basic/strv.c index 72964a166a..79a9d8d421 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -278,7 +278,7 @@ char **strv_split_newlines(const char *s) { return l; } -int strv_split_quoted(char ***t, const char *s, ExtractFlags flags) { +int strv_split_extract(char ***t, const char *s, const char *separators, ExtractFlags flags) { size_t n = 0, allocated = 0; _cleanup_strv_free_ char **l = NULL; int r; @@ -289,11 +289,12 @@ int strv_split_quoted(char ***t, const char *s, ExtractFlags flags) { for (;;) { _cleanup_free_ char *word = NULL; - r = extract_first_word(&s, &word, NULL, flags|EXTRACT_QUOTES); + r = extract_first_word(&s, &word, separators, flags); if (r < 0) return r; - if (r == 0) + if (r == 0) { break; + } if (!GREEDY_REALLOC(l, allocated, n + 2)) return -ENOMEM; |