From: Zbigniew Jędrzejewski-Szmek Date: Sun, 25 Sep 2016 00:13:28 +0000 (-0400) Subject: basic/strv: add STRPTR_IN_SET X-Git-Tag: v232.2~57 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=7dd230537883c50e572752574e08c94aef5efa7f;ds=sidebyside basic/strv: add STRPTR_IN_SET Also some trivial tests for STR_IN_SET and STRPTR_IN_SET. --- diff --git a/src/basic/strv.h b/src/basic/strv.h index c4a8a1d20..0a908c893 100644 --- 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 STRPTR_IN_SET(x, ...) \ + ({ \ + const char* _x = (x); \ + _x && strv_contains(STRV_MAKE(__VA_ARGS__), _x); \ + }) #define FOREACH_STRING(x, ...) \ for (char **_l = ({ \