summaryrefslogtreecommitdiff
path: root/src/lobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lobject.c')
-rw-r--r--src/lobject.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lobject.c b/src/lobject.c
index d8cc3ce9..148d4bce 100644
--- a/src/lobject.c
+++ b/src/lobject.c
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 2.52 2011/06/24 12:25:02 roberto Exp $
+** $Id: lobject.c,v 2.53 2011/07/27 12:13:08 roberto Exp $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -103,8 +103,8 @@ static int isneg (const char **s) {
static lua_Number readhexa (const char **s, lua_Number r, int *count) {
- while (lisxdigit(cast_uchar(**s))) { /* read integer part */
- r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++)));
+ for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */
+ r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s)));
(*count)++;
}
return r;
@@ -157,7 +157,9 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
int luaO_str2d (const char *s, size_t len, lua_Number *result) {
char *endptr;
- if (strpbrk(s, "xX")) /* hexa? */
+ if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */
+ return 0;
+ else if (strpbrk(s, "xX")) /* hexa? */
*result = lua_strx2number(s, &endptr);
else
*result = lua_str2number(s, &endptr);