Sweden-Number/dlls/dxerr9/errors.awk

81 lines
1.6 KiB
Awk
Raw Normal View History

2004-03-10 00:25:57 +01:00
BEGIN {
print "/* Machine generated. Do not edit. */"
print ""
lines = 0
}
{
split($0, array, FS)
if (NF > 0 && length(array[1]) > 0) {
lines++
2005-11-10 12:39:07 +01:00
# save the first word (or '&' separated list of words) in the names array
if (array[2] == "&") {
if (array[4] == "&") {
names[lines] = array[1] " " array[2] " " array[3] " " array[4] " " array[5]
start = 6
} else {
names[lines] = array[1] " " array[2] " " array[3]
start = 4
}
} else {
names[lines] = array[1]
start = 2
}
2004-03-10 00:25:57 +01:00
# create the WCHAR version of the name
printf "static const WCHAR name%dW[] = { ", lines
i = 1
len = length(names[lines]) + 1
2004-03-10 00:25:57 +01:00
while (i < len) {
printf "'%s',", substr(names[lines],i,1)
2004-03-10 00:25:57 +01:00
i++
}
print "0 };"
# create the CHAR version of the description
printf "static const CHAR description%dA[] = \"", lines
word = start
2004-03-10 00:25:57 +01:00
while (word < (NF + 1)) {
printf "%s", array[word]
if (word < NF )
printf " "
word++
}
print "\";"
# create the WCHAR version of the description
printf "static const WCHAR description%dW[] = { ", lines
word = start
2004-03-10 00:25:57 +01:00
while (word < (NF + 1)) {
i = 1
len = length(array[word]) + 1
while (i < len) {
if (substr(array[word],i,1) == "'")
printf "'\\'',"
else
printf "'%s',", substr(array[word],i,1)
2004-03-10 00:25:57 +01:00
i++
}
if (word < NF )
printf "' ',"
word++
}
print "0 };"
}
}
END {
print ""
print "static const error_info info[] = {"
i = 1
while ( i <= lines) {
split(names[i], words, FS)
2004-03-10 00:25:57 +01:00
printf " { %s, \"%s\", name%dW, description%dA, description%dW },\n",
words[1], names[i], i, i,i
2004-03-10 00:25:57 +01:00
i++
}
print "};"
}