summaryrefslogtreecommitdiffstats
path: root/src/delta
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-09-09 17:43:38 +0200
committerGitHub <noreply@github.com>2020-09-09 17:43:38 +0200
commit12ce0f41735e3d179c41deee99d9abe8aae52527 (patch)
tree13ba019fd7e4232da90de24f9ee36f6a669b4833 /src/delta
parentMerge pull request #16972 from wusto/ambient-and-keep-caps-corrections (diff)
parentRename strv_split_extract() to strv_split_full() (diff)
downloadsystemd-12ce0f41735e3d179c41deee99d9abe8aae52527.tar.xz
systemd-12ce0f41735e3d179c41deee99d9abe8aae52527.zip
Merge pull request #16635 from keszybz/do-not-for-each-word
Drop FOREACH_WORD
Diffstat (limited to 'src/delta')
-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 acb6020715..a88eed098d 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -541,28 +541,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[]) {