diff options
| -rw-r--r-- | lbaselib.c | 21 |
1 files changed, 11 insertions, 10 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.199 2007/10/17 17:26:39 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.200 2007/10/25 19:31:05 roberto Exp roberto $ |
| 3 | ** Basic library | 3 | ** Basic library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -107,7 +107,7 @@ static int luaB_setmetatable (lua_State *L) { | |||
| 107 | luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, | 107 | luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, |
| 108 | "nil or table expected"); | 108 | "nil or table expected"); |
| 109 | if (luaL_getmetafield(L, 1, "__metatable")) | 109 | if (luaL_getmetafield(L, 1, "__metatable")) |
| 110 | luaL_error(L, "cannot change a protected metatable"); | 110 | return luaL_error(L, "cannot change a protected metatable"); |
| 111 | lua_settop(L, 2); | 111 | lua_settop(L, 2); |
| 112 | lua_setmetatable(L, 1); | 112 | lua_setmetatable(L, 1); |
| 113 | return 1; | 113 | return 1; |
| @@ -124,8 +124,7 @@ static void getfunc (lua_State *L, int opt) { | |||
| 124 | luaL_argerror(L, 1, "invalid level"); | 124 | luaL_argerror(L, 1, "invalid level"); |
| 125 | lua_getinfo(L, "f", &ar); | 125 | lua_getinfo(L, "f", &ar); |
| 126 | if (lua_isnil(L, -1)) | 126 | if (lua_isnil(L, -1)) |
| 127 | luaL_error(L, "no function environment for tail call at level %d", | 127 | luaL_error(L, "no function environment for tail call at level %d", level); |
| 128 | level); | ||
| 129 | } | 128 | } |
| 130 | } | 129 | } |
| 131 | 130 | ||
| @@ -152,8 +151,8 @@ static int luaB_setfenv (lua_State *L) { | |||
| 152 | return 0; | 151 | return 0; |
| 153 | } | 152 | } |
| 154 | else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) | 153 | else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) |
| 155 | luaL_error(L, | 154 | return luaL_error(L, |
| 156 | LUA_QL("setfenv") " cannot change environment of given object"); | 155 | LUA_QL("setfenv") " cannot change environment of given object"); |
| 157 | return 1; | 156 | return 1; |
| 158 | } | 157 | } |
| 159 | 158 | ||
| @@ -315,8 +314,10 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { | |||
| 315 | lua_replace(L, 3); /* save string in a reserved stack slot */ | 314 | lua_replace(L, 3); /* save string in a reserved stack slot */ |
| 316 | return lua_tolstring(L, 3, size); | 315 | return lua_tolstring(L, 3, size); |
| 317 | } | 316 | } |
| 318 | else luaL_error(L, "reader function must return a string"); | 317 | else { |
| 319 | return NULL; /* to avoid warnings */ | 318 | luaL_error(L, "reader function must return a string"); |
| 319 | return NULL; /* to avoid warnings */ | ||
| 320 | } | ||
| 320 | } | 321 | } |
| 321 | 322 | ||
| 322 | 323 | ||
| @@ -473,7 +474,7 @@ static const luaL_Reg base_funcs[] = { | |||
| 473 | static int auxresume (lua_State *L, lua_State *co, int narg) { | 474 | static int auxresume (lua_State *L, lua_State *co, int narg) { |
| 474 | int status; | 475 | int status; |
| 475 | if (!lua_checkstack(co, narg)) | 476 | if (!lua_checkstack(co, narg)) |
| 476 | luaL_error(L, "too many arguments to resume"); | 477 | return luaL_error(L, "too many arguments to resume"); |
| 477 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { | 478 | if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { |
| 478 | lua_pushliteral(L, "cannot resume dead coroutine"); | 479 | lua_pushliteral(L, "cannot resume dead coroutine"); |
| 479 | return -1; /* error flag */ | 480 | return -1; /* error flag */ |
| @@ -483,7 +484,7 @@ static int auxresume (lua_State *L, lua_State *co, int narg) { | |||
| 483 | if (status == LUA_OK || status == LUA_YIELD) { | 484 | if (status == LUA_OK || status == LUA_YIELD) { |
| 484 | int nres = lua_gettop(co); | 485 | int nres = lua_gettop(co); |
| 485 | if (!lua_checkstack(L, nres)) | 486 | if (!lua_checkstack(L, nres)) |
| 486 | luaL_error(L, "too many results to resume"); | 487 | return luaL_error(L, "too many results to resume"); |
| 487 | lua_xmove(co, L, nres); /* move yielded values */ | 488 | lua_xmove(co, L, nres); /* move yielded values */ |
| 488 | return nres; | 489 | return nres; |
| 489 | } | 490 | } |
