diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-10 19:55:30 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-10 19:55:30 +0100 |
commit | 092b6e188b6b75be4450c6f20fc82599dcaf9552 (patch) | |
tree | b26137bbea4c7fddf07b587019c0a90695fa6ddb | |
parent | b95292a1523fb119a1cfa11a461f605566b41cec (diff) | |
parent | 3d793d29059a7ddf5282efa6b32b953c183d7a4d (diff) |
Merge pull request #1785 from ssahani/word
core: unit deps port to extract_first_word
-rw-r--r-- | src/core/load-fragment.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 7f12f26b08..a514052772 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -111,22 +111,28 @@ int config_parse_unit_deps(const char *unit, UnitDependency d = ltype; Unit *u = userdata; - const char *word, *state; - size_t l; + const char *p; assert(filename); assert(lvalue); assert(rvalue); - FOREACH_WORD_QUOTED(word, l, rvalue, state) { - _cleanup_free_ char *t = NULL, *k = NULL; + p = rvalue; + for(;;) { + _cleanup_free_ char *word = NULL, *k = NULL; int r; - t = strndup(word, l); - if (!t) + r = extract_first_word(&p, &word, NULL, 0); + if (r == 0) + break; + if (r == -ENOMEM) return log_oom(); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); + break; + } - r = unit_name_printf(u, t, &k); + r = unit_name_printf(u, word, &k); if (r < 0) { log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve specifiers, ignoring: %m"); continue; @@ -136,8 +142,6 @@ int config_parse_unit_deps(const char *unit, if (r < 0) log_syntax(unit, LOG_ERR, filename, line, r, "Failed to add dependency on %s, ignoring: %m", k); } - if (!isempty(state)) - log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid syntax, ignoring."); return 0; } |