Skip to content

Commit 5738346

Browse files
keszybzpoettering
authored andcommitted
Copy FOREACH_STRING fix from systemd
This is a copy of systemd/systemd@66a6408.
1 parent b3337dd commit 5738346

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/util.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -552,17 +552,10 @@ static inline size_t strlen_null(const char *s) {
552552

553553
#define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL }))
554554

555-
#define FOREACH_STRING(x, ...) \
556-
for (char **_l = ({ \
557-
char **_ll = STRV_MAKE(__VA_ARGS__); \
558-
x = _ll ? _ll[0] : NULL; \
559-
_ll; \
560-
}); \
561-
_l && *_l; \
562-
x = ({ \
563-
_l ++; \
564-
_l[0]; \
565-
}))
555+
#define FOREACH_STRING(x, y, ...) \
556+
for (char **_l = STRV_MAKE(({ x = y; }), ##__VA_ARGS__); \
557+
x; \
558+
x = *(++_l))
566559

567560
#define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x)
568561

0 commit comments

Comments
 (0)