summaryrefslogtreecommitdiffstats
path: root/opengl/libs/tools/enumextract.sh
blob: 570730215f179aaf39cecdbf969975087547fe17 (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
#!/bin/sh

awk '
/^#define GL_/ {
    names[count] = $2;
    values[count] = $3;
    sort[count] = $3 + 0;
    count++;
}
END {
    for (i = 1; i < count; i++) {
        for (j = 0; j < i; j++) {
            if (sort[i] < sort[j]) {
                tn = names[i];
                tv = values[i];
                ts = sort[i];
                names[i] = names[j];
                values[i] = values[j];
                sort[i] = sort[j];
                names[j] = tn;
                values[j] = tv;
                sort[j] = ts;
            }
        }
    }
 
    for (i = 0; i < count; i++) {
        printf("GLENUM(%s, %s)\n", names[i], values[i]);
    }
}
' < $1