summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-10 19:55:30 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-10 19:55:30 +0100
commit092b6e188b6b75be4450c6f20fc82599dcaf9552 (patch)
treeb26137bbea4c7fddf07b587019c0a90695fa6ddb /src
parentb95292a1523fb119a1cfa11a461f605566b41cec (diff)
parent3d793d29059a7ddf5282efa6b32b953c183d7a4d (diff)
Merge pull request #1785 from ssahani/word
core: unit deps port to extract_first_word
Diffstat (limited to 'src')
-rw-r--r--src/core/load-fragment.c22
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;
}