Skip Menu |

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

Report information
The Basics
Id: 8952
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: Text-TabularDisplay

People
Owner: darren [...] cpan.org
Requestors: fischerdk [...] fidoki.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.20
Fixed in: (no value)



Subject: _format_line() converts zeros to nulls
The sprintf statement in _format_line() uses a || operator to determine whether to output the value contained in $col_lines[$i][$h] or ''. I'm assuming the intent here was to catch null or undefined values. However, this will catch any "false" value, including the number zero (0) as well as the zero string "0". As a result, any field that consists of the number zero or the zero string will be replaced with null ''. The following patch will correct this: @@ -263,8 +263,8 @@ for my $h (0 .. $height - 1 ) { my @line; for (my $i = 0; $i <= $#$columns; $i++) { - push @line, - sprintf " %-" . $lengths->[$i] . "s ", $col_lines[$i][$h] || ''; + my $val = defined($col_lines[$i][$h]) ? $col_lines[$i][$h] : ''; + push @line, sprintf " %-" . $lengths->[$i] . "s ", $val; } push @lines, join '|', "", @line, ""; } Cheers
[guest - Thu Dec 16 15:32:14 2004]: Show quoted text
> The sprintf statement in _format_line() uses a || operator to > determine whether to output the value contained in > $col_lines[$i][$h] or ''. I'm assuming the intent here was to catch > null or undefined values. However, this will catch any "false" > value, including the number zero (0) as well as the zero string > "0". As a result, any field that consists of the number zero or the > zero string will be replaced with null ''.
This has been sitting here for years now, and I keep forgetting to actually apply the patch and release the new version. Well, I apologize. I'm applying it now, and version 1.21 will be on its way to CPAN soon, with the update.
On Fri Dec 09 16:01:20 2005, DARREN wrote: Show quoted text
> This has been sitting here for years now, and I keep forgetting to > actually apply the patch and release the new version. Well, I > apologize. I'm applying it now, and version 1.21 will be on its way to > CPAN soon, with the update.
Version 1.22 is on CPAN now.