[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaO_str2d, strtod and hexadecimal numbers under IRIX
- From: "Rainer M. Canavan" <lua@...>
- Date: Tue, 19 Oct 2010 23:16:57 +0200 (CEST)
> From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
> Could you send only a diff of your changes to luaO_str2d (without debug
> prints)?
Enclosed below. It's certainly not an optimal solution and
should probably ifdef'ed out if performance is a concern.
A more complete solution would probably be to use the gnulib
implementation if the system version is buggy.
> From: Mike Pall <mikelu-1010@mike.de>
[...]
> Well, it's a violation of ANSI C only present in IRIX. And IRIX is
Apparently, AIX has (had?) it as well. 7.1 was released in September.
http://permalink.gmane.org/gmane.comp.lib.gnulib.bugs/22410
Considering the widespread, but usually more subtle bugs in
strtod, I'd not be surprised if other implementations had
similar problems.
> for all practical purposes 'dead'. IRIX 6.5 is from 1998, the last
> minor update 6.5.30 is from 2006 and hardware production has been
> stopped in 2006, too.
It's still supported, at least until December 2013.
regards,
rainer
--- lobject.c Sun Oct 17 21:21:14 CEST 2010
+++ ../../../lua-5.1.4/src/lobject.c Tue Oct 19 22:55:08 CEST 2010
@@ -89,12 +89,15 @@
int luaO_str2d (const char *s, lua_Number *result) {
char *endptr;
+
*result = lua_str2number(s, &endptr);
- if (endptr == s) return 0; /* conversion failed */
- if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
-{ printf('hex!!! %s\n', endptr);
+ *result = strtod(s, &endptr);
+ if ((*s == '0') &&
+ (*(s+1) == 'x' || *(s+1) == 'X')) /* maybe a hexadecimal constant? */
+ {
*result = cast_num(strtoul(s, &endptr, 16));
-}
+ }
+ if (endptr == s) return 0; /* conversion failed */
if (*endptr == '\0') return 1; /* most common case */
while (isspace(cast(unsigned char, *endptr))) endptr++;
if (*endptr != '\0') return 0; /* invalid trailing characters? */