diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 15:17:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 15:17:01 -0300 |
commit | 762d059a13d83eb367238a6115bbb4f5f13fcb49 (patch) | |
tree | f35fdf0675b791865d0d4800522b172903b34803 /lapi.c | |
parent | 572a69b6afbd368beab8844bc876b0f9690b5253 (diff) | |
download | lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.tar.gz lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.tar.bz2 lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.zip |
new implementation for the Virtual Machine
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.140 2001/04/17 17:35:54 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.141 2001/04/23 16:35:45 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -184,9 +184,10 @@ LUA_API int lua_iscfunction (lua_State *L, int index) { | |||
184 | LUA_API int lua_isnumber (lua_State *L, int index) { | 184 | LUA_API int lua_isnumber (lua_State *L, int index) { |
185 | TObject *o; | 185 | TObject *o; |
186 | int i; | 186 | int i; |
187 | TObject n; | ||
187 | lua_lock(L); | 188 | lua_lock(L); |
188 | o = luaA_indexAcceptable(L, index); | 189 | o = luaA_indexAcceptable(L, index); |
189 | i = (o == NULL) ? 0 : (tonumber(o) == 0); | 190 | i = (o != NULL && (ttype(o) == LUA_TNUMBER || luaV_tonumber(o, &n))); |
190 | lua_unlock(L); | 191 | lua_unlock(L); |
191 | return i; | 192 | return i; |
192 | } | 193 | } |
@@ -234,13 +235,18 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { | |||
234 | 235 | ||
235 | 236 | ||
236 | LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | 237 | LUA_API lua_Number lua_tonumber (lua_State *L, int index) { |
237 | StkId o; | 238 | const TObject *o; |
238 | lua_Number n; | 239 | TObject n; |
240 | lua_Number res; | ||
239 | lua_lock(L); | 241 | lua_lock(L); |
240 | o = luaA_indexAcceptable(L, index); | 242 | o = luaA_indexAcceptable(L, index); |
241 | n = (o == NULL || tonumber(o)) ? 0 : nvalue(o); | 243 | if (o != NULL && |
244 | (ttype(o) == LUA_TNUMBER || (o = luaV_tonumber(o, &n)) != NULL)) | ||
245 | res = nvalue(o); | ||
246 | else | ||
247 | res = 0; | ||
242 | lua_unlock(L); | 248 | lua_unlock(L); |
243 | return n; | 249 | return res; |
244 | } | 250 | } |
245 | 251 | ||
246 | LUA_API const l_char *lua_tostring (lua_State *L, int index) { | 252 | LUA_API const l_char *lua_tostring (lua_State *L, int index) { |