diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-15 12:43:34 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-15 12:43:34 -0300 |
| commit | 7a543cfae613d7fa5f0cc82ef462310e5d3a4413 (patch) | |
| tree | 0bc41f597df62c85c4f2abcdbbe288edb010e644 /lapi.c | |
| parent | 24689927f2ef4d5bfe9f0d7deff08504eb31f81e (diff) | |
| download | lua-7a543cfae613d7fa5f0cc82ef462310e5d3a4413.tar.gz lua-7a543cfae613d7fa5f0cc82ef462310e5d3a4413.tar.bz2 lua-7a543cfae613d7fa5f0cc82ef462310e5d3a4413.zip | |
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 12 |
1 files changed, 8 insertions, 4 deletions
| @@ -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) { | |||
| 349 | LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum) { | 349 | LUA_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 | ||
| 483 | LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { | 487 | LUA_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 | } |
