From 6ab841beecc622370beb028ebe3c8f05e763047e Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 3 Apr 2019 10:17:20 +0800 Subject: [PATCH] turn on SSM during lua_load --- 3rd/lua/lauxlib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/3rd/lua/lauxlib.c b/3rd/lua/lauxlib.c index fa775d47..40c5e08c 100644 --- a/3rd/lua/lauxlib.c +++ b/3rd/lua/lauxlib.c @@ -699,6 +699,7 @@ static int skipcomment (LoadF *lf, int *cp) { else return 0; /* no comment */ } +LUA_API void luaS_expandshr(int n); static int luaL_loadfilex_ (lua_State *L, const char *filename, const char *mode) { @@ -724,7 +725,9 @@ static int luaL_loadfilex_ (lua_State *L, const char *filename, } if (c != EOF) lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ + luaS_expandshr(4096); status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); + luaS_expandshr(-4096); readstatus = ferror(lf.f); if (filename) fclose(lf.f); /* close file (even in case of errors) */ if (readstatus) { @@ -1152,8 +1155,6 @@ static int cache_mode(lua_State *L) { return 0; } -LUA_API void luaS_expandshr(int n); - LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, const char *mode) { int level = cache_level(L); @@ -1173,9 +1174,7 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, lua_pushliteral(L, "New state failed"); return LUA_ERRMEM; } - luaS_expandshr(4096); int err = luaL_loadfilex_(eL, filename, mode); - luaS_expandshr(-4096); if (err != LUA_OK) { size_t sz = 0; const char * msg = lua_tolstring(eL, -1, &sz);