commit 8af828b13792597e0c3e805ae03a09b263c22282
parent f4984e3852c510e8d3705d8adfe8e686b674cd74
Author: Travis Geiselbrecht <geist@foobox.com>
Date:   Thu,  5 Apr 2012 23:35:57 -0700
assembler: allow "-" as an output filename to signify stdout
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/assembler.c b/assembler.c
@@ -337,7 +337,12 @@ void emit(const char *fn) {
 	u16 *dis = pc;
 	filename = fn;
 	linenumber = 0;
-	fp = fopen(fn, "w");
+
+	if (!strcmp(fn, "-")) {
+		fp = stdout;
+	} else {
+		fp = fopen(fn, "w");
+	}
 	if (!fp) die("cannot write file");
 
 	while (pc < end) {
@@ -350,7 +355,8 @@ void emit(const char *fn) {
 		}
 		pc++;
 	}
-	fclose(fp);
+	if (fp != stdout)
+		fclose(fp);
 }
 
 int main(int argc, char **argv) {