charset: common check of compare option
[sheet.git] / charset.plp
index 7ff3f420a2dd25d4dc652ad67231193da1313a2b..d2c92c5378c4227e8917ba419e7d3f2cee6c723d 100644 (file)
@@ -1,5 +1,8 @@
 <(common.inc.plp)><:
 
+my $mode = exists $get{compare};
+my @tablist = split m{/+}, $Request || 'default';
+
 Html({
        title => 'charset cheat sheet',
        version => '1.0',
@@ -18,8 +21,6 @@ Html({
        )],
 });
 
-my @tablist = split m{/+}, $Request || 'default';
-
 use List::Util qw( first pairmap pairfirst pairs );
 
 :>
@@ -76,7 +77,7 @@ use Shiar_Sheet::FormatChar;
 my $glyphs = Shiar_Sheet::FormatChar->new;
 my @request;
 
-my $INHERIT = do 'charset-encoding.inc.pl'
+my $charsets = do 'charset-encoding.inc.pl'
        or Alert('Encoding metadata could not be read', $@ || $!);
 
 sub tabinput {
@@ -136,7 +137,8 @@ sub tabinput {
        my $params = $input =~ s/[+](.*)\z// ? $1 : undef;
 
        if (not defined $params) {
-               my @parents = @{ $INHERIT->{$input} || [] };
+               my $charset = $charsets->{$input} || {};
+               my @parents = @{ $charset->{inherit} || [] };
 
                if (my ($parent, $part) = pairfirst { defined $visible->{$a} } @parents) {
                        $row{parent} = $parent;
@@ -403,7 +405,7 @@ for my $row (@request) {
                        my ($cell, $name, $class) = $glyph eq $NOCHAR ? () :
                                $glyphs->glyph_html($glyph);
 
-                       if (exists $get{compare}) {
+                       if ($mode) {
                                state $visible = {};
                                $class = (
                                        $cp == ord $glyph ? 'l4' :
@@ -430,7 +432,7 @@ for my $row (@request) {
 <hr>
 
 <div class="legend">
-       <table class="glyphs"><tr><: if (exists $get{compare}) { :>
+       <table class="glyphs"><tr><: if ($mode) { :>
        <td class="X l4">unicode
        <td class="X l3">inherited
        <td class="X l2">existing