Hi everyone!

   I've came accross a bug in neko vm while working on a haXe project.
Apparenty neko's builtin $int() and $float() functions don't detect if
an invalid integer/float representation passed to them in a string.

According to neko API documentation:

int? $int(any)
Convert the value to the corresponding integer or return null

float? $float(any)
Convert the value to the corresponding float or return null

The C impementation of these functions are using atoi() and atof() C
library functions which can't detect parse errors: they both return 0
which is not a clever solution because what if I want to parse 0 or
0.0? I've created a diff against revision 1.67 which resolves these
issues using functions strtol() and strtof(). They can detect parsing
errors so $int() and $float() return null is that case. Moreover this
eliminates the need of parsng hexadecimal representations by hand
because strtol() can handle it.

Best regards,
Gabor

Attachment: int_float_parse.diff
Description: Binary data

-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to