From a8db3c675450432aa07f9817d3688ab33651fed9 Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 21 Jan 2007 21:20:22 +0000 Subject: [PATCH 1/1] added stdin support ("swfc -") --- src/parser.lex | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/parser.lex b/src/parser.lex index b22d95c..fb0fa62 100644 --- a/src/parser.lex +++ b/src/parser.lex @@ -326,10 +326,19 @@ void freeTokens(struct token_t*file) struct token_t* generateTokens(char*filename) { - FILE*fi = fopen(filename, "rb"); + FILE*fi; int t; struct token_t*result; int num; + + if(!filename) + return 0; + + if(!strcmp(filename,"-")) + fi = stdin; + else + fi = fopen(filename, "rb"); + if(!fi) { printf("Couldn't find file %s\n", filename); return 0; @@ -359,7 +368,8 @@ struct token_t* generateTokens(char*filename) result[t].text += (int)strings.buffer; } - fclose(fi); + if(fi!=stdin) + fclose(fi); return result; } -- 1.7.10.4