lua-users home
lua-l archive

Re: luaO_str2d, strtod and hexadecimal numbers under IRIX

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


> --- 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? */
This diff seems strange...
- it removes a 'printf' that is not present in the original version;
- it adds a consecutive assignment to '*result', so the second one
throws out the first value without ever using it.
Is that correct?
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /