mirror of https://git.wuffs.org/MWCC
85 lines
2.1 KiB
C
85 lines
2.1 KiB
C
|
#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;
|
||
|
}
|