aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldump.c2
-rw-r--r--loadlib.c2
-rw-r--r--lundump.c2
-rw-r--r--lundump.h7
-rw-r--r--testes/calls.lua4
5 files changed, 11 insertions, 6 deletions
diff --git a/ldump.c b/ldump.c
index fbadbcc9..f848b669 100644
--- a/ldump.c
+++ b/ldump.c
@@ -196,7 +196,7 @@ static void dumpFunction (DumpState *D, const Proto *f, TString *psource) {
196 196
197static void dumpHeader (DumpState *D) { 197static void dumpHeader (DumpState *D) {
198 dumpLiteral(D, LUA_SIGNATURE); 198 dumpLiteral(D, LUA_SIGNATURE);
199 dumpInt(D, LUAC_VERSION); 199 dumpByte(D, LUAC_VERSION);
200 dumpByte(D, LUAC_FORMAT); 200 dumpByte(D, LUAC_FORMAT);
201 dumpLiteral(D, LUAC_DATA); 201 dumpLiteral(D, LUAC_DATA);
202 dumpByte(D, sizeof(Instruction)); 202 dumpByte(D, sizeof(Instruction));
diff --git a/loadlib.c b/loadlib.c
index ddfecca9..c0ec9a13 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -69,7 +69,7 @@ static const char *const CLIBS = "_CLIBS";
69 69
70/* 70/*
71** Special type equivalent to '(void*)' for functions in gcc 71** Special type equivalent to '(void*)' for functions in gcc
72** (to supress warnings when converting function pointers) 72** (to suppress warnings when converting function pointers)
73*/ 73*/
74typedef void (*voidf)(void); 74typedef void (*voidf)(void);
75 75
diff --git a/lundump.c b/lundump.c
index 17364999..d6b249d5 100644
--- a/lundump.c
+++ b/lundump.c
@@ -276,7 +276,7 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) {
276static void checkHeader (LoadState *S) { 276static void checkHeader (LoadState *S) {
277 /* skip 1st char (already read and checked) */ 277 /* skip 1st char (already read and checked) */
278 checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk"); 278 checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk");
279 if (loadInt(S) != LUAC_VERSION) 279 if (loadByte(S) != LUAC_VERSION)
280 error(S, "version mismatch"); 280 error(S, "version mismatch");
281 if (loadByte(S) != LUAC_FORMAT) 281 if (loadByte(S) != LUAC_FORMAT)
282 error(S, "format mismatch"); 282 error(S, "format mismatch");
diff --git a/lundump.h b/lundump.h
index 5b05fed4..2df6923e 100644
--- a/lundump.h
+++ b/lundump.h
@@ -18,7 +18,12 @@
18#define LUAC_INT 0x5678 18#define LUAC_INT 0x5678
19#define LUAC_NUM cast_num(370.5) 19#define LUAC_NUM cast_num(370.5)
20 20
21#define LUAC_VERSION LUA_VERSION_NUM 21/*
22** Encode major-minor version in one byte, one nibble for each
23*/
24#define MYINT(s) (s[0]-'0') /* assume one-digit numbers */
25#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
26
22#define LUAC_FORMAT 0 /* this is the official format */ 27#define LUAC_FORMAT 0 /* this is the official format */
23 28
24/* load one chunk; from lundump.c */ 29/* load one chunk; from lundump.c */
diff --git a/testes/calls.lua b/testes/calls.lua
index 0141ffa4..1701f155 100644
--- a/testes/calls.lua
+++ b/testes/calls.lua
@@ -422,9 +422,9 @@ assert((function (a) return a end)() == nil)
422 422
423print("testing binary chunks") 423print("testing binary chunks")
424do 424do
425 local header = string.pack("c4BBBc6BBBj", 425 local header = string.pack("c4BBc6BBBj",
426 "\27Lua", -- signature 426 "\27Lua", -- signature
427 (504 >> 7) & 0x7f, (504 & 0x7f) | 0x80, -- version 5.4 (504) 427 0x54, -- version 5.4 (0x54)
428 0, -- format 428 0, -- format
429 "\x19\x93\r\n\x1a\n", -- data 429 "\x19\x93\r\n\x1a\n", -- data
430 4, -- size of instruction 430 4, -- size of instruction