AP_Scripting: remove support for loading binary luac

this saves about 2k of flash
This commit is contained in:
Andrew Tridgell 2022-11-27 07:19:32 +11:00
parent ef3016eff0
commit 2863f3954b
3 changed files with 13 additions and 1 deletions

View File

@ -720,11 +720,13 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
}
if (skipcomment(&lf, &c)) /* read initial portion */
lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */
#if LUA_SUPPORT_LOAD_BINARY
if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
skipcomment(&lf, &c); /* re-read initial portion */
}
#endif
if (c != EOF)
lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode);

View File

@ -768,11 +768,15 @@ static void f_parser (lua_State *L, void *ud) {
LClosure *cl;
struct SParser *p = cast(struct SParser *, ud);
int c = zgetc(p->z); /* read first character */
#if LUA_SUPPORT_LOAD_BINARY
// support loading pre-compiled luac
if (c == LUA_SIGNATURE[0]) {
checkmode(L, p->mode, "binary");
cl = luaU_undump(L, p->z, p->name);
}
else {
else
#endif
{
checkmode(L, p->mode, "text");
cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
}

View File

@ -11,6 +11,12 @@
#include <limits.h>
#include <stddef.h>
/*
don't support binary load() by default
*/
#ifndef LUA_SUPPORT_LOAD_BINARY
#define LUA_SUPPORT_LOAD_BINARY 0
#endif
/*
** ===================================================================