summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-07 20:58:41 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-07 20:58:41 +0200
commitf60f22dfbb8cfa0eb55d1896db0e4c3f7d3cfacb (patch)
tree281e6403566756a06a47599067b296446e9257d0
parent6febfd0d4bdf7519e119149b8d8ec03c210aed1d (diff)
util: use quoted word parsing where applicable
-rw-r--r--src/conf-parser.c4
-rw-r--r--src/device.c2
-rw-r--r--src/load-fragment.c16
-rw-r--r--src/main.c2
-rw-r--r--src/service.c4
-rw-r--r--src/strv.c2
6 files changed, 15 insertions, 15 deletions
diff --git a/src/conf-parser.c b/src/conf-parser.c
index df3584dd04..1cabc0d789 100644
--- a/src/conf-parser.c
+++ b/src/conf-parser.c
@@ -423,7 +423,7 @@ int config_parse_strv(
k = 0;
FOREACH_WORD_QUOTED(w, l, rvalue, state)
- if (!(n[k++] = strndup(w, l)))
+ if (!(n[k++] = cunescape_length(w, l)))
goto fail;
n[k] = NULL;
@@ -475,7 +475,7 @@ int config_parse_path_strv(
n[k] = (*sv)[k];
FOREACH_WORD_QUOTED(w, l, rvalue, state) {
- if (!(n[k] = strndup(w, l))) {
+ if (!(n[k] = cunescape_length(w, l))) {
r = -ENOMEM;
goto fail;
}
diff --git a/src/device.c b/src/device.c
index a0349c4300..2079f1c4e4 100644
--- a/src/device.c
+++ b/src/device.c
@@ -244,7 +244,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
goto fail;
if (wants) {
- FOREACH_WORD(w, l, wants, state) {
+ FOREACH_WORD_QUOTED(w, l, wants, state) {
char *e;
if (!(e = strndup(w, l))) {
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 1cc7c5cc39..43b8093fa0 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -61,7 +61,7 @@ static int config_parse_deps(
assert(lvalue);
assert(rvalue);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
char *t, *k;
int r;
@@ -103,7 +103,7 @@ static int config_parse_names(
assert(rvalue);
assert(data);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
char *t, *k;
int r;
@@ -689,7 +689,7 @@ static int config_parse_cpu_affinity(
assert(rvalue);
assert(data);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
char *t;
int r;
unsigned cpu;
@@ -766,7 +766,7 @@ static int config_parse_secure_bits(
assert(rvalue);
assert(data);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
if (first_word(w, "keep-caps"))
c->secure_bits |= SECURE_KEEP_CAPS;
else if (first_word(w, "keep-caps-locked"))
@@ -807,7 +807,7 @@ static int config_parse_bounding_set(
assert(rvalue);
assert(data);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
char *t;
int r;
cap_value_t cap;
@@ -902,11 +902,11 @@ static int config_parse_cgroup(
size_t l;
char *state;
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
char *t;
int r;
- if (!(t = strndup(w, l)))
+ if (!(t = cunescape_length(w, l)))
return -ENOMEM;
r = unit_add_cgroup_from_text(u, t);
@@ -967,7 +967,7 @@ static int config_parse_mount_flags(
assert(rvalue);
assert(data);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
if (strncmp(w, "shared", l) == 0)
flags |= MS_SHARED;
else if (strncmp(w, "slave", l) == 0)
diff --git a/src/main.c b/src/main.c
index 592edbe767..d5902b354f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -426,7 +426,7 @@ static int config_parse_cpu_affinity(
assert(lvalue);
assert(rvalue);
- FOREACH_WORD(w, l, rvalue, state) {
+ FOREACH_WORD_QUOTED(w, l, rvalue, state) {
char *t;
int r;
unsigned cpu;
diff --git a/src/service.c b/src/service.c
index ccc83128be..fed8227299 100644
--- a/src/service.c
+++ b/src/service.c
@@ -526,7 +526,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
state = LSB;
- FOREACH_WORD(w, z, t+9, i) {
+ FOREACH_WORD_QUOTED(w, z, t+9, i) {
char *n, *m;
if (!(n = strndup(w, z))) {
@@ -563,7 +563,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
state = LSB;
- FOREACH_WORD(w, z, strchr(t, ':')+1, i) {
+ FOREACH_WORD_QUOTED(w, z, strchr(t, ':')+1, i) {
char *n, *m;
if (!(n = strndup(w, z))) {
diff --git a/src/strv.c b/src/strv.c
index 01464e1e33..a66369602b 100644
--- a/src/strv.c
+++ b/src/strv.c
@@ -264,7 +264,7 @@ char **strv_split_quoted(const char *s) {
i = 0;
FOREACH_WORD_QUOTED(w, l, s, state)
- if (!(r[i++] = strndup(w, l))) {
+ if (!(r[i++] = cunescape_length(w, l))) {
strv_free(r);
return NULL;
}