stats.awk
1.2 KB
/^#define[ ]*ST_/ {
name = $2;
if (names[$3])
print "/* Multiple match on number " $3 " */";
names[$3] = name;
if ($3 > maxval) maxval = $3;
desc = "";
if (NF > 6) {
for (i = 5; i < NF-1; i++)
desc = desc " " $i;
} else
desc = name;
descs[$3] = desc;
next;
}
{ next; }
END {
print "/* Warning - File generated automatically */"
print "char *stat_names[] = {"
for (i = 0; i < maxval+1; i++) {
print "\"" descs[i] "\", /* " i " */";
}
print "};"
print "char *sh_stat_names[] = {"
for (i = 0; i < maxval+1; i++) {
print "\"" names[i] "\", /* " i " */";
}
print "};"
}