From d95c75dfd7635c3d85855e10ced212a3dc9299ff Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 5 Oct 2016 23:24:29 +0200 Subject: [PATCH] Allowing an input filename on the command line makes debuggers happy. (Then we don't need to redirect stdin.) --- mach/proto/mcg/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mach/proto/mcg/main.c b/mach/proto/mcg/main.c index eca8a14ec..9c863b8ad 100644 --- a/mach/proto/mcg/main.c +++ b/mach/proto/mcg/main.c @@ -32,6 +32,8 @@ static bool find_procedures_cb(struct symbol* symbol, void* user) int main(int argc, char* const argv[]) { + const char* inputfile = NULL; + program_name = argv[0]; opterr = 1; @@ -48,14 +50,17 @@ int main(int argc, char* const argv[]) break; case 1: - fatal("unexpected argument '%s'", optarg); + if (inputfile) + fatal("unexpected argument '%s'", optarg); + inputfile = optarg; } } symbol_init(); - if (!EM_open(NULL)) - fatal("couldn't open stdin: %s", EM_error); + if (!EM_open(inputfile)) + fatal("couldn't open '%s': %s", + inputfile ? inputfile : "", EM_error); /* Reads in the EM, outputs the data sections, parses any code and * generates IR trees. */ -- 2.34.1