diff options
author | 2014-08-08 12:40:26 +0000 | |
---|---|---|
committer | 2014-08-08 12:40:26 +0000 | |
commit | dc9523b79494e25195311bff75491791f1d9a4a5 (patch) | |
tree | 516337c466d5655b440f055da577beb82ad16d2a | |
parent | Fix CVE-2014-3507, avoid allocating and then leaking a fresh fragment (diff) | |
download | wireguard-openbsd-dc9523b79494e25195311bff75491791f1d9a4a5.tar.xz wireguard-openbsd-dc9523b79494e25195311bff75491791f1d9a4a5.zip |
Add support for using - as shorthand for stdin/stdout in tradcpp.
When looking into switching the /usr/bin/cpp wrapper to
tradcpp I came across "| ${CPP} ${CPPFLAGS} -" in usr.bin/which.
gcc documents this behaviour for cpp here:
https://gcc.gnu.org/onlinedocs/cpp/Invocation.html
Versions of the John F. Reiser derived cpp in 32V and CSRG SCCS
accept this usage as well, as does the cpp in PCC.
-rw-r--r-- | libexec/tradcpp/files.c | 2 | ||||
-rw-r--r-- | libexec/tradcpp/main.c | 2 | ||||
-rw-r--r-- | libexec/tradcpp/output.c | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/libexec/tradcpp/files.c b/libexec/tradcpp/files.c index f0ee45eee55..ea151b23286 100644 --- a/libexec/tradcpp/files.c +++ b/libexec/tradcpp/files.c @@ -400,7 +400,7 @@ file_readabsolute(struct place *place, const char *name) assert(place != NULL); - if (name == NULL) { + if ((name == NULL) || !strcmp(name, "-")) { fd = STDIN_FILENO; pf = place_addfile(place, "<standard-input>", false); } else { diff --git a/libexec/tradcpp/main.c b/libexec/tradcpp/main.c index 35f9bca1326..eae7f44632d 100644 --- a/libexec/tradcpp/main.c +++ b/libexec/tradcpp/main.c @@ -1040,7 +1040,7 @@ main(int argc, char *argv[]) init(); for (i=1; i<argc; i++) { - if (argv[i][0] != '-') { + if ((argv[i][0] != '-') || !strcmp(argv[i], "-")) { break; } place_setcommandline(&cmdplace, i, 1); diff --git a/libexec/tradcpp/output.c b/libexec/tradcpp/output.c index d1d1f2d4d94..5cc7165892c 100644 --- a/libexec/tradcpp/output.c +++ b/libexec/tradcpp/output.c @@ -47,7 +47,7 @@ static void output_open(void) { - if (mode.output_file == NULL) { + if ((mode.output_file == NULL) || !strcmp(mode.output_file, "-")) { outputfd = STDOUT_FILENO; } else { outputfd = open(mode.output_file, O_WRONLY|O_CREAT|O_TRUNC, |