aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-07-02 14:35:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-07-02 14:35:06 -0300
commita9dc7c88283a8046ad40c592f9e626d93e8e14a1 (patch)
tree693fa40d1ca9beceb5af5d4d4325401abe3f96a2 /lauxlib.c
parent7192afafeeb1a96b3de60af90a72cd8762b09d94 (diff)
downloadlua-a9dc7c88283a8046ad40c592f9e626d93e8e14a1.tar.gz
lua-a9dc7c88283a8046ad40c592f9e626d93e8e14a1.tar.bz2
lua-a9dc7c88283a8046ad40c592f9e626d93e8e14a1.zip
functions lua_tonumber/lua_tointeger replaced by lua_tonumberx/lua_tointegerx
that have an extra out parameter with conversion status
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 2f0168f1..38bc27d4 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.216 2010/06/30 17:40:27 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.217 2010/07/02 11:38:13 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -308,8 +308,9 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
308 308
309 309
310LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { 310LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
311 lua_Number d = lua_tonumber(L, narg); 311 int isnum;
312 if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ 312 lua_Number d = lua_tonumberx(L, narg, &isnum);
313 if (!isnum)
313 tag_error(L, narg, LUA_TNUMBER); 314 tag_error(L, narg, LUA_TNUMBER);
314 return d; 315 return d;
315} 316}
@@ -321,8 +322,9 @@ LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
321 322
322 323
323LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { 324LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
324 lua_Integer d = lua_tointeger(L, narg); 325 int isnum;
325 if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ 326 lua_Integer d = lua_tointegerx(L, narg, &isnum);
327 if (!isnum)
326 tag_error(L, narg, LUA_TNUMBER); 328 tag_error(L, narg, LUA_TNUMBER);
327 return d; 329 return d;
328} 330}
@@ -624,9 +626,10 @@ LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
624 626
625LUALIB_API int luaL_len (lua_State *L, int idx) { 627LUALIB_API int luaL_len (lua_State *L, int idx) {
626 int l; 628 int l;
629 int isnum;
627 lua_len(L, idx); 630 lua_len(L, idx);
628 l = lua_tointeger(L, -1); 631 l = lua_tointegerx(L, -1, &isnum);
629 if (l == 0 && !lua_isnumber(L, -1)) 632 if (!isnum)
630 luaL_error(L, "object length is not a number"); 633 luaL_error(L, "object length is not a number");
631 lua_pop(L, 1); /* remove object */ 634 lua_pop(L, 1); /* remove object */
632 return l; 635 return l;