Subject: | Wrong value type for negative integers (with fix) |
Date: | Fri, 03 Jun 2011 16:55:28 +0200 |
To: | bug-xmlrpc-pureperl [...] rt.cpan.org |
From: | Claus Brunzema <Claus.Brunzema [...] energymeteo.de> |
Hello Ryan Alan Dietrich,
thanks for the nice (dependency-free) xmlrpc-module, it is really handy
for small scripts and quick testing. It is, however, currently not
possible to correctly send negative integer values, because the leading
minus sign causes a regexp mismatch and the value is sent as string. The
following patch fixes the regex (similar to the float detection):
diff -rc xmlrpc-pureperl.original/lib/XMLRPC/PurePerl.pm xmlrpc-pureperl/lib/XMLRPC/PurePerl.pm
*** xmlrpc-pureperl.original/lib/XMLRPC/PurePerl.pm 2006-06-06 09:08:46.000000000 +0200
--- xmlrpc-pureperl/lib/XMLRPC/PurePerl.pm 2011-06-01 17:44:44.102698172 +0200
***************
*** 216,222 ****
if ( ! $ref ) {
if ( $obj =~ /^\-?[0-9]+\.[0-9]*$/ ) {
${$xml} .= "<value><double>$obj</double></value>\n";
! } elsif ( $obj =~ /^[0-9]+$/ ) {
${$xml} .= "<value><i4>$obj</i4></value>\n";
} else {
${$xml} .= "<value><string>" . &_entity_encode($obj) . "</string></value>\n";
--- 216,222 ----
if ( ! $ref ) {
if ( $obj =~ /^\-?[0-9]+\.[0-9]*$/ ) {
${$xml} .= "<value><double>$obj</double></value>\n";
! } elsif ( $obj =~ /^-?[0-9]+$/ ) {
${$xml} .= "<value><i4>$obj</i4></value>\n";
} else {
${$xml} .= "<value><string>" . &_entity_encode($obj) . "</string></value>\n";
I used xmlrpc-pureperl-0.01 and perl v5.10.1 on Fedora release 13
(Goddard).
Cheers
Claus
--
Claus Brunzema
energy & meteo systems GmbH
Marie-Curie-Str. 1
26129 Oldenburg
Germany
fon +49(0) 441 36116 487
fax +49(0) 441 36116 479
claus.brunzema@energymeteo.de
www.energymeteo.de
energy & meteo systems GmbH, Oldenburg
Geschäftsführer: Dr. Ulrich Focken, Dr. Matthias Lange
Amtsgericht Oldenburg HRB Nr. 5596
Email disclaimer
www.energymeteo.com/en/06_contact/disclaimer.php