diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-30 11:42:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-30 11:42:44 -0300 |
commit | d86170662017645cf22884641f33a9d6b48d16e6 (patch) | |
tree | 80782cb7bfc8c31a0f6068f99ff47c0ca705b591 /lvm.c | |
parent | 34ac039fb84e3c12fb8c96c9c99c34224c09872b (diff) | |
download | lua-d86170662017645cf22884641f33a9d6b48d16e6.tar.gz lua-d86170662017645cf22884641f33a9d6b48d16e6.tar.bz2 lua-d86170662017645cf22884641f33a9d6b48d16e6.zip |
new macro 'cvt2num' to better control whether strings are convertible
to numbers
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.220 2014/07/21 16:02:10 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.221 2014/07/30 14:00:14 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -66,7 +66,7 @@ int luaV_tonumber_ (const TValue *obj, lua_Number *n) { | |||
66 | *n = fltvalue(obj); | 66 | *n = fltvalue(obj); |
67 | return 1; | 67 | return 1; |
68 | } | 68 | } |
69 | else if (ttisstring(obj) && /* string convertible to number? */ | 69 | else if (cvt2num(obj) && /* string convertible to number? */ |
70 | luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) { | 70 | luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) { |
71 | obj = &v; | 71 | obj = &v; |
72 | goto again; /* convert result from 'luaO_str2num' to a float */ | 72 | goto again; /* convert result from 'luaO_str2num' to a float */ |
@@ -98,7 +98,7 @@ static int tointeger_aux (const TValue *obj, lua_Integer *p, int mode) { | |||
98 | *p = ivalue(obj); | 98 | *p = ivalue(obj); |
99 | return 1; | 99 | return 1; |
100 | } | 100 | } |
101 | else if (ttisstring(obj) && | 101 | else if (cvt2num(obj) && |
102 | luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) { | 102 | luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) { |
103 | obj = &v; | 103 | obj = &v; |
104 | goto again; /* convert result from 'luaO_str2num' to an integer */ | 104 | goto again; /* convert result from 'luaO_str2num' to an integer */ |