summaryrefslogtreecommitdiff
path: root/tools/binlang
diff options
context:
space:
mode:
Diffstat (limited to 'tools/binlang')
-rwxr-xr-xtools/binlang130
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
21if(!$ARGV[0] || !$ARGV[1] || !$ARGV[2]) { 21print <<MOO
22 print <<MOO 22The tool formerly known as 'binlang' is no longer used. We now use
23Usage: binlang <english file> <language file> <output file> 23genlang2 with the -b option to generate binary language files.
24
25Generate a binary language file.
26MOO 24MOO
27; 25;
28 exit;
29}
30
31if($ARGV[0] eq "-v") {
32 shift @ARGV;
33 $debug=1;
34}
35
36my $english = $ARGV[0];
37my $input = $ARGV[1];
38my $output = $ARGV[2];
39
40my $idnum=0;
41
42open(ENG, "<$english") or die "Can't open $english";
43open(LANG, "<$input") or die "Can't open $input";
44open(OUTF, ">$output") or die "Can't open $output";
45
46my $langversion = 3;
47
48binmode OUTF;
49
50printf 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#
55my $idnum=0; # start with a true number
56while(<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}
86close(ENG);
87
88while(<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}
137close(LANG);
138
139close(OUTF);
140
141foreach $k (keys(%idnum))
142{
143 if($idnum{$k} ne '_done_')
144 {
145 warn "Missing ID in $input: $k\n";
146 }
147}