diff options
author | Wynn Wolf Arbor | 2020-06-04 11:59:30 +0200 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-06-04 11:59:30 +0200 |
commit | 22394ce54c11f11461ef5e14b76db1d71ba120e3 (patch) | |
tree | 051edfa351fa73c3ef96b0614ec40f5bf4f68698 | |
parent | a79316179389b22525b58e38f4618bf9fa0ea525 (diff) | |
download | skein-0.1.1.tar.gz |
cgit-about-filter: Invoke filters in-line0.1.1
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.
-rw-r--r-- | cgit-about-filter.c | 10 |
1 files 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 <string.h> #include <unistd.h> -#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; |