diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-12-30 19:21:57 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-12-30 19:21:57 +0100 |
commit | cecb9698c8c3cf8b82df3e54f4cb7edb1be0a2b3 (patch) | |
tree | c7080fdaf728cd0e7c599b1357528d0c9ad30698 /bin/tibtoa | |
parent | 35c6eb861ee57c6db3030f3329d6c828324aebf2 (diff) |
tibtoa: -i to indent
Diffstat (limited to 'bin/tibtoa')
-rwxr-xr-x | bin/tibtoa | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -3,12 +3,15 @@ use strict; use feature 'switch'; use warnings; use utf8; +use Getopt::Std; + binmode(STDOUT, ':utf8'); my ($char, $char2); my $out; my $cache; my $hex; my ($indent, $rindent); +my %opts; my %all = ( 0x01 => '►DMS', 0x02 => '►Dec', @@ -606,6 +609,8 @@ my $special = { }, }; +getopts('i', \%opts); + open(PRGM, '<', shift) or die; # Remove header added by tilp2 seek(PRGM, 74, 0); @@ -622,13 +627,15 @@ while(read(PRGM, $char, 1)) { warn(sprintf('Unknown byte: %2x', $char)); $out = chr($char); } - if ($out =~ /Then|While|Repeat|For/) { - $indent++; - } elsif ($out =~ /Else/) { - $rindent--; - } elsif ($out =~ /End/) { - $indent--; - $rindent--; + if ($opts{i}) { + if ($out =~ /Then|While|Repeat|For/) { + $indent++; + } elsif ($out =~ /Else/) { + $rindent--; + } elsif ($out =~ /End/) { + $indent--; + $rindent--; + } } $cache .= $out; if ($out eq "\n") { |