summaryrefslogtreecommitdiff
path: root/bin/tibtoa
diff options
context:
space:
mode:
Diffstat (limited to 'bin/tibtoa')
-rwxr-xr-xbin/tibtoa20
1 files changed, 19 insertions, 1 deletions
diff --git a/bin/tibtoa b/bin/tibtoa
index 9b15c1c..35055eb 100755
--- a/bin/tibtoa
+++ b/bin/tibtoa
@@ -6,7 +6,9 @@ use utf8;
binmode(STDOUT, ':utf8');
my ($char, $char2);
my $out;
+my $cache;
my $hex;
+my ($indent, $rindent);
my %all = (
0x01 => '►DMS',
0x02 => '►Dec',
@@ -607,6 +609,7 @@ my $special = {
open(PRGM, '<', shift) or die;
# Remove header added by tilp2
seek(PRGM, 74, 0);
+$indent = 0;
while(read(PRGM, $char, 1)) {
$char = ord($char);
if (exists($all{$char})) {
@@ -619,5 +622,20 @@ while(read(PRGM, $char, 1)) {
warn(sprintf('Unknown byte: %2x', $char));
$out = chr($char);
}
- print $out;
+ if ($out =~ /Then|While|Repeat|For/) {
+ $indent++;
+ } elsif ($out =~ /Else/) {
+ $rindent--;
+ } elsif ($out =~ /End/) {
+ $indent--;
+ $rindent--;
+ }
+ $cache .= $out;
+ if ($out eq "\n") {
+ print "\t" x $rindent;
+ $rindent = $indent;
+ print $cache;
+ $cache = '';
+ }
}
+print $cache;