From 20f949289927024e8f64542996af7a4592d437b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= Date: Sun, 3 Mar 2019 23:27:53 +0100 Subject: [PATCH] Allow using - to indicate input from stdin --- src/asm/fstack.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/asm/fstack.c b/src/asm/fstack.c index 2d5d4cc2..3035ab7c 100644 --- a/src/asm/fstack.c +++ b/src/asm/fstack.c @@ -405,23 +405,25 @@ void fstk_RunRept(uint32_t count) /* * Initialize the filestack routines */ -void fstk_Init(char *s) +void fstk_Init(char *pFileName) { - char tzFileName[_MAX_PATH + 1]; char tzSymFileName[_MAX_PATH + 1 + 2]; - snprintf(tzSymFileName, sizeof(tzSymFileName), "\"%s\"", s); + snprintf(tzSymFileName, sizeof(tzSymFileName), "\"%s\"", pFileName); sym_AddString("__FILE__", tzSymFileName); - strcpy(tzFileName, s); pFileStack = NULL; - pCurrentFile = fopen(tzFileName, "rb"); - if (pCurrentFile == NULL) - err(1, "Unable to open file '%s'", tzFileName); + if (strcmp(pFileName, "-") == 0) { + pCurrentFile = stdin; + } else { + pCurrentFile = fopen(pFileName, "rb"); + if (pCurrentFile == NULL) + err(1, "Unable to open file '%s'", pFileName); + } nMacroCount = 0; nCurrentStatus = STAT_isInclude; - snprintf(tzCurrentFileName, _MAX_PATH + 1, "%s", tzFileName); + snprintf(tzCurrentFileName, _MAX_PATH + 1, "%s", pFileName); CurrentFlexHandle = yy_create_buffer(pCurrentFile); yy_switch_to_buffer(CurrentFlexHandle); nLineNo = 1;