summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-19 00:54:41 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-19 00:54:41 +0100
commitc4a7b2c56e907e39fa9a6cdb21c1970464abd44e (patch)
tree0ad70957d5736341e0cc068e50557c08d99a9aac /src/shared
parentcb9da7f24fb057813606c87f9a73fdb941baa78c (diff)
util: add new FOREACH_STRING() macro as syntactic sugar to iterate through a number of fixed strings
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/strv.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/strv.h b/src/shared/strv.h
index b356d034c6..e26ab828d2 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -119,3 +119,15 @@ void strv_print(char **l);
})
#define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x)
+
+#define FOREACH_STRING(x, ...) \
+ for (char **_l = ({ \
+ char **_ll = STRV_MAKE(__VA_ARGS__); \
+ x = _ll ? _ll[0] : NULL; \
+ _ll; \
+ }); \
+ _l && *_l; \
+ x = ({ \
+ _l ++; \
+ _l[0]; \
+ }))