summaryrefslogtreecommitdiff
path: root/src/basic/strv.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-31 16:21:14 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-09 09:34:55 +0200
commit0645b83a40d1c782f173c4d8440ab2fc82a75006 (patch)
tree03c9733aec1d24b4ae6578c14f8ef01b107a6900 /src/basic/strv.h
parentd59d954d7f6f5f3772b12e8078875183e0b27889 (diff)
downloadsystemd-0645b83a40d1c782f173c4d8440ab2fc82a75006.tar.gz
tree-wide: replace strv_split_full() with strv_split_extract() everywhere
Behaviour is not identical, as shown by the tests in test-strv. The combination of EXTRACT_UNQUOTE without EXTRACT_RELAX only appears in the test, so it doesn't seem particularly important. OTOH, the difference in handling of squished parameters could make a difference. New behaviour is what both bash and python do, so I think we can ignore this corner case. This change has the following advantages: - the duplication of code paths that do a very similar thing is removed - extract_one_word() / strv_split_extract() return a proper error code.
Diffstat (limited to 'src/basic/strv.h')
-rw-r--r--src/basic/strv.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/basic/strv.h b/src/basic/strv.h
index bc0b04b56b..9e15820f28 100644
--- a/src/basic/strv.h
+++ b/src/basic/strv.h
@@ -72,13 +72,19 @@ static inline bool strv_isempty(char * const *l) {
return !l || !*l;
}
-char **strv_split_full(const char *s, const char *separator, SplitFlags flags);
-static inline char **strv_split(const char *s, const char *separator) {
- return strv_split_full(s, separator, 0);
-}
char **strv_split_newlines(const char *s);
int strv_split_extract(char ***t, const char *s, const char *separators, ExtractFlags flags);
+static inline char **strv_split(const char *s, const char *separators) {
+ char **ret;
+ int r;
+
+ r = strv_split_extract(&ret, s, separators, 0);
+ if (r < 0)
+ return NULL;
+
+ return ret;
+}
/* Given a string containing white-space separated tuples of words themselves separated by ':',
* returns a vector of strings. If the second element in a tuple is missing, the corresponding