diff options
| -rw-r--r-- | lobject.c | 10 |
1 files changed, 6 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.51 2011/06/23 16:01:06 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.53 2011/07/27 12:09:13 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -103,8 +103,8 @@ static int isneg (const char **s) { | |||
| 103 | 103 | ||
| 104 | 104 | ||
| 105 | static lua_Number readhexa (const char **s, lua_Number r, int *count) { | 105 | static lua_Number readhexa (const char **s, lua_Number r, int *count) { |
| 106 | while (lisxdigit(cast_uchar(**s))) { /* read integer part */ | 106 | for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */ |
| 107 | r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++))); | 107 | r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s))); |
| 108 | (*count)++; | 108 | (*count)++; |
| 109 | } | 109 | } |
| 110 | return r; | 110 | return r; |
| @@ -157,7 +157,9 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
| 157 | 157 | ||
| 158 | int luaO_str2d (const char *s, size_t len, lua_Number *result) { | 158 | int luaO_str2d (const char *s, size_t len, lua_Number *result) { |
| 159 | char *endptr; | 159 | char *endptr; |
| 160 | if (strpbrk(s, "xX")) /* hexa? */ | 160 | if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */ |
| 161 | return 0; | ||
| 162 | else if (strpbrk(s, "xX")) /* hexa? */ | ||
| 161 | *result = lua_strx2number(s, &endptr); | 163 | *result = lua_strx2number(s, &endptr); |
| 162 | else | 164 | else |
| 163 | *result = lua_str2number(s, &endptr); | 165 | *result = lua_str2number(s, &endptr); |
