Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 1 | BEGIN { |
| 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 Gouget | f4c0524 | 2005-11-10 11:39:07 +0000 | [diff] [blame] | 12 | # save the first word (or '&' separated list of words) in the names array |
Robert Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 13 | 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 Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 25 | |
| 26 | # create the WCHAR version of the name |
| 27 | printf "static const WCHAR name%dW[] = { ", lines |
| 28 | i = 1 |
Robert Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 29 | len = length(names[lines]) + 1 |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 30 | while (i < len) { |
Robert Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 31 | printf "'%s',", substr(names[lines],i,1) |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 32 | i++ |
| 33 | } |
| 34 | print "0 };" |
| 35 | |
| 36 | # create the CHAR version of the description |
| 37 | printf "static const CHAR description%dA[] = \"", lines |
Robert Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 38 | word = start |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 39 | 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 Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 49 | word = start |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 50 | while (word < (NF + 1)) { |
| 51 | i = 1 |
| 52 | len = length(array[word]) + 1 |
| 53 | while (i < len) { |
Francois Gouget | aca7f80 | 2005-11-10 11:07:20 +0000 | [diff] [blame] | 54 | if (substr(array[word],i,1) == "'") |
Robert Reif | 3468a80 | 2005-09-23 10:08:57 +0000 | [diff] [blame] | 55 | printf "'\\''," |
| 56 | else |
| 57 | printf "'%s',", substr(array[word],i,1) |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 58 | i++ |
| 59 | } |
| 60 | if (word < NF ) |
| 61 | printf "' '," |
| 62 | word++ |
| 63 | } |
| 64 | print "0 };" |
| 65 | } |
| 66 | } |
| 67 | END { |
| 68 | print "" |
| 69 | print "static const error_info info[] = {" |
| 70 | |
| 71 | i = 1 |
| 72 | while ( i <= lines) { |
Robert Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 73 | split(names[i], words, FS) |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 74 | printf " { %s, \"%s\", name%dW, description%dA, description%dW },\n", |
Robert Reif | 8a4e04a | 2005-10-03 10:15:15 +0000 | [diff] [blame] | 75 | words[1], names[i], i, i,i |
Robert Reif | cc02d95 | 2004-03-09 23:25:57 +0000 | [diff] [blame] | 76 | i++ |
| 77 | } |
| 78 | |
| 79 | print "};" |
| 80 | } |