From 80fe8504f5d7be0a3ddf939981bf4b18266861b6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 11 Mar 2014 15:56:27 -0300 Subject: make all dumps/loads go trhough Load/DumpVector (so it is easier to adapt the code to correct endianess, if needed) --- ldump.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ldump.c') diff --git a/ldump.c b/ldump.c index c86a03c8..5076c430 100644 --- a/ldump.c +++ b/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 2.25 2014/03/10 17:56:32 roberto Exp roberto $ +** $Id: ldump.c,v 2.26 2014/03/11 18:05:46 roberto Exp roberto $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -25,9 +25,14 @@ typedef struct { } DumpState; -#define DumpVar(x,D) DumpBlock(&x,sizeof(x),D) +/* +** All high-level dumps go through DumpVector; you can change it to +** change the endianess of the result +*/ #define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) +#define DumpLiteral(s,D) DumpBlock(s, sizeof(s) - sizeof(char), D) + static void DumpBlock (const void *b, size_t size, DumpState *D) { if (D->status == 0) { @@ -38,6 +43,9 @@ static void DumpBlock (const void *b, size_t size, DumpState *D) { } +#define DumpVar(x,D) DumpVector(&x,1,D) + + static void DumpByte (int y, DumpState *D) { lu_byte x = (lu_byte)y; DumpVar(x, D); @@ -160,8 +168,6 @@ static void DumpFunction (const Proto *f, DumpState *D) { } -#define DumpLiteral(s,D) DumpBlock(s, sizeof(s) - sizeof(char), D) - static void DumpHeader (DumpState *D) { DumpLiteral(LUA_SIGNATURE, D); DumpByte(LUAC_VERSION, D); -- cgit v1.2.3-55-g6feb