From b4c97cd198613dd4631b970ab4e55915237787f7 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 6 Apr 2017 21:06:56 +0200 Subject: [PATCH] charset: distinct column count per table Prevent unicode planes from affecting other tables. --- charset.plp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/charset.plp b/charset.plp index 73b3740..8dfa91e 100644 --- a/charset.plp +++ b/charset.plp @@ -22,7 +22,6 @@ Html({ use POSIX qw( ceil ); use Shiar_Sheet::FormatChar; my $glyphs = Shiar_Sheet::FormatChar->new; -my $cols = 16; # columns # generate character table(s) # (~16x faster than decoding in loop; @@ -39,7 +38,7 @@ my %ALIAS = ( ); my @request = map { if (my $input = $_) { - my %row = (offset => 0); + my %row = (offset => 0, cols => 16); my $endpoint = 255; if ($input =~ s/^--//) { $row{offset} = $endpoint > 160 ? 160 : 48; @@ -67,7 +66,7 @@ my @request = map { $row{set} = 'Unicode planes'; $row{cell} = do 'charset-ucplanes.inc.pl' or Alert('Table data could not be read', $@ || $!); - $cols *= 2; + $row{cols} *= 2; } elsif ($row{set} = Encode::resolve_alias($input)) { if ($row{set} eq 'Internal') { @@ -107,10 +106,12 @@ for my $cp437 (grep {$request[$_]->{set} eq 'cp437'} 0 .. $#request) { } sub range_cell { - my ($table, $offset) = @_; + my ($info, $offset) = @_; + my $table = $info->{cell} or return; my $def = $table->{$offset} or return; my ($len, $class, $name, $title) = @{$def}; + my $cols = $info->{cols}; my $colsize = $table->{colsize} || 1; my $attr = ''; $len /= $colsize; @@ -157,6 +158,7 @@ sub range_cell { } for my $row (@request) { + my $cols = $row->{cols}; my $colsize = $row->{cell} && $row->{cell}->{colsize} || 1; my $coldigits = ceil(log($colsize * $cols) / log(16)); # uniform length of hexadecimal header my $rowdiv = 16 ** $coldigits; # divider of row headers @@ -188,7 +190,7 @@ for my $row (@request) { for my $lsb (0 .. $cols - 1) { my $val = ( ($msb * $cols) + $lsb ) * $colsize; if ($row->{cell}) { - print range_cell($row->{cell}, $val); + print range_cell($row, $val); next; } -- 2.30.0