From 22394ce54c11f11461ef5e14b76db1d71ba120e3 Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Thu, 4 Jun 2020 11:59:30 +0200 Subject: cgit-about-filter: Invoke filters in-line Previously, EXEC relied on filter invocations being stored globally in a char * array. Use an improved variadic version of the macro that enables us to get rid of those global definitions and instead invoke filters in-line. --- cgit-about-filter.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cgit-about-filter.c b/cgit-about-filter.c index 68dfd9b..02b6043 100644 --- a/cgit-about-filter.c +++ b/cgit-about-filter.c @@ -4,13 +4,11 @@ #include #include -#define EXEC(args) execvp(args[0], args) +#define EXEC1(args) execvp(args[0], args) +#define EXEC(...) EXEC1(((char *const []){ __VA_ARGS__, NULL })) static const char *extension(const char *filename); -char *mandoc[] = { "mandoc", "-Thtml", "-Ofragment", NULL }; -char *lowdown[] = { "lowdown", "-Thtml", NULL }; - int main(int argc, char *argv[]) { @@ -28,9 +26,9 @@ main(int argc, char *argv[]) return 1; if (strlen(ext) == 1 && isdigit(*ext)) { - EXEC(mandoc); + EXEC("mandoc", "-Thtml", "-Ofragment"); } else if (strcmp(ext, "md") == 0) { - EXEC(lowdown); + EXEC("lowdown", "-Thtml"); } return 1; -- cgit v1.2.3-2-gb3c3