diff options
Diffstat (limited to 'tools/binlang')
-rwxr-xr-x | tools/binlang | 130 |
1 files changed, 4 insertions, 126 deletions
diff --git a/tools/binlang b/tools/binlang index 053180317a..90681348f9 100755 --- a/tools/binlang +++ b/tools/binlang | |||
@@ -8,7 +8,7 @@ | |||
8 | # \/ \/ \/ \/ \/ | 8 | # \/ \/ \/ \/ \/ |
9 | # $Id$ | 9 | # $Id$ |
10 | # | 10 | # |
11 | # Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se> | 11 | # Copyright (C) 2002, 2006 by Daniel Stenberg <daniel@haxx.se> |
12 | # | 12 | # |
13 | # All files in this archive are subject to the GNU General Public License. | 13 | # All files in this archive are subject to the GNU General Public License. |
14 | # See the file COPYING in the source tree root for full license agreement. | 14 | # See the file COPYING in the source tree root for full license agreement. |
@@ -18,130 +18,8 @@ | |||
18 | # | 18 | # |
19 | ############################################################################ | 19 | ############################################################################ |
20 | 20 | ||
21 | if(!$ARGV[0] || !$ARGV[1] || !$ARGV[2]) { | 21 | print <<MOO |
22 | print <<MOO | 22 | The tool formerly known as 'binlang' is no longer used. We now use |
23 | Usage: binlang <english file> <language file> <output file> | 23 | genlang2 with the -b option to generate binary language files. |
24 | |||
25 | Generate a binary language file. | ||
26 | MOO | 24 | MOO |
27 | ; | 25 | ; |
28 | exit; | ||
29 | } | ||
30 | |||
31 | if($ARGV[0] eq "-v") { | ||
32 | shift @ARGV; | ||
33 | $debug=1; | ||
34 | } | ||
35 | |||
36 | my $english = $ARGV[0]; | ||
37 | my $input = $ARGV[1]; | ||
38 | my $output = $ARGV[2]; | ||
39 | |||
40 | my $idnum=0; | ||
41 | |||
42 | open(ENG, "<$english") or die "Can't open $english"; | ||
43 | open(LANG, "<$input") or die "Can't open $input"; | ||
44 | open(OUTF, ">$output") or die "Can't open $output"; | ||
45 | |||
46 | my $langversion = 3; | ||
47 | |||
48 | binmode OUTF; | ||
49 | |||
50 | printf OUTF ("\x1a%c", $langversion); # magic lang file header | ||
51 | |||
52 | # | ||
53 | # We scan the english file to get the correct order of the id numbers | ||
54 | # | ||
55 | my $idnum=0; # start with a true number | ||
56 | while(<ENG>) { | ||
57 | if($_ =~ / *\#/) { | ||
58 | # comment | ||
59 | next; | ||
60 | } | ||
61 | # get rid of DOS newlines | ||
62 | $_ =~ s/\r//g; | ||
63 | if($_ =~ /^ *([a-z]+): *(.*)/) { | ||
64 | ($var, $value) = ($1, $2); | ||
65 | $set{$var} = $value; | ||
66 | |||
67 | # "new" is always the last one, so now we have them all | ||
68 | if($var eq "new") { | ||
69 | $value = $set{'eng'}; | ||
70 | |||
71 | if($value =~ s/^\"(.*)\"\s*$/$1/g) { | ||
72 | # Skip voice-only entries | ||
73 | if($set{'id'} =~ /^VOICE_/) { | ||
74 | $idnum{$set{'id'}} = '_done_'; | ||
75 | next; | ||
76 | } | ||
77 | |||
78 | # Assign an ID number to this entry | ||
79 | $idnum{$set{'id'}}=$idnum; | ||
80 | $idnum++; | ||
81 | } | ||
82 | undef %set; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | close(ENG); | ||
87 | |||
88 | while(<LANG>) { | ||
89 | if($_ =~ /^ *\#/) { | ||
90 | # comment | ||
91 | next; | ||
92 | } | ||
93 | # get rid of DOS newlines | ||
94 | $_ =~ s/\r//g; | ||
95 | if($_ =~ /^ *([a-z]+): *(.*)/) { | ||
96 | ($var, $value) = ($1, $2); | ||
97 | |||
98 | $set{$var} = $value; | ||
99 | |||
100 | # "new" is always the last one, so now we have them all | ||
101 | if($var eq "new") { | ||
102 | $idnum = $idnum{$set{'id'}}; | ||
103 | |||
104 | # Skip already processed entries (like voice-only ones) | ||
105 | next if($idnum eq '_done_'); | ||
106 | |||
107 | if(!$value) { | ||
108 | # if not set, get the english version | ||
109 | $value = $set{'eng'}; | ||
110 | } | ||
111 | |||
112 | if($value =~ s/^\"(.*)\"\s*$/$1/g) { | ||
113 | if($idnum eq "") { | ||
114 | warn "Found no ".$set{'id'}." in english file!\n"; | ||
115 | } | ||
116 | else { | ||
117 | $idnum{$set{'id'}} = '_done_'; | ||
118 | |||
119 | printf OUTF ("%c%c%s\x00", | ||
120 | ($idnum>>8), ($idnum&0xff), | ||
121 | $value); | ||
122 | if($debug) { | ||
123 | printf("%02x => %s\n", $idnum, $value); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | else { | ||
128 | warn "String for ".$set{'id'}." misses quotes\n"; | ||
129 | } | ||
130 | |||
131 | undef %set; | ||
132 | } | ||
133 | |||
134 | } | ||
135 | |||
136 | } | ||
137 | close(LANG); | ||
138 | |||
139 | close(OUTF); | ||
140 | |||
141 | foreach $k (keys(%idnum)) | ||
142 | { | ||
143 | if($idnum{$k} ne '_done_') | ||
144 | { | ||
145 | warn "Missing ID in $input: $k\n"; | ||
146 | } | ||
147 | } | ||