blob: 0a785371920e038bc5bb78d5408969d3d1468b83 [file] [log] [blame]
Robert Reifcc02d952004-03-09 23:25:57 +00001BEGIN {
2 print "/* Machine generated. Do not edit. */"
3 print ""
4 lines = 0
5}
6{
7 split($0, array, FS)
8
9 if (NF > 0 && length(array[1]) > 0) {
10 lines++
11
Francois Gougetf4c05242005-11-10 11:39:07 +000012 # save the first word (or '&' separated list of words) in the names array
Robert Reif8a4e04a2005-10-03 10:15:15 +000013 if (array[2] == "&") {
14 if (array[4] == "&") {
15 names[lines] = array[1] " " array[2] " " array[3] " " array[4] " " array[5]
16 start = 6
17 } else {
18 names[lines] = array[1] " " array[2] " " array[3]
19 start = 4
20 }
21 } else {
22 names[lines] = array[1]
23 start = 2
24 }
Robert Reifcc02d952004-03-09 23:25:57 +000025
26 # create the WCHAR version of the name
27 printf "static const WCHAR name%dW[] = { ", lines
28 i = 1
Robert Reif8a4e04a2005-10-03 10:15:15 +000029 len = length(names[lines]) + 1
Robert Reifcc02d952004-03-09 23:25:57 +000030 while (i < len) {
Robert Reif8a4e04a2005-10-03 10:15:15 +000031 printf "'%s',", substr(names[lines],i,1)
Robert Reifcc02d952004-03-09 23:25:57 +000032 i++
33 }
34 print "0 };"
35
36 # create the CHAR version of the description
37 printf "static const CHAR description%dA[] = \"", lines
Robert Reif8a4e04a2005-10-03 10:15:15 +000038 word = start
Robert Reifcc02d952004-03-09 23:25:57 +000039 while (word < (NF + 1)) {
40 printf "%s", array[word]
41 if (word < NF )
42 printf " "
43 word++
44 }
45 print "\";"
46
47 # create the WCHAR version of the description
48 printf "static const WCHAR description%dW[] = { ", lines
Robert Reif8a4e04a2005-10-03 10:15:15 +000049 word = start
Robert Reifcc02d952004-03-09 23:25:57 +000050 while (word < (NF + 1)) {
51 i = 1
52 len = length(array[word]) + 1
53 while (i < len) {
Francois Gougetaca7f802005-11-10 11:07:20 +000054 if (substr(array[word],i,1) == "'")
Robert Reif3468a802005-09-23 10:08:57 +000055 printf "'\\'',"
56 else
57 printf "'%s',", substr(array[word],i,1)
Robert Reifcc02d952004-03-09 23:25:57 +000058 i++
59 }
60 if (word < NF )
61 printf "' ',"
62 word++
63 }
64 print "0 };"
65 }
66}
67END {
68 print ""
69 print "static const error_info info[] = {"
70
71 i = 1
72 while ( i <= lines) {
Robert Reif8a4e04a2005-10-03 10:15:15 +000073 split(names[i], words, FS)
Robert Reifcc02d952004-03-09 23:25:57 +000074 printf " { %s, \"%s\", name%dW, description%dA, description%dW },\n",
Robert Reif8a4e04a2005-10-03 10:15:15 +000075 words[1], names[i], i, i,i
Robert Reifcc02d952004-03-09 23:25:57 +000076 i++
77 }
78
79 print "};"
80}