formatchar: avoid annotation of empty cells (regression)
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 23 Dec 2010 21:41:30 +0000 (22:41 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 11 Jan 2011 22:41:38 +0000 (23:41 +0100)
Shiar_Sheet/FormatChar.pm

index 62f6791ba9f1e1d72332c87b30cc56b498d7dfe0..78f2a1934b1bcf8017d61164a776934a6091c495 100644 (file)
@@ -108,38 +108,40 @@ sub cell {
        }
 
        my $anno = '';
-       for (@{ $self->{anno} }) {
-               if (/html$/) {
-                       require HTML::Entities;
-                       if (my $entity = $HTML::Entities::char2entity{$cell}) {
-                               $entity = substr($entity, 1, -1) unless /^&/;
-                               $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($entity));
-                               last;
+       if ($cell ne '') {
+               for (@{ $self->{anno} }) {
+                       if (/html$/) {
+                               require HTML::Entities;
+                               if (my $entity = $HTML::Entities::char2entity{$cell}) {
+                                       $entity = substr($entity, 1, -1) unless /^&/;
+                                       $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($entity));
+                                       last;
+                               }
                        }
-               }
-               elsif ($_ eq 'xml') {
-                       $anno = sprintf(' <small class="digraph">%s</small>',
-                               sprintf '#%d', ord($cell)
-                       );
-                       last;
-               }
-               elsif ($_ eq '&xml') {
-                       $anno = sprintf(' <small class="digraph">%s</small>',
-                               sprintf '&amp;#%d;', ord($cell)
-                       );
-                       last;
-               }
-               elsif ($_ eq 'di') {
-                       if (defined $mnem and length $mnem) {
-                               $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem));
+                       elsif ($_ eq 'xml') {
+                               $anno = sprintf(' <small class="digraph">%s</small>',
+                                       sprintf '#%d', ord($cell)
+                               );
                                last;
                        }
-               }
-               else {
-                       if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
-                               $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $cell);
+                       elsif ($_ eq '&xml') {
+                               $anno = sprintf(' <small class="digraph">%s</small>',
+                                       sprintf '&amp;#%d;', ord($cell)
+                               );
                                last;
                        }
+                       elsif ($_ eq 'di') {
+                               if (defined $mnem and length $mnem) {
+                                       $anno = sprintf(' <small class="digraph">%s</small>', EscapeHTML($mnem));
+                                       last;
+                               }
+                       }
+                       else {
+                               if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) {
+                                       $anno = sprintf(' <small class="%s">%04X</small>', 'value', ord $cell);
+                                       last;
+                               }
+                       }
                }
        }