summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lapi.c b/lapi.c
index 7689c90b..60e3a1ee 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.171 2013/03/16 21:10:18 roberto Exp roberto $ 2** $Id: lapi.c,v 2.172 2013/04/12 19:07:09 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*/
@@ -321,7 +321,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
321 o2 = index2addr(L, index2); 321 o2 = index2addr(L, index2);
322 if (isvalid(o1) && isvalid(o2)) { 322 if (isvalid(o1) && isvalid(o2)) {
323 switch (op) { 323 switch (op) {
324 case LUA_OPEQ: i = equalobj(L, o1, o2); break; 324 case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
325 case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; 325 case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
326 case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; 326 case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
327 default: api_check(L, 0, "invalid option"); 327 default: api_check(L, 0, "invalid option");
@@ -349,7 +349,11 @@ LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum) {
349LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum) { 349LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum) {
350 TValue n; 350 TValue n;
351 const TValue *o = index2addr(L, idx); 351 const TValue *o = index2addr(L, idx);
352 if (tonumber(o, &n)) { 352 if (ttisinteger(o)) {
353 if (isnum) *isnum = 1;
354 return ivalue(o);
355 }
356 else if (tonumber(o, &n)) {
353 lua_Integer res; 357 lua_Integer res;
354 lua_Number num = nvalue(o); 358 lua_Number num = nvalue(o);
355 lua_number2integer(res, num); 359 lua_number2integer(res, num);
@@ -482,7 +486,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
482 486
483LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { 487LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
484 lua_lock(L); 488 lua_lock(L);
485 setnvalue(L->top, cast_num(n)); 489 setivalue(L->top, cast_num(n));
486 api_incr_top(L); 490 api_incr_top(L);
487 lua_unlock(L); 491 lua_unlock(L);
488} 492}