From: jsg Date: Fri, 8 Aug 2014 12:40:26 +0000 (+0000) Subject: Add support for using - as shorthand for stdin/stdout in tradcpp. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dc9523b79494e25195311bff75491791f1d9a4a5;p=openbsd 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. --- 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, "", 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