From e2a5e7e5f004fb9ac93d4118eb98ac040e10c897 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 22 Feb 2019 12:26:48 -0800 Subject: Simplify handling of arguments to cc-qbe a bit --- main.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 11f37b2..4783bdd 100644 --- a/main.c +++ b/main.c @@ -35,16 +35,12 @@ main(int argc, char *argv[]) usage(); } ARGEND - if (argc == 1) { - if (!freopen(argv[0], "r", stdin)) - fatal("open %s:", argv[0]); - } else if (argc) { + if (argc > 1) usage(); - } - if (output) { - if (!freopen(output, "w", stdout)) - fatal("open %s:", output); - } + if (argc == 1 && !freopen(argv[0], "r", stdin)) + fatal("open %s:", argv[0]); + if (output && !freopen(output, "w", stdout)) + fatal("open %s:", output); ppinit(argc ? argv[0] : ""); if (pponly) { -- cgit v1.2.3