AP_Scripting: remove support for loading binary luac
this saves about 2k of flash
This commit is contained in:
parent
ef3016eff0
commit
2863f3954b
@ -720,11 +720,13 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
|
|||||||
}
|
}
|
||||||
if (skipcomment(&lf, &c)) /* read initial portion */
|
if (skipcomment(&lf, &c)) /* read initial portion */
|
||||||
lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */
|
lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */
|
||||||
|
#if LUA_SUPPORT_LOAD_BINARY
|
||||||
if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
|
if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
|
||||||
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
|
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
|
||||||
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
|
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
|
||||||
skipcomment(&lf, &c); /* re-read initial portion */
|
skipcomment(&lf, &c); /* re-read initial portion */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (c != EOF)
|
if (c != EOF)
|
||||||
lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
|
lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
|
||||||
status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode);
|
status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode);
|
||||||
|
@ -768,11 +768,15 @@ static void f_parser (lua_State *L, void *ud) {
|
|||||||
LClosure *cl;
|
LClosure *cl;
|
||||||
struct SParser *p = cast(struct SParser *, ud);
|
struct SParser *p = cast(struct SParser *, ud);
|
||||||
int c = zgetc(p->z); /* read first character */
|
int c = zgetc(p->z); /* read first character */
|
||||||
|
#if LUA_SUPPORT_LOAD_BINARY
|
||||||
|
// support loading pre-compiled luac
|
||||||
if (c == LUA_SIGNATURE[0]) {
|
if (c == LUA_SIGNATURE[0]) {
|
||||||
checkmode(L, p->mode, "binary");
|
checkmode(L, p->mode, "binary");
|
||||||
cl = luaU_undump(L, p->z, p->name);
|
cl = luaU_undump(L, p->z, p->name);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
checkmode(L, p->mode, "text");
|
checkmode(L, p->mode, "text");
|
||||||
cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
|
cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,12 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
don't support binary load() by default
|
||||||
|
*/
|
||||||
|
#ifndef LUA_SUPPORT_LOAD_BINARY
|
||||||
|
#define LUA_SUPPORT_LOAD_BINARY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** ===================================================================
|
** ===================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user