From c8121ce34b39c6fd31899f4da91e26063c8af54f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 12 Feb 2024 15:16:11 -0300 Subject: Revising code for Varint encoding in dumps - Usign lua_Unsigned to count strings. - Varint uses a type large enough both for size_t and lua_Unsigned. - Most-Significant Bit 0 means last byte, to conform to common usage. - (unrelated) Change in macro 'getaddr' so that multiplication is by constants. --- lundump.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lundump.h') diff --git a/lundump.h b/lundump.h index b10307e4..ff66d2e7 100644 --- a/lundump.h +++ b/lundump.h @@ -7,6 +7,8 @@ #ifndef lundump_h #define lundump_h +#include + #include "llimits.h" #include "lobject.h" #include "lzio.h" @@ -25,6 +27,19 @@ #define LUAC_FORMAT 0 /* this is the official format */ + +/* +** Type to handle MSB Varint encoding: Try to get the largest unsigned +** integer available. (It was enough to be the largest between size_t and +** lua_Integer, but the C89 preprocessor knows nothing about size_t.) +*/ +#if !defined(LUA_USE_C89) && defined(LLONG_MAX) +typedef unsigned long long varint_t; +#else +typedef unsigned long varint_t; +#endif + + /* load one chunk; from lundump.c */ LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name, int fixed); -- cgit v1.2.3-55-g6feb