From 0e8416907674da88819b70d6db208fa490d0f946 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 23 Dec 2010 22:41:30 +0100 Subject: [PATCH] formatchar: avoid annotation of empty cells (regression) --- Shiar_Sheet/FormatChar.pm | 56 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/Shiar_Sheet/FormatChar.pm b/Shiar_Sheet/FormatChar.pm index 62f6791..78f2a19 100644 --- a/Shiar_Sheet/FormatChar.pm +++ b/Shiar_Sheet/FormatChar.pm @@ -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(' %s', 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(' %s', EscapeHTML($entity)); + last; + } } - } - elsif ($_ eq 'xml') { - $anno = sprintf(' %s', - sprintf '#%d', ord($cell) - ); - last; - } - elsif ($_ eq '&xml') { - $anno = sprintf(' %s', - sprintf '&#%d;', ord($cell) - ); - last; - } - elsif ($_ eq 'di') { - if (defined $mnem and length $mnem) { - $anno = sprintf(' %s', EscapeHTML($mnem)); + elsif ($_ eq 'xml') { + $anno = sprintf(' %s', + sprintf '#%d', ord($cell) + ); last; } - } - else { - if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) { - $anno = sprintf(' %04X', 'value', ord $cell); + elsif ($_ eq '&xml') { + $anno = sprintf(' %s', + sprintf '&#%d;', ord($cell) + ); last; } + elsif ($_ eq 'di') { + if (defined $mnem and length $mnem) { + $anno = sprintf(' %s', EscapeHTML($mnem)); + last; + } + } + else { + if ($_ eq 'hex' or $cell =~ /^[^a-zA-Z]$/) { + $anno = sprintf(' %04X', 'value', ord $cell); + last; + } + } } } -- 2.30.0