diff options
Diffstat (limited to 'command_line/C++_Parser/Src')
-rw-r--r-- | command_line/C++_Parser/Src/Library/WarningHelpers.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/command_line/C++_Parser/Src/Library/WarningHelpers.c b/command_line/C++_Parser/Src/Library/WarningHelpers.c new file mode 100644 index 0000000..35a6fa8 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/WarningHelpers.c @@ -0,0 +1,84 @@ +#include "parser.h" + +int SetWarningFlags(const char *opt, void *str, const char *, int flags) { + // this is very similar to ToolHelper + // might also fail to match + unsigned char *ptr; + Boolean set; + Boolean no; + UInt16 flag; + + ptr = (unsigned char *) str; + no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); + set = (Boolean) (no ^ 1); + + while (*ptr) { + if (*ptr == '+') { + set = !no; + } else if (*ptr == '-') { + set = no; + } else if (*ptr == '|') { + set = (Boolean) (no ^ 1); + } else { + flag = (ptr[0] << 8) | ptr[1]; + + if (set) + pCmdLine.noWarnings = 0; + + switch (flag) { + case 'Nw': + pCmdLine.noWarnings = set; + break; + case 'Aw': + TargetSetWarningFlags(flag, set); + break; + case 'Cw': + pCmdLine.noCmdLineWarnings = !set; + break; + case 'We': + pCmdLine.warningsAreErrors = set; + TargetSetWarningFlags(flag, set); + break; + default: + if (!TargetSetWarningFlags(flag, set)) + CLPFatalError("Bad warning settings in %s (%c%c)\n", str, ptr[0], ptr[1]); + } + + ++ptr; + } + + ++ptr; + } + + Parser_StorePanels(parseopts.context); + + return 1; +} + +int DisplayWarningOptions() { + Handle h; + + h = NewHandle(0); + if (!h) + exit(-23); + + HPrintF(h, "Command-line warning options:\n"); + + if (pCmdLine.noCmdLineWarnings) + HPrintF(h, "\t- no command-line warnings\n"); + else + HPrintF(h, "\t- command-line warnings\n"); + + if (pCmdLine.warningsAreErrors) + HPrintF(h, "\t- warnings are errors\n"); + else + HPrintF(h, "\t- warnings are not errors\n"); + + if (pCmdLine.noWarnings) + HPrintF(h, "\t- no warnings at all\n"); + + TargetDisplayWarningOptions(h); + ShowTextHandle(NULL, h); + DisposeHandle(h); + return 1; +} |