rewrite SSM and clonefunction

This commit is contained in:
Cloud Wu
2019-04-16 21:16:13 +08:00
committed by 云风
parent 2d6d2c75a4
commit 2ceb642b5d
32 changed files with 934 additions and 645 deletions

View File

@@ -699,9 +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,
LUALIB_API int luaL_loadfilex_ (lua_State *L, const char *filename,
const char *mode) {
LoadF lf;
int status, readstatus;
@@ -725,9 +723,7 @@ 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) {
@@ -1181,6 +1177,7 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
lua_close(eL);
return err;
}
lua_sharefunction(eL, -1);
proto = lua_topointer(eL, -1);
const void * oldv = save(filename, proto);
if (oldv) {