mirror of https://github.com/rusefi/lua.git
Back to old encoding of versions in binary files
(Undoing part of commit f53eabeed8.) It is better to keep this encoding stable, so that all Lua versions can read at least the version of a binary file.
This commit is contained in:
parent
9a6f47f0ed
commit
61a4e64a66
2
ldump.c
2
ldump.c
|
@ -196,7 +196,7 @@ static void dumpFunction (DumpState *D, const Proto *f, TString *psource) {
|
|||
|
||||
static void dumpHeader (DumpState *D) {
|
||||
dumpLiteral(D, LUA_SIGNATURE);
|
||||
dumpInt(D, LUAC_VERSION);
|
||||
dumpByte(D, LUAC_VERSION);
|
||||
dumpByte(D, LUAC_FORMAT);
|
||||
dumpLiteral(D, LUAC_DATA);
|
||||
dumpByte(D, sizeof(Instruction));
|
||||
|
|
|
@ -69,7 +69,7 @@ static const char *const CLIBS = "_CLIBS";
|
|||
|
||||
/*
|
||||
** Special type equivalent to '(void*)' for functions in gcc
|
||||
** (to supress warnings when converting function pointers)
|
||||
** (to suppress warnings when converting function pointers)
|
||||
*/
|
||||
typedef void (*voidf)(void);
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) {
|
|||
static void checkHeader (LoadState *S) {
|
||||
/* skip 1st char (already read and checked) */
|
||||
checkliteral(S, &LUA_SIGNATURE[1], "not a binary chunk");
|
||||
if (loadInt(S) != LUAC_VERSION)
|
||||
if (loadByte(S) != LUAC_VERSION)
|
||||
error(S, "version mismatch");
|
||||
if (loadByte(S) != LUAC_FORMAT)
|
||||
error(S, "format mismatch");
|
||||
|
|
|
@ -18,7 +18,12 @@
|
|||
#define LUAC_INT 0x5678
|
||||
#define LUAC_NUM cast_num(370.5)
|
||||
|
||||
#define LUAC_VERSION LUA_VERSION_NUM
|
||||
/*
|
||||
** Encode major-minor version in one byte, one nibble for each
|
||||
*/
|
||||
#define MYINT(s) (s[0]-'0') /* assume one-digit numbers */
|
||||
#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
|
||||
|
||||
#define LUAC_FORMAT 0 /* this is the official format */
|
||||
|
||||
/* load one chunk; from lundump.c */
|
||||
|
|
|
@ -422,9 +422,9 @@ assert((function (a) return a end)() == nil)
|
|||
|
||||
print("testing binary chunks")
|
||||
do
|
||||
local header = string.pack("c4BBBc6BBBj",
|
||||
local header = string.pack("c4BBc6BBBj",
|
||||
"\27Lua", -- signature
|
||||
(504 >> 7) & 0x7f, (504 & 0x7f) | 0x80, -- version 5.4 (504)
|
||||
0x54, -- version 5.4 (0x54)
|
||||
0, -- format
|
||||
"\x19\x93\r\n\x1a\n", -- data
|
||||
4, -- size of instruction
|
||||
|
|
Loading…
Reference in New Issue