diff options
-rw-r--r-- | ldump.c | 2 | ||||
-rw-r--r-- | loadlib.c | 2 | ||||
-rw-r--r-- | lundump.c | 2 | ||||
-rw-r--r-- | lundump.h | 7 | ||||
-rw-r--r-- | testes/calls.lua | 4 |
5 files changed, 11 insertions, 6 deletions
@@ -196,7 +196,7 @@ static void dumpFunction (DumpState *D, const Proto *f, TString *psource) { | |||
196 | 196 | ||
197 | static void dumpHeader (DumpState *D) { | 197 | static 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)); |
@@ -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 | */ |
74 | typedef void (*voidf)(void); | 74 | typedef void (*voidf)(void); |
75 | 75 | ||
@@ -276,7 +276,7 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) { | |||
276 | static void checkHeader (LoadState *S) { | 276 | static 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"); |
@@ -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 | ||
423 | print("testing binary chunks") | 423 | print("testing binary chunks") |
424 | do | 424 | do |
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 |