char **strv_sort(char **l);
void strv_print(char **l);
+#define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL }))
+
+#define STRV_MAKE_EMPTY ((char*[1]) { NULL })
+
#define strv_from_stdarg_alloca(first) \
({ \
char **_l; \
\
if (!first) \
- _l = ((char*[1]) { NULL }); \
+ _l = (char**) &first; \
else { \
unsigned _n; \
va_list _ap; \
}
}
-static void test_strv_from_stdarg_alloca_one(const char **l, const char *first, ...) {
+static void test_strv_from_stdarg_alloca_one(char **l, const char *first, ...) {
char **j;
unsigned i;
}
static void test_strv_from_stdarg_alloca(void) {
- test_strv_from_stdarg_alloca_one((const char*[]) { "foo", "bar", NULL }, "foo", "bar", NULL);
- test_strv_from_stdarg_alloca_one((const char*[]) { "foo", "bar", NULL }, "foo", "bar", NULL);
- test_strv_from_stdarg_alloca_one((const char*[]) { "foo", NULL }, "foo", NULL);
+ test_strv_from_stdarg_alloca_one(STRV_MAKE("foo", "bar"), "foo", "bar", NULL);
+ test_strv_from_stdarg_alloca_one(STRV_MAKE("foo"), "foo", NULL);
+ test_strv_from_stdarg_alloca_one(STRV_MAKE_EMPTY, NULL);
}
int main(int argc, char *argv[]) {