X-Git-Url: http://git.rot13.org/?p=Printer-Zebra.git;a=blobdiff_plain;f=ZPL2pbm.pl;h=e54e8fd2e10ea469d82d4409c881905f06574386;hp=e3126655289cac2e8a4e1c5ad1192a321ae2f00e;hb=05f9a467e24bdd81da8785dd4b72db83e9fb5189;hpb=96a1ba71842d19c9a0c18576c45e3e367f88c9ce diff --git a/ZPL2pbm.pl b/ZPL2pbm.pl index e312665..e54e8fd 100755 --- a/ZPL2pbm.pl +++ b/ZPL2pbm.pl @@ -13,7 +13,7 @@ while() { $command->{$cmd} = $desc; } -my $file = shift @ARGV || die "usage: $0 dump.zpl > dump.pbm"; +my $file = shift @ARGV || die "usage: $0 dump.zpl > dump.pbm\n"; open(my $in, '<', $file); @@ -35,11 +35,20 @@ while( $line ) { my $w = $row_bytes * 2; # hex digits - my $out; + my $out = ''; # ZPL decompress my $repeat = 0; foreach my $p ( 0 .. length($data) - 1 ) { + + if ( length($out) == $total_bytes * 2 ) { + warn "END of bitmap\n"; + $line = substr($data,$p); + slurp_line; + last; + }; + my $c = substr($data,$p,1); + if ( $c eq ',' ) { my $l = $w - ( length($out) % $w ); $l = $w if $l == 0; @@ -70,10 +79,7 @@ while( $line ) { $out .= $c; } } else { - warn "ABORT: offset $p data [$c]"; - $line = $c . substr($data,$p); - slurp_line; - last; + die "ABORT: offset $p data [$c]"; } warn "## $repeat [$c] out = ",length($out),$/;