mirror of
https://github.com/lua/lua
synced 2025-02-07 08:44:01 +03:00
details
This commit is contained in:
parent
9f0d62ad9f
commit
b4164a9aa7
21
lbaselib.c
21
lbaselib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lbaselib.c,v 1.199 2007/10/17 17:26:39 roberto Exp roberto $
|
||||
** $Id: lbaselib.c,v 1.200 2007/10/25 19:31:05 roberto Exp roberto $
|
||||
** Basic library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -107,7 +107,7 @@ static int luaB_setmetatable (lua_State *L) {
|
||||
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
|
||||
"nil or table expected");
|
||||
if (luaL_getmetafield(L, 1, "__metatable"))
|
||||
luaL_error(L, "cannot change a protected metatable");
|
||||
return luaL_error(L, "cannot change a protected metatable");
|
||||
lua_settop(L, 2);
|
||||
lua_setmetatable(L, 1);
|
||||
return 1;
|
||||
@ -124,8 +124,7 @@ static void getfunc (lua_State *L, int opt) {
|
||||
luaL_argerror(L, 1, "invalid level");
|
||||
lua_getinfo(L, "f", &ar);
|
||||
if (lua_isnil(L, -1))
|
||||
luaL_error(L, "no function environment for tail call at level %d",
|
||||
level);
|
||||
luaL_error(L, "no function environment for tail call at level %d", level);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,8 +151,8 @@ static int luaB_setfenv (lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
|
||||
luaL_error(L,
|
||||
LUA_QL("setfenv") " cannot change environment of given object");
|
||||
return luaL_error(L,
|
||||
LUA_QL("setfenv") " cannot change environment of given object");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -315,8 +314,10 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
|
||||
lua_replace(L, 3); /* save string in a reserved stack slot */
|
||||
return lua_tolstring(L, 3, size);
|
||||
}
|
||||
else luaL_error(L, "reader function must return a string");
|
||||
return NULL; /* to avoid warnings */
|
||||
else {
|
||||
luaL_error(L, "reader function must return a string");
|
||||
return NULL; /* to avoid warnings */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -473,7 +474,7 @@ static const luaL_Reg base_funcs[] = {
|
||||
static int auxresume (lua_State *L, lua_State *co, int narg) {
|
||||
int status;
|
||||
if (!lua_checkstack(co, narg))
|
||||
luaL_error(L, "too many arguments to resume");
|
||||
return luaL_error(L, "too many arguments to resume");
|
||||
if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) {
|
||||
lua_pushliteral(L, "cannot resume dead coroutine");
|
||||
return -1; /* error flag */
|
||||
@ -483,7 +484,7 @@ static int auxresume (lua_State *L, lua_State *co, int narg) {
|
||||
if (status == LUA_OK || status == LUA_YIELD) {
|
||||
int nres = lua_gettop(co);
|
||||
if (!lua_checkstack(L, nres))
|
||||
luaL_error(L, "too many results to resume");
|
||||
return luaL_error(L, "too many results to resume");
|
||||
lua_xmove(co, L, nres); /* move yielded values */
|
||||
return nres;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user