[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Math::BigInt dislikes undefined values



Hi;

Can you email me this patch as an attachment?  I have trouble pasting from my web-mail to patch.

Best Wishes,
Chris travers

On Tue, Oct 9, 2012 at 11:51 AM, <..hidden..> wrote:
Greeting all.
I recently upgraded to perl 5.16.1 am noticing Math::BigInt.pm does not
like undefined or zero values from Form.pm sub sub db_parse_numeric.
It will complain cant call method "is_zero" on an undefined value

Is it OK to check if we have a defined value in $arrayref->[$_] and
$names->[$_] then call Math::whatever rather than call first then
determine if $hashref is defined?

The following patch illustrates my idea and eliminates the error:
---Begin patch
--- Form.pm     2012-10-09 11:27:19.478584216 -0700
+++ Form.pm.1   2012-10-09 11:27:12.999585237 -0700
@@ -608,10 +608,8 @@
     for (0 .. $#names) {
         #   numeric            real/float4
         if ($types[$_] == 3 or $types[$_] == 2){
-            $arrayref->[$_] = Math::BigFloat->new($arrayref->[$_])
-              if defined $arrayref;
-            $hashref->{$names[$_]} =
Math::BigFloat->new($hashref->{$names[$_]})
-              if defined $hashref;
+          if ($arrayref->[$_]) {$arrayref->[$_] =
Math::BigFloat->new($arrayref->[$_]) ;}
+          if ($names->[$_]) {$hashref->{$names[$_]} =
Math::BigFloat->new($hashref->{$names[$_]});}
         }

     }

---End patch
I am not sure since there are tons of places that call Form.pm sub sub
db_parse_numeric.
Note: I am still running the 1.2 version and this patch is against its
/trunk -r 5153.

Note 2: I have not tested where else undefined values could be sent to Math::

Cheers Turtle

PS
I did notice a thread on the user list where the user just removes
Math::BigInt and in my case this is not an viable option.



------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Ledger-smb-devel mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel