chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f203e18
)
basic/strv: add STRPTR_IN_SET
author
Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl>
Sun, 25 Sep 2016 00:13:28 +0000
(20:13 -0400)
committer
Sven Eden
<yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:53 +0000
(08:50 +0200)
Also some trivial tests for STR_IN_SET and STRPTR_IN_SET.
src/basic/strv.h
patch
|
blob
|
history
diff --git
a/src/basic/strv.h
b/src/basic/strv.h
index c4a8a1d20c8cd7fae03c6d4316e2c6e2ef3e3daf..0a908c89345db05ffc25fe1d89c7a6251fa2094f 100644
(file)
--- a/
src/basic/strv.h
+++ b/
src/basic/strv.h
@@
-160,6
+160,11
@@
void strv_print(char **l);
})
#define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x)
})
#define STR_IN_SET(x, ...) strv_contains(STRV_MAKE(__VA_ARGS__), x)
+#define STRPTR_IN_SET(x, ...) \
+ ({ \
+ const char* _x = (x); \
+ _x && strv_contains(STRV_MAKE(__VA_ARGS__), _x); \
+ })
#define FOREACH_STRING(x, ...) \
for (char **_l = ({ \
#define FOREACH_STRING(x, ...) \
for (char **_l = ({ \