summaryrefslogtreecommitdiff
path: root/command_line/C++_Parser/Src/Library/WarningHelpers.c
blob: 95a06573b837e88501460cb170ac83cbda781838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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(const char *, void *, const char *, int) {
    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;
}