aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-08-23 15:03:11 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-08-23 15:03:11 -0300
commitdaa5fe3e31d8ca28a8770df135cbad7fa6fdfa4b (patch)
tree18b7a14d85fd4bd13c6656fc9c69c8aa22d995d3
parent8d9ea59d28e0a4626ce8372f6f643c30d79063aa (diff)
downloadlua-daa5fe3e31d8ca28a8770df135cbad7fa6fdfa4b.tar.gz
lua-daa5fe3e31d8ca28a8770df135cbad7fa6fdfa4b.tar.bz2
lua-daa5fe3e31d8ca28a8770df135cbad7fa6fdfa4b.zip
'loadin' should accept any value for the environment (not only tables) +
it should check whether chunk has upvalue named '_ENV'
-rw-r--r--lbaselib.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 9680bb38..b834d54f 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.245 2010/06/13 19:41:34 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.246 2010/07/02 11:38:13 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*/
@@ -330,11 +330,14 @@ static int luaB_load (lua_State *L) {
330 330
331static int luaB_loadin (lua_State *L) { 331static int luaB_loadin (lua_State *L) {
332 int n; 332 int n;
333 luaL_checktype(L, 1, LUA_TTABLE); 333 luaL_checkany(L, 1);
334 n = luaB_load_aux(L, 2); 334 n = luaB_load_aux(L, 2);
335 if (n == 1) { /* success? */ 335 if (n == 1) { /* success? */
336 const char *name;
336 lua_pushvalue(L, 1); /* environment for loaded function */ 337 lua_pushvalue(L, 1); /* environment for loaded function */
337 lua_setupvalue(L, -2, 1); 338 name = lua_setupvalue(L, -2, 1);
339 if (name == NULL || strcmp(name, "_ENV") != 0)
340 luaL_error(L, "loaded chunk does not have environment upvalue");
338 } 341 }
339 return n; 342 return n;
340} 343}