summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@gmail.com>2015-11-05 10:56:13 +0530
committerSusant Sahani <ssahani@gmail.com>2015-11-10 22:24:00 +0530
commit3d793d29059a7ddf5282efa6b32b953c183d7a4d (patch)
tree3c7f716f928ea4ed36bceddc85f7517da54cd4fc /src/core
parent930a0796937402e591f42555c870713e8f5cc64a (diff)
core: unit deps port to extract_first_word
Diffstat (limited to 'src/core')
-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;
}