From 1d7625cb1efa97694509a725bd0edbdfafbbc318 Mon Sep 17 00:00:00 2001 From: Xavier Wang Date: Thu, 4 Oct 2018 20:45:50 +0800 Subject: [PATCH] - fix incorrect offset in error message. - fix packed option in `protoc`. --- pb.c | 2 +- protoc.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pb.c b/pb.c index 8ad39c2..c620ee7 100644 --- a/pb.c +++ b/pb.c @@ -259,7 +259,7 @@ static void lpb_readbytes(lua_State *L, lpb_SliceEx *s, lpb_SliceEx *pv) { if (pb_readslice(&s->base, (size_t)len, &pv->base) == 0 && len != 0) luaL_error(L, "un-finished bytes (len %d at offset %d)", (int)len, lpb_offset(s)); - pv->head = pv->base.p; + pv->head = s->head; } static int lpb_hexchar(char ch) { diff --git a/protoc.lua b/protoc.lua index e99f1a3..29ab059 100644 --- a/protoc.lua +++ b/protoc.lua @@ -399,6 +399,9 @@ local function field(self, lex, ident) if options then info.default_value, options.default = tostring(options.default), nil info.json_name, options.json_name = options.json_name, nil + if options.packed and options.packed == "false" then + options.packed = false + end end info.options = options if info.number <= 0 then