~ chicken-core (master) /scripts/foldcase.awk
Trap1function num(x) {
2 return substr(x, 1, length(x) - 1)
3}
4BEGIN {
5 print "static int fold1[][ 2 ] = {"
6 i = 0
7}
8/ S;/ {print " {0x" num($1) ", 0x" num($3) "},"}
9/ C;/ {print " {0x" num($1) ", 0x" num($3) "},"}
10/ F;/ {
11 if(match($5, /;$/)) {
12 c[ i ] = $4
13 d[ i ] = num($5)
14 } else {
15 c[ i ] = num($4)
16 d[ i ] = 0
17 }
18 a[ i ] = num($1); b[ i++ ] = $3
19}
20END {
21 print "};"
22 print "static int fold2[][ 4 ] = {"
23 for(j = 0; j < i; ++j) {
24 print " {0x" a[ j ] ", 0x" b[ j ] ", 0x" c[ j ] ", 0x" d[ j ] "},"
25 }
26 print "};"
27}