chiark / gitweb /
util: use quoted word parsing where applicable
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Jul 2010 18:58:41 +0000 (20:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Jul 2010 18:58:41 +0000 (20:58 +0200)
src/conf-parser.c
src/device.c
src/load-fragment.c
src/main.c
src/service.c
src/strv.c

index df3584dd04567bbc73272b2aebb6dd56c81803a1..1cabc0d789b2d9ef17f9689490e81fb498f2e006 100644 (file)
@@ -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;
                 }
index a0349c4300470dc9cc02a7e19019488ca22b75b0..2079f1c4e48cfa136e6a6a0160e7f0f413a1d25d 100644 (file)
@@ -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))) {
index 1cc7c5cc3940c46e004877f6cffdf2d1c6dbb795..43b8093fa02e782dad11d983a7c9115440585ab5 100644 (file)
@@ -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)
index 592edbe7676004be55c3319c0d059255f082677d..d5902b354fbc2e90be133ee39293832fef229ffe 100644 (file)
@@ -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;
index ccc83128be6277e9a4a8e8c2d75be9c328356be2..fed8227299279ec11e0370465f90318825fde23f 100644 (file)
@@ -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))) {
index 01464e1e330816bfd0f4fae3af4ae3085b5ac0b6..a66369602bbbc98051fbd675628fcfdc1dea47f9 100644 (file)
@@ -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;
                 }