summaryrefslogtreecommitdiff
path: root/command_line/C++_Parser/Src/Library
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2022-10-19 21:16:13 +0100
committerAsh Wolf <ninji@wuffs.org>2022-10-19 21:16:13 +0100
commitd1f153d34b023d81768f6087f67dbfff714bafc9 (patch)
treea694d470a60655d0cda15a70791fbdb90a2398cf /command_line/C++_Parser/Src/Library
parent775b6861666af36d317fb577cf489e2c6377f878 (diff)
downloadMWCC-d1f153d34b023d81768f6087f67dbfff714bafc9.tar.gz
MWCC-d1f153d34b023d81768f6087f67dbfff714bafc9.zip
let's commit all this before my VM blows up and nukes my work
Diffstat (limited to 'command_line/C++_Parser/Src/Library')
-rw-r--r--command_line/C++_Parser/Src/Library/WarningHelpers.c84
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;
+}