diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-18 15:18:35 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-18 15:18:35 -0300 |
| commit | 0b00e7f1a20b5c4c3f21aaf163818335d0d61928 (patch) | |
| tree | c0950f44c82d0fe3a70c6f5c3671490d36740464 /lapi.c | |
| parent | b7ed502deaaab48c8794314e8594b0511dfa34d8 (diff) | |
| download | lua-0b00e7f1a20b5c4c3f21aaf163818335d0d61928.tar.gz lua-0b00e7f1a20b5c4c3f21aaf163818335d0d61928.tar.bz2 lua-0b00e7f1a20b5c4c3f21aaf163818335d0d61928.zip | |
new macro to convert double->int
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.175 2002/03/04 21:29:41 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.176 2002/03/07 18:15:10 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 | */ |
| @@ -597,7 +597,7 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
| 597 | api_check(L, ttype(t) == LUA_TTABLE); | 597 | api_check(L, ttype(t) == LUA_TTABLE); |
| 598 | value = luaH_getstr(hvalue(t), luaS_newliteral(L, "n")); /* = t.n */ | 598 | value = luaH_getstr(hvalue(t), luaS_newliteral(L, "n")); /* = t.n */ |
| 599 | if (ttype(value) == LUA_TNUMBER) | 599 | if (ttype(value) == LUA_TNUMBER) |
| 600 | n = cast(int, nvalue(value)); | 600 | lua_number2int(n, nvalue(value)); |
| 601 | else { | 601 | else { |
| 602 | Node *nd; | 602 | Node *nd; |
| 603 | Table *a = hvalue(t); | 603 | Table *a = hvalue(t); |
| @@ -618,7 +618,7 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
| 618 | max = nvalue(key(nd)); | 618 | max = nvalue(key(nd)); |
| 619 | nd++; | 619 | nd++; |
| 620 | } | 620 | } |
| 621 | n = cast(int, max); | 621 | lua_number2int(n, max); |
| 622 | } | 622 | } |
| 623 | lua_unlock(L); | 623 | lua_unlock(L); |
| 624 | return n; | 624 | return n; |
