turn on SSM during lua_load
@@ -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);
