From 4cbfb4e199bf019c0f4c917c6c189fe93867a05a Mon Sep 17 00:00:00 2001 From: mc78 Date: Fri, 12 May 2017 12:19:40 +0200 Subject: [PATCH 1/6] added -E switch to cl65 for >>stop after the preprocessing stage<<. added compilation and assemblation disable after -Wc -E also with -E beeing part of a comma separated list of arguments --- src/cl65/main.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 7bdbe7a8a..58a1fe0c2 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -706,6 +706,7 @@ static void Usage (void) " -C name\t\t\tUse linker config file\n" " -Cl\t\t\t\tMake local variables static\n" " -D sym[=defn]\t\t\tDefine a preprocessor symbol\n" + " -E Stop after the preprocessing stage\n" " -I dir\t\t\tSet a compiler include directory path\n" " -L path\t\t\tSpecify a library search path\n" " -Ln name\t\t\tCreate a VICE label file\n" @@ -1411,14 +1412,41 @@ int main (int argc, char* argv []) /* Print version number */ OptVersion (Arg, 0); break; - + + case 'E': + /*Forward -E to compiler*/ + CmdAddArg (&CC65, Arg); + DoAssemble = 0; + DoLink = 0; + break; case 'W': 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') { + } + else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - OptCCArgs (Arg, GetArg (&I, 3)); + + /* Get argument succeeding -Wc switch */ + const char* WcSubArgs = GetArg (&I, 3); + + /* Remember -Wc sub arguments in cc65 arg struct */ + OptCCArgs (Arg, WcSubArgs); + /* Check for isolated -E switch given after -Wc*/ + if (!strcmp("-E", WcSubArgs)){ + /*If both -Wc and -E given, then prevent assembling + and linking */ + DoAssemble = 0; + DoLink = 0; + }else{ + /* Check for -E beeing part of comma separated arg + list given after -Wc*/ + if ( (NULL!=strstr(WcSubArgs, "-E,")) || + (NULL!=strstr(WcSubArgs, ",-E"))){ + DoAssemble = 0; + DoLink = 0; + } + } } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ OptLdArgs (Arg, GetArg (&I, 3)); From 691df09a1f4a6b0f95b0d6eb7fd7320eb28df2b6 Mon Sep 17 00:00:00 2001 From: mc78 Date: Tue, 16 May 2017 13:13:09 +0200 Subject: [PATCH 2/6] According to recent comments on my recent pull request, -Wc checking for -E flag has been removed again. Intead, -E flag has been added to cl65 without need of -Wc. Two functions have been introduced to disable compile, link or both. These function remove assigment repetions to DoAssemble and DoLink for litte overhead, having the maintainability in mind. --- src/cl65/main.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 58a1fe0c2..2172700ae 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -156,7 +156,21 @@ static char* TargetLib = 0; # endif #endif +/*****************************************************************************/ +/* Credential functions */ +/*****************************************************************************/ +void DisableAssembling(void){ + DoAssemble = 0; +} +void DisableLinking(void){ + DoLink = 0; +} + +void DisableAssemblingAndLinking(void){ + DisableAssembling(); + DisableLinking(); +} /*****************************************************************************/ /* Command structure handling */ @@ -1399,8 +1413,7 @@ int main (int argc, char* argv []) case 'S': /* Dont assemble and link the created files */ - DoAssemble = 0; - DoLink = 0; + DisableAssemblingAndLinking(); break; case 'T': @@ -1416,37 +1429,16 @@ int main (int argc, char* argv []) case 'E': /*Forward -E to compiler*/ CmdAddArg (&CC65, Arg); - DoAssemble = 0; - DoLink = 0; + DisableAssemblingAndLinking(); break; case 'W': 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') { + } else if (Arg[2] == 'c' && Arg[3] == '\0') { /* -Wc: Pass options to compiler */ - - /* Get argument succeeding -Wc switch */ - const char* WcSubArgs = GetArg (&I, 3); - /* Remember -Wc sub arguments in cc65 arg struct */ - OptCCArgs (Arg, WcSubArgs); - /* Check for isolated -E switch given after -Wc*/ - if (!strcmp("-E", WcSubArgs)){ - /*If both -Wc and -E given, then prevent assembling - and linking */ - DoAssemble = 0; - DoLink = 0; - }else{ - /* Check for -E beeing part of comma separated arg - list given after -Wc*/ - if ( (NULL!=strstr(WcSubArgs, "-E,")) || - (NULL!=strstr(WcSubArgs, ",-E"))){ - DoAssemble = 0; - DoLink = 0; - } - } + OptCCArgs (Arg, GetArg (&I, 3)); } else if (Arg[2] == 'l' && Arg[3] == '\0') { /* -Wl: Pass options to linker */ OptLdArgs (Arg, GetArg (&I, 3)); @@ -1458,7 +1450,7 @@ int main (int argc, char* argv []) case 'c': /* Don't link the resulting files */ - DoLink = 0; + DisableLinking(); break; case 'd': From d70a9507a7c731e9b95dd615328df975a3cff58c Mon Sep 17 00:00:00 2001 From: mc78 Date: Tue, 16 May 2017 13:31:10 +0200 Subject: [PATCH 3/6] replaced tabs with spaces which accidently were introduced. --- src/cl65/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 2172700ae..e428c96ac 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -157,19 +157,19 @@ static char* TargetLib = 0; #endif /*****************************************************************************/ -/* Credential functions */ +/* Credential functions */ /*****************************************************************************/ void DisableAssembling(void){ - DoAssemble = 0; + DoAssemble = 0; } void DisableLinking(void){ - DoLink = 0; + DoLink = 0; } void DisableAssemblingAndLinking(void){ - DisableAssembling(); - DisableLinking(); + DisableAssembling(); + DisableLinking(); } /*****************************************************************************/ From 3157e4be1ec7f2a5ac61ca45b232cd07c5e30483 Mon Sep 17 00:00:00 2001 From: mc78 Date: Mon, 22 May 2017 23:07:31 +0200 Subject: [PATCH 4/6] added empty lines and spaces according to olivers comments. Made local functions static. --- src/cl65/main.c | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index e428c96ac..6926199f9 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -156,22 +156,36 @@ static char* TargetLib = 0; # endif #endif + + /*****************************************************************************/ /* Credential functions */ /*****************************************************************************/ -void DisableAssembling(void){ + + + +static void DisableAssembling (void) +{ DoAssemble = 0; } -void DisableLinking(void){ + + +static void DisableLinking (void) +{ DoLink = 0; } -void DisableAssemblingAndLinking(void){ + + +static void DisableAssemblingAndLinking (void) +{ DisableAssembling(); DisableLinking(); } + + /*****************************************************************************/ /* Command structure handling */ /*****************************************************************************/ @@ -1427,22 +1441,33 @@ int main (int argc, char* argv []) break; case 'E': - /*Forward -E to compiler*/ + /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); DisableAssemblingAndLinking(); break; + case 'W': - 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 { + /* 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: + break; + } + }else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); } From 21b1add98464367bef7819654f1643337c65260b Mon Sep 17 00:00:00 2001 From: mc78 Date: Mon, 22 May 2017 23:21:55 +0200 Subject: [PATCH 5/6] added four escaped tabs to -E Stop after .... description --- src/cl65/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 6926199f9..8252b61ff 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -734,7 +734,7 @@ static void Usage (void) " -C name\t\t\tUse linker config file\n" " -Cl\t\t\t\tMake local variables static\n" " -D sym[=defn]\t\t\tDefine a preprocessor symbol\n" - " -E Stop after the preprocessing stage\n" + " -E\t\t\t\tStop after the preprocessing stage\n" " -I dir\t\t\tSet a compiler include directory path\n" " -L path\t\t\tSpecify a library search path\n" " -Ln name\t\t\tCreate a VICE label file\n" From f87a575d4d32f0f2386ebd7c24dc73953eed2bef Mon Sep 17 00:00:00 2001 From: mc78 Date: Tue, 23 May 2017 22:57:27 +0200 Subject: [PATCH 6/6] added missing spaces before braces. added unknown option msg if not given -Wc|l|a when passing options to subprocess --- src/cl65/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index 8252b61ff..b209cb21d 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -180,8 +180,8 @@ static void DisableLinking (void) static void DisableAssemblingAndLinking (void) { - DisableAssembling(); - DisableLinking(); + DisableAssembling (); + DisableLinking (); } @@ -1427,7 +1427,7 @@ int main (int argc, char* argv []) case 'S': /* Dont assemble and link the created files */ - DisableAssemblingAndLinking(); + DisableAssemblingAndLinking (); break; case 'T': @@ -1443,7 +1443,7 @@ int main (int argc, char* argv []) case 'E': /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); - DisableAssemblingAndLinking(); + DisableAssemblingAndLinking (); break; case 'W': @@ -1465,9 +1465,10 @@ int main (int argc, char* argv []) OptLdArgs (Arg, GetArg (&I, 3)); break; default: + UnknownOption (Arg); break; } - }else { + } else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); } @@ -1475,7 +1476,7 @@ int main (int argc, char* argv []) case 'c': /* Don't link the resulting files */ - DisableLinking(); + DisableLinking (); break; case 'd':