aboutsummaryrefslogtreecommitdiff
path: root/messages.pl
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-26 16:26:32 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-26 16:26:32 -0500
commitb37ac0ede97639931bd540fe34848eb8bf52764b (patch)
treefe1127c9d0eb22329a7d96b06f8f884109cb9650 /messages.pl
parentf3b7f8c68e6fe58aad1d093b4efc4eb665ff2788 (diff)
downloadtaipan-b37ac0ede97639931bd540fe34848eb8bf52764b.tar.gz
more dict entries, better comments, fix cart docs
Diffstat (limited to 'messages.pl')
-rw-r--r--messages.pl17
1 files changed, 13 insertions, 4 deletions
diff --git a/messages.pl b/messages.pl
index 0d68f4d..1120a8b 100644
--- a/messages.pl
+++ b/messages.pl
@@ -2,7 +2,11 @@
# compresses messages for taipan.c.
# messages are listed at the end of this file after __END__ marker.
+# Run with no arguments to encode all messages, in which case the
# output of this script should be redirected to messages.c.
+# With an argument, encoding is not done: instead, the strings
+# to be encoded are dumped to stdout, *after* dictionary
+# substitution is done.
# make dictionary from textdecomp.s comments
open my $t, "<textdecomp.s" or die $!;
@@ -35,7 +39,7 @@ while(<DATA>) {
s/^\w+\s+//;
my $orig = $_;
- #warn "msg: $_\n";
+ print " input: $_\n" if @ARGV;
s/"//g;
s/\\r//g;
s/\\n/\n/g;
@@ -49,9 +53,12 @@ while(<DATA>) {
}
}
- my $w = $_;
- $w =~ s/\n/\\n/g;
- #warn "got: \"$w\"\n";
+ if(@ARGV) {
+ my $w = $_;
+ $w =~ s/\n/\\n/g;
+ print "output: \"$w\"\n\n";
+ next;
+ }
open my $out, ">msg.out" or die $!;
print $out $_;
close $out;
@@ -69,6 +76,8 @@ while(<DATA>) {
print "\n};" . ($dict_used ? " // dictionary used" : "") . "\n\n";
}
+exit 0 if @ARGV;
+
print "// messages: $msgcount\n";
print "// total input size: $total_in\n";
print "// total output size: $total_out\n";