From: Hugo van der Sanden Date: Wed, 18 Jul 2001 05:21:54 +0000 (+0100) Subject: Re: [ID 20010716.005] numeric conversions in 5.7.[12] changed from perl5.6.1 (leading... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=96a05aee450e24b2d5686c50a7e95ce03114af79;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20010716.005] numeric conversions in 5.7.[12] changed from perl5.6.1 (leading whitespace) Message-Id: <200107180421.f6I4Ltc00987@crypt0.demon.co.uk> p4raw-id: //depot/perl@11403 --- diff --git a/numeric.c b/numeric.c index ec93d6b..4363669 100644 --- a/numeric.c +++ b/numeric.c @@ -629,6 +629,10 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value) I32 ipart = 0; /* index into part[] */ I32 offcount; /* number of digits in least significant part */ + /* leading whitespace */ + while (isSPACE(*s)) + ++s; + /* sign */ switch (*s) { case '-': diff --git a/t/op/arith.t b/t/op/arith.t index 2847acb..8b8e2bc 100755 --- a/t/op/arith.t +++ b/t/op/arith.t @@ -1,6 +1,6 @@ #!./perl -w -print "1..109\n"; +print "1..113\n"; sub try ($$) { print +($_[1] ? "ok" : "not ok"), " $_[0]\n"; @@ -204,3 +204,10 @@ tryeq 106, 46339 * 46341, 0x7ffea80f; tryeq 107, 46339 * -46341, -0x7ffea80f; tryeq 108, -46339 * 46341, -0x7ffea80f; tryeq 109, -46339 * -46341, 0x7ffea80f; + +# leading space should be ignored + +tryeq 110, 1 + " 1", 2; +tryeq 111, 3 + " -1", 2; +tryeq 112, 1.2, " 1.2"; +tryeq 113, -1.2, " -1.2";