From 90d4abd26bfd7e7f2e84873037293074bbc25be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 21 Feb 2019 11:27:33 +0100 Subject: [PATCH] Copy FOREACH_STRING fix from systemd This is a copy of https://github.com/systemd/systemd/commit/66a64081f82dfad90f2f9394a477820a2e3e6510. --- src/util.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/util.h b/src/util.h index feefeaa97a..dcc8ff3995 100644 --- a/src/util.h +++ b/src/util.h @@ -552,17 +552,10 @@ static inline size_t strlen_null(const char *s) { #define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL })) -#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]; \ - })) +#define FOREACH_STRING(x, y, ...) \ + for (char **_l = STRV_MAKE(({ x = y; }), ##__VA_ARGS__); \ + x; \ + x = *(++_l)) #define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x) -- 2.19.2