Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.

X Report information
Id: 18063
Status: resolved
Left: 0 min
Priority: 0/0
Queue: Spreadsheet-ParseExcel

Owner: Nobody
Requestors: grant_s [...] yahoo.com
Cc:
AdminCc:

Severity: Normal
Broken in: 0.2603
Fixed in: (no value)




X History Display mode: Brief headersFull headers
#   Wed Mar 08 13:05:59 2006 guest - Ticket created  
Subject: Perl warnings on lines 1789, 1790
[text/plain 958b]
When ParseExcel parses an XLS file with cells having certain
characteristics, it gives the following warnings:
Character in "c" format wrapped at Spreadsheet/ParseExcel.pm line 1789.
Character in "c" format wrapped at Spreadsheet/ParseExcel.pm line 1790.

I'm sorry, I don't know what conditions produce the warnings, but
those conditions are present in the first cell in the attached
spreadsheet, but not the other cell.

The warnings result from trying to unpack a 1-byte negative number,
while unpack() thinks it is looking at a 4-byte number. To fix, we
convert 1-byte negatives to 4-byte negatives by ORing with 0xFFFFFF00.

The exact source code patch is attached.

Distribution: Spreadsheet-ParseExcel-0.2603.tar.gz
Perl version: v5.8.0 built for aix-thread-multi
uname -a: AIX excelsioribm 2 5 00C0E82E4C00

Exact warning messages: see above
Code to reproduce: attached, show-warnings.pl with gives-warnings.xls
Patch to fix: attached, patch.txt
Subject: show-warnings.pl

[text/plain 177b]
#!/usr/bin/perl -w

use File::Basename;
use lib $ENV{HOME} . "/.perl";
use Spreadsheet::ParseExcel;

my $oBook = Spreadsheet::ParseExcel::Workbook->Parse('gives-warnings.xls');

Subject: gives-warnings.xls

[application/vnd.ms-excel 14.5k]
Message body not shown because it is too large or is not plain text.
Subject: patch.txt

[text/plain 565b]

Spreadsheet/ParseExcel.pm lines 1789-1790:
substr($sWk, 3, 1) &= pack('c', unpack("c",substr($sWk, 3, 1)) & 0xFC);
substr($lWk, 0, 1) &= pack('c', unpack("c",substr($lWk, 0, 1)) & 0xFC);

replace with:
my $u = unpack("c",substr($sWk, 3, 1)) & 0xFC;
$u |= 0xFFFFFF00 if ($u & 0x80); # raise neg bits for neg 1-byte value
substr($sWk, 3, 1) &= pack('c', $u);
$u = unpack("c",substr($lWk, 0, 1)) & 0xFC;
$u |= 0xFFFFFF00 if ($u & 0x80); # raise neg bits for neg 1-byte value
substr($lWk, 0, 1) &= pack('c', $u);

#   Mon Sep 11 10:38:26 2006 SZABGAB - Correspondence added  
[text/plain 392b]
On Wed Mar 08 13:05:59 2006, guest wrote:
> When ParseExcel parses an XLS file with cells having certain
> characteristics, it gives the following warnings:
> Character in "c" format wrapped at Spreadsheet/ParseExcel.pm line 1789.

You fix was applied, it will be released soon in
Spreadsheet-ParseExcel-0.27_02

many thanks for the test case and the fix
Gabor Szabo <szabgab[...]gmail.com>

#   Mon Sep 11 10:38:29 2006 RT_System - Status changed from 'new' to 'open'  
#   Thu Nov 27 11:18:51 2008 HMBRAND - Correspondence added  
[text/plain 2.2k]
On Mon Sep 11 10:38:26 2006, SZABGAB wrote:
> On Wed Mar 08 13:05:59 2006, guest wrote:
> > When ParseExcel parses an XLS file with cells having certain
> > characteristics, it gives the following warnings:
> > Character in "c" format wrapped at Spreadsheet/ParseExcel.pm line
1789.
>
> You fix was applied, it will be released soon in
> Spreadsheet-ParseExcel-0.27_02
>
> many thanks for the test case and the fix

This will break 64bit builds. I don't know if -256 is portable enough.

Without patch:

Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1597.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1601.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1597.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1601.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1597.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1601.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1597.
Character in 'c' format wrapped in pack at /pro/lib/perl5/
site_perl/5.8.8/Spreadsheet/ParseExcel.pm line 1601.

With patch it is clean:

--- lib/Spreadsheet/ParseExcel.pm.org 2008-11-27 17:15:02.000000000
+0100
+++ lib/Spreadsheet/ParseExcel.pm 2008-11-27 17:10:14.000000000
+0100
@@ -1593,11 +1593,11 @@ sub _UnpackRKRec {
elsif($iPtn == 1) {
# http://rt.cpan.org/Ticket/Display.html?id=18063
my $u31 = unpack("c",substr($sWk, 3, 1)) & 0xFC;
- $u31 |= 0xFFFFFF00 if ($u31 & 0x80); # raise neg bits for neg
1-byte value
+ $u31 |= -256 if ($u31 & 0x80); # raise neg bits for neg 1-byte
value
substr($sWk, 3, 1) &= pack('U', $u31);

my $u01 = unpack("c",substr($lWk, 0, 1)) & 0xFC;
- $u01 |= 0xFFFFFF00 if ($u01 & 0x80); # raise neg bits for neg
1-byte value
+ $u01 |= -256 if ($u01 & 0x80); # raise neg bits for neg 1-byte
value
substr($lWk, 0, 1) &= pack('U', $u01);

return ($iF, unpack("d", ($BIGENDIAN)? $sWk . "\0\0\0\0":
"\0\0\0\0". $lWk)/ 100);


#   Wed Jan 14 04:17:37 2009 JMCNAMARA - Subject changed from 'Perl warnings on lines 1789, 1790' to 'Perl warnings on lines 1789, 1790 (RK Number error)'  
#   Wed Aug 19 06:56:39 2009 JMCNAMARA - Correspondence added  
[text/plain 113b]
Fixed in version 0.50 od ParseExcel.

I rewrote the RK number conversion code and added a test suite.

John.
--

#   Wed Aug 19 06:56:40 2009 JMCNAMARA - Status changed from 'open' to 'resolved'