changeset 181:44ea61019069

Accept "-" as the input file, or as the output file. Has no effect (input or output remains stdin and/or stdout respectively)
author David A. Holland
date Fri, 12 Jun 2015 03:16:04 -0400
parents d65a2f2184cb
children f7814226906c
files CHANGES main.c
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Fri Jun 12 03:09:48 2015 -0400
+++ b/CHANGES	Fri Jun 12 03:16:04 2015 -0400
@@ -1,4 +1,6 @@
 pending
+   - Accept "-" as either input or output file name to mean stdin or
+     stdout respectively. Suggested by Jonathan Gray.
    - Fix output spacing behavior to match gcc when newlines appear in or
      while looking for macro arguments. Partly from Joerg Sonnenberger.
    - Implement __FILE__ and __LINE__ macros. Mostly from Joerg Sonnenberger.
--- a/main.c	Fri Jun 12 03:09:48 2015 -0400
+++ b/main.c	Fri Jun 12 03:16:04 2015 -0400
@@ -1053,7 +1053,7 @@
 	init();
 
 	for (i=1; i<argc; i++) {
-		if (argv[i][0] != '-') {
+		if (argv[i][0] != '-' || argv[i][1] == 0) {
 			break;
 		}
 		place_setcommandline(&cmdplace, i, 1);
@@ -1078,9 +1078,15 @@
 	}
 	if (i < argc) {
 		inputfile = argv[i++];
+		if (!strcmp(inputfile, "-")) {
+			inputfile = NULL;
+		}
 	}
 	if (i < argc) {
 		outputfile = argv[i++];
+		if (!strcmp(outputfile, "-")) {
+			outputfile = NULL;
+		}
 	}
 	if (i < argc) {
 		usage(progname, "Extra non-option argument %s", argv[i]);