summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-07-18 14:50:38 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-18 14:56:00 -0500
commit8bd992c5035bfee6aedbcae7669be5b823537aad (patch)
tree2db34dbf0765362d875242b9908f3d0d95b387bb
parentd5908f520e8b21091766076584c9f582dbcdae1c (diff)
downloadrockbox-8bd992c5035bfee6aedbcae7669be5b823537aad.tar.gz
rockbox-8bd992c5035bfee6aedbcae7669be5b823537aad.zip
lua disable bytecode dump & undump functions
Adds a flag to remove the ability to dump and load lua bytecode saves 6+kb Change-Id: I080323df7f03f752e0a10928e22a7ce3190a9633
-rw-r--r--apps/plugins/lua/ldump.c13
-rw-r--r--apps/plugins/lua/luaconf.h4
-rw-r--r--apps/plugins/lua/lundump.c13
-rw-r--r--apps/plugins/lua/lundump.h8
4 files changed, 33 insertions, 5 deletions
diff --git a/apps/plugins/lua/ldump.c b/apps/plugins/lua/ldump.c
index c9d3d4870f..9afba60a37 100644
--- a/apps/plugins/lua/ldump.c
+++ b/apps/plugins/lua/ldump.c
@@ -15,6 +15,8 @@
15#include "lstate.h" 15#include "lstate.h"
16#include "lundump.h" 16#include "lundump.h"
17 17
18#ifndef LUA_DISABLE_BYTECODE
19
18typedef struct { 20typedef struct {
19 lua_State* L; 21 lua_State* L;
20 lua_Writer writer; 22 lua_Writer writer;
@@ -162,3 +164,14 @@ int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip
162 DumpFunction(f,NULL,&D); 164 DumpFunction(f,NULL,&D);
163 return D.status; 165 return D.status;
164} 166}
167#else /* LUA_DISABLE_BYTECODE */
168#include "lauxlib.h"
169int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
170{
171 (void) f;
172 (void) w;
173 (void) data;
174 (void) strip;
175 return luaL_error(L, " bytecode not supported");
176}
177#endif
diff --git a/apps/plugins/lua/luaconf.h b/apps/plugins/lua/luaconf.h
index 4b6f25d008..582968d423 100644
--- a/apps/plugins/lua/luaconf.h
+++ b/apps/plugins/lua/luaconf.h
@@ -797,7 +797,7 @@ extern long rb_pow(long, long);
797#undef LUA_COMPAT_GFIND 797#undef LUA_COMPAT_GFIND
798#undef LUA_COMPAT_OPENLIB 798#undef LUA_COMPAT_OPENLIB
799 799
800/* Resize heap allocated buffers */ 800/* Resize [STACK] allocated buffers */
801#undef LUAI_MAXVARS /*200*/ 801#undef LUAI_MAXVARS /*200*/
802#define LUAI_MAXVARS 100 802#define LUAI_MAXVARS 100
803 803
@@ -811,6 +811,6 @@ extern long rb_pow(long, long);
811#include "rockconf.h" 811#include "rockconf.h"
812 812
813/*else*/ 813/*else*/
814#define LUAC_TRUST_BINARIES 814#define LUA_DISABLE_BYTECODE
815 815
816#endif 816#endif
diff --git a/apps/plugins/lua/lundump.c b/apps/plugins/lua/lundump.c
index 6a8422de30..967b45c94b 100644
--- a/apps/plugins/lua/lundump.c
+++ b/apps/plugins/lua/lundump.c
@@ -20,6 +20,8 @@
20#include "lundump.h" 20#include "lundump.h"
21#include "lzio.h" 21#include "lzio.h"
22 22
23#ifndef LUA_DISABLE_BYTECODE
24
23typedef struct { 25typedef struct {
24 lua_State* L; 26 lua_State* L;
25 ZIO* Z; 27 ZIO* Z;
@@ -225,3 +227,14 @@ void luaU_header (char* h)
225 *h++=(char)sizeof(lua_Number); 227 *h++=(char)sizeof(lua_Number);
226 *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ 228 *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
227} 229}
230
231#else /* LUA_DISABLE_BYTECODE */
232#include "lauxlib.h"
233Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
234{
235 (void) Z;
236 (void) buff;
237 luaL_error(L, LUA_QL("%s") " bytecode not supported", name);
238 return NULL;
239}
240#endif
diff --git a/apps/plugins/lua/lundump.h b/apps/plugins/lua/lundump.h
index f791a4f173..b2fe851e59 100644
--- a/apps/plugins/lua/lundump.h
+++ b/apps/plugins/lua/lundump.h
@@ -13,12 +13,13 @@
13/* load one chunk; from lundump.c */ 13/* load one chunk; from lundump.c */
14LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 14LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
15 15
16/* make header; from lundump.c */
17LUAI_FUNC void luaU_header (char* h);
18
19/* dump one chunk; from ldump.c */ 16/* dump one chunk; from ldump.c */
20LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 17LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
21 18
19#ifndef LUA_DISABLE_BYTECODE
20/* make header; from lundump.c */
21LUAI_FUNC void luaU_header (char* h);
22
22#ifdef luac_c 23#ifdef luac_c
23/* print one chunk; from print.c */ 24/* print one chunk; from print.c */
24LUAI_FUNC void luaU_print (const Proto* f, int full); 25LUAI_FUNC void luaU_print (const Proto* f, int full);
@@ -33,4 +34,5 @@ LUAI_FUNC void luaU_print (const Proto* f, int full);
33/* size of header of binary files */ 34/* size of header of binary files */
34#define LUAC_HEADERSIZE 12 35#define LUAC_HEADERSIZE 12
35 36
37#endif /* LUA_DISABLE_BYTECODE */
36#endif 38#endif