File: setclasses

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (76 lines) | stat: -rw-r--r-- 1,553 bytes parent folder | download
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
int readLine()                  // 1: line was read from CLASSES, 
{                               // 0: no line
    g_classLine = fgets("CLASSES", g_classLine);
    return listlen(g_classLine) && g_classLine[2] == "OK";
}

int empty(list entries)
{
    return !entries || entries[0][0] == '#' || strfind(entries[0], "//") == 0;
}

string  nextClassesEntry()
{
    list parts;

    while (readLine())
    {
        string line = g_classLine[0];
        int last = strlen(line) - 1;
        int bs = line[last] == '\\';

        if (bs)
            line = resize(line, last);           // remove the backslash

        list entries = strtok(line, " \t");     // entries on the line

        if (empty(entries))     // blank or comment
        {
            if (!parts)         // nothing collected yet
                continue;
            break;              // or return the 1st element
        }

        parts += (list)entries[0];
        if (bs)
            continue;
        break;
    }

    return parts ? parts[0] : "";
}

void setClasses()
{
    while (1)
    {
        string class = nextClassesEntry();
        if (strlen(class) == 0)
            break;
        g_classes = listunion(g_classes, class);
    }            
#ifdef SCANNER_DIR
    if (listfind(g_classes, SCANNER_DIR) == -1)
        g_classes = listunion((list)SCANNER_DIR, g_classes);
#endif
#ifdef PARSER_DIR
    if (listfind(g_classes, PARSER_DIR) == -1)
        g_classes = listunion((list)PARSER_DIR, g_classes);
#endif
    g_nClasses = listlen(g_classes);
}