From bc58bf572cf317f54580018cf12968693768228d Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Mon, 5 Mar 2018 22:31:10 +0100 Subject: [PATCH] Fixed -W cmdline option handling. Reverted part of https://github.com/cc65/cc65/commit/3157e4be1ec7f2a5ac61ca45b232cd07c5e30483 as it actually introduced a regression. It doesn't make sense to check for Arg[3] == '\0' _before_ checking Arg[2] != '\0'. This made the Win32 builds fail to correctly parse e.g. cl65 -W unused-var test.c --- src/cl65/main.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 5a2103b24..afd3e97e3 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -1444,35 +1444,24 @@ int main (int argc, char* argv []) /* Print version number */ OptVersion (Arg, 0); break; - + case 'E': /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); DisableAssemblingAndLinking (); break; - + case 'W': - /* avoid && with'\0' in if clauses */ - if (Arg[3] == '\0') { - switch (Arg[2]) { - case 'a': - /* -Wa: Pass options to assembler */ - OptAsmArgs (Arg, GetArg (&I, 3)); - break; - case 'c': - /* -Wc: Pass options to compiler - ** Remember -Wc sub arguments in cc65 arg struct - */ - OptCCArgs (Arg, GetArg (&I, 3)); - break; - case 'l': - /* -Wl: Pass options to linker */ - OptLdArgs (Arg, GetArg (&I, 3)); - break; - default: - UnknownOption (Arg); - break; - } + if (Arg[2] == 'a' && Arg[3] == '\0') { + /* -Wa: Pass options to assembler */ + OptAsmArgs (Arg, GetArg (&I, 3)); + } else if (Arg[2] == 'c' && Arg[3] == '\0') { + /* -Wc: Pass options to compiler */ + /* Remember -Wc sub arguments in cc65 arg struct */ + OptCCArgs (Arg, GetArg (&I, 3)); + } else if (Arg[2] == 'l' && Arg[3] == '\0') { + /* -Wl: Pass options to linker */ + OptLdArgs (Arg, GetArg (&I, 3)); } else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); -- 2.39.5