summaryrefslogtreecommitdiffstats
path: root/src/delta/delta.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-31 11:28:11 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-09 09:34:54 +0200
commitcc24f0b8725af5d8bb8f601f49327ed2f8e6d382 (patch)
tree0be0726a6b6c3cd9ade833494d55486225a1f60b /src/delta/delta.c
parentcryptsetup: use extract_first_word() (diff)
downloadsystemd-cc24f0b8725af5d8bb8f601f49327ed2f8e6d382.tar.xz
systemd-cc24f0b8725af5d8bb8f601f49327ed2f8e6d382.zip
delta: use extract_first_word()
Diffstat (limited to '')
-rw-r--r--src/delta/delta.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/delta/delta.c b/src/delta/delta.c
index 29e5120375..b37bad8447 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -545,28 +545,33 @@ static int help(void) {
}
static int parse_flags(const char *flag_str, int flags) {
- const char *word, *state;
- size_t l;
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+ int r;
- FOREACH_WORD_SEPARATOR(word, l, flag_str, ",", state) {
- if (strneq("masked", word, l))
+ r = extract_first_word(&flag_str, &word, ",", EXTRACT_DONT_COALESCE_SEPARATORS);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ return flags;
+
+ if (streq(word, "masked"))
flags |= SHOW_MASKED;
- else if (strneq ("equivalent", word, l))
+ else if (streq(word, "equivalent"))
flags |= SHOW_EQUIVALENT;
- else if (strneq("redirected", word, l))
+ else if (streq(word, "redirected"))
flags |= SHOW_REDIRECTED;
- else if (strneq("overridden", word, l))
+ else if (streq(word, "overridden"))
flags |= SHOW_OVERRIDDEN;
- else if (strneq("unchanged", word, l))
+ else if (streq(word, "unchanged"))
flags |= SHOW_UNCHANGED;
- else if (strneq("extended", word, l))
+ else if (streq(word, "extended"))
flags |= SHOW_EXTENDED;
- else if (strneq("default", word, l))
+ else if (streq(word, "default"))
flags |= SHOW_DEFAULTS;
else
return -EINVAL;
}
- return flags;
}
static int parse_argv(int argc, char *argv[]) {