Re: [PATCH] Small typo in zend_u_strtol
| From: | Matt W | Date: | Thu, 05 Oct 2006 23:46:08 +0000 |
| Subject: | Re: [PATCH] Small typo in zend_u_strtol | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-25956@lists.php.net to get a copy of this message | ||
Hi Andrei,
----- Original Message -----
From: "Andrei Zmievski"
Sent: Thursday, October 05, 2006
> Are you sure this is correct? I copied the source from BSD strtol
> implementation.
>
>
> http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/strtol.c?
> rev=1.19&content-type=text/x-cvsweb-markup
Well, copied but modified for Unicode use... like half the for loop is
changed. In BSD's case, the value of '0', etc. is subtracted from "c"
variable, so it then has the actual numeric value of the digit. But PHP's
puts the actual numeric value in "val" from u_digit(). "c" is still too high
by '0' 's value (48?). Finally, their "acc += c" was changed to "acc
+=
val" for that reason. If PHP's had kept "c" *there*, the problem would've
been discovered fast. :-)
Do you see the problem in the examples I gave? Numbers between 2147483640
and 2147483647 incorrectly set ERANGE, along with similar negative values.
> -Andrei
Matt
> On Oct 5, 2006, at 1:50 AM, Matt W wrote:
>
> > Hi,
> >
> > Was this missed? I'm sure you want to fix it. :-) Maybe should've put
> > "bug" instead of "typo" in the subject...
> >
> > Just also sending to you Andrei since it's Unicode related.
> >
> > Patch was an attachment:
> > http://news.php.net/php.internals/25820