diff options
Diffstat (limited to 'bugs')
-rw-r--r-- | bugs | 63 |
1 files changed, 60 insertions, 3 deletions
@@ -1880,8 +1880,8 @@ patch = [[ | |||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | 1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 |
1881 | @@ -1,5 +1,5 @@ | 1881 | @@ -1,5 +1,5 @@ |
1882 | /* | 1882 | /* |
1883 | -** $Id: bugs,v 1.117 2012/09/11 12:42:14 roberto Exp roberto $ | 1883 | -** $Id: bugs,v 1.118 2012/10/01 14:05:31 roberto Exp roberto $ |
1884 | +** $Id: bugs,v 1.117 2012/09/11 12:42:14 roberto Exp roberto $ | 1884 | +** $Id: bugs,v 1.118 2012/10/01 14:05:31 roberto Exp roberto $ |
1885 | ** load precompiled Lua chunks | 1885 | ** load precompiled Lua chunks |
1886 | ** See Copyright Notice in lua.h | 1886 | ** See Copyright Notice in lua.h |
1887 | */ | 1887 | */ |
@@ -2703,7 +2703,6 @@ example = [[print(string.find(string.rep("a", 2^20), string.rep(".?", 2^20)))]], | |||
2703 | patch = [[ | 2703 | patch = [[ |
2704 | ]] | 2704 | ]] |
2705 | } | 2705 | } |
2706 | ]=] | ||
2707 | 2706 | ||
2708 | 2707 | ||
2709 | Bug{ | 2708 | Bug{ |
@@ -2797,6 +2796,64 @@ patch = [[ | |||
2797 | ]] | 2796 | ]] |
2798 | } | 2797 | } |
2799 | 2798 | ||
2799 | Bug{ | ||
2800 | what = [[load/loadfile returns wrong result when given an environment | ||
2801 | for a binary chunk with no upvalues]], | ||
2802 | report = [[Vladimir Strakh, 2012/11/28]], | ||
2803 | since = [[5.2]], | ||
2804 | fix = nil, | ||
2805 | example = [[ | ||
2806 | f = load(string.dump(function () return 1 end), nil, "b", {}) | ||
2807 | print(type(f)) --> table (whould be a function) | ||
2808 | ]], | ||
2809 | patch = [[ | ||
2810 | --- lbaselib.c 2012/04/27 14:13:19 1.274 | ||
2811 | +++ lbaselib.c 2012/12/03 20:08:15 | ||
2812 | @@ -244,5 +244,11 @@ | ||
2813 | |||
2814 | -static int load_aux (lua_State *L, int status) { | ||
2815 | - if (status == LUA_OK) | ||
2816 | +static int load_aux (lua_State *L, int status, int envidx) { | ||
2817 | + if (status == LUA_OK) { | ||
2818 | + if (envidx != 0) { /* 'env' parameter? */ | ||
2819 | + lua_pushvalue(L, envidx); /* environment for loaded function */ | ||
2820 | + if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ | ||
2821 | + lua_pop(L, 1); /* remove 'env' if not used by previous call */ | ||
2822 | + } | ||
2823 | return 1; | ||
2824 | + } | ||
2825 | else { | ||
2826 | @@ -258,9 +264,5 @@ | ||
2827 | const char *mode = luaL_optstring(L, 2, NULL); | ||
2828 | - int env = !lua_isnone(L, 3); /* 'env' parameter? */ | ||
2829 | + int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ | ||
2830 | int status = luaL_loadfilex(L, fname, mode); | ||
2831 | - if (status == LUA_OK && env) { /* 'env' parameter? */ | ||
2832 | - lua_pushvalue(L, 3); | ||
2833 | - lua_setupvalue(L, -2, 1); /* set it as 1st upvalue of loaded chunk */ | ||
2834 | - } | ||
2835 | - return load_aux(L, status); | ||
2836 | + return load_aux(L, status, env); | ||
2837 | } | ||
2838 | @@ -309,5 +311,5 @@ | ||
2839 | size_t l; | ||
2840 | - int top = lua_gettop(L); | ||
2841 | const char *s = lua_tolstring(L, 1, &l); | ||
2842 | const char *mode = luaL_optstring(L, 3, "bt"); | ||
2843 | + int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ | ||
2844 | if (s != NULL) { /* loading a string? */ | ||
2845 | @@ -322,7 +324,3 @@ | ||
2846 | } | ||
2847 | - if (status == LUA_OK && top >= 4) { /* is there an 'env' argument */ | ||
2848 | - lua_pushvalue(L, 4); /* environment for loaded function */ | ||
2849 | - lua_setupvalue(L, -2, 1); /* set it as 1st upvalue */ | ||
2850 | - } | ||
2851 | - return load_aux(L, status); | ||
2852 | + return load_aux(L, status, env); | ||
2853 | } | ||
2854 | ]] | ||
2855 | } | ||
2856 | |||
2800 | --[=[ | 2857 | --[=[ |
2801 | Bug{ | 2858 | Bug{ |
2802 | what = [[ ]], | 2859 | what = [[ ]], |