Skip Menu |

This queue is for tickets about the Text-Banner CPAN distribution.

Report information
The Basics
Id: 85381
Status: resolved
Priority: 0/
Queue: Text-Banner

People
Owner: gsullivan [...] cpan.org
Requestors: Josh.Nekl [...] analog.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.00



Subject: Text::Banner default fill and multiple '0' characters
Date: Fri, 17 May 2013 11:55:05 -0400
To: <bug-Text-Banner [...] rt.cpan.org>
From: Joshua Nekl <josh.nekl [...] analog.com>
The following code illustrates the two bugs in Text::Banner #! /usr/bin/env perl use Text::Banner; my $a = Text::Banner->new; $a->set('1030'); print $a->get; The output is not displayed in their own characters, but the bit-mapped '1's and '0's. 0001000 0011100 0111110 0011100 0011000 0100010 1000001 0100010 0101000 1000001 0000001 1000001 0001000 1000001 0111110 1000001 0001000 1000001 0000001 1000001 0001000 0100010 1000001 0100010 0111110 0011100 0111110 0011100 This can be fixed by removing the if statement for the call to _CHANGE in the set subroutine (patch below). The second bug occurs if a zero '0' character appears multiple times in the output string or if a character appears multiple times in the string and a fill character of '0' is used. The display of "1030" results in 1 33333 11 3 3 1 1 3 1 33333 1 3 1 3 3 11111 33333 In the _CHANGE subroutine, the substitution is repeated if characters are repeated in the output. The first time the bitmapped '0' gets changed to space ' ' and the bitmapped '1's changed to the output character '0'. During the second substitution the output '0's get changed to spaces ' '. The substitution should only occur once for each character. This can be fixed by iterating over the keys of PIC instead of STRING in the _CHANGE subroutine (patch below). 1 000 33333 000 11 0 0 3 3 0 0 1 1 0 0 3 0 0 1 0 0 33333 0 0 1 0 0 3 0 0 1 0 0 3 3 0 0 11111 000 33333 000 --- Banner.pm.orig 2013-05-17 11:11:47.000000000 -0400 +++ Banner.pm 2013-05-17 11:35:04.000000000 -0400 @@ -63,7 +63,7 @@ } sub _CHANGE { my $self=shift; my $char; - foreach $char (@{$self->{STRING}}) { + foreach $char (keys %{$self->{PIC}}) { foreach (@{$self->{PIC}->{$char}}) { s/0/ /g; if ($self->{FILL}) { s/[^\s]|1/$self->{FILL}/g; } else { s/[^\s]/$char/g; } @@ -85,7 +85,7 @@ foreach (0,7,14,21,28,35,42,49) { push @{$self->{PIC}->{$char}}, substr($temp,$_,7); } push @{$self->{PIC}->{$char}},"0000000"; # this is spacing between lines } - $self->_CHANGE if $self->{FILL}; + $self->_CHANGE; return undef; } sub _BLOWUP { Regards, Joshua Nekl <Josh.Nekl@analog.com>
Thanks for the patch. The patch has been applied, and a new test was created.