diff options
Diffstat (limited to 'bin/tibtoa')
-rwxr-xr-x | bin/tibtoa | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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; |