From 19afd916870a0621b59e8728d439b0fe10288b99 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 8 Nov 2023 10:02:06 -0300 Subject: Solving merge issue with use of tables in dump/undump The use of tables in dump/undump to reuse strings did not exist in the version that changed the representation of arrays, so it was not corrected for the new API for tables. --- ldump.c | 8 ++++---- lundump.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ldump.c b/ldump.c index 01169c12..c6f2c4e1 100644 --- a/ldump.c +++ b/ldump.c @@ -116,10 +116,10 @@ static void dumpString (DumpState *D, TString *ts) { if (ts == NULL) dumpSize(D, 0); else { - const TValue *idx = luaH_getstr(D->h, ts); - if (ttisinteger(idx)) { /* string already saved? */ + TValue idx; + if (luaH_getstr(D->h, ts, &idx) == HOK) { /* string already saved? */ dumpSize(D, 1); /* reuse a saved string */ - dumpInt(D, ivalue(idx)); /* index of saved string */ + dumpInt(D, ivalue(&idx)); /* index of saved string */ } else { /* must write and save the string */ TValue key, value; /* to save the string in the hash */ @@ -130,7 +130,7 @@ static void dumpString (DumpState *D, TString *ts) { D->nstr++; /* one more saved string */ setsvalue(D->L, &key, ts); /* the string is the key */ setivalue(&value, D->nstr); /* its index is the value */ - luaH_finishset(D->L, D->h, &key, idx, &value); /* h[ts] = nstr */ + luaH_set(D->L, D->h, &key, &value); /* h[ts] = nstr */ /* integer value does not need barrier */ } } diff --git a/lundump.c b/lundump.c index 45708f96..5b4cd2ea 100644 --- a/lundump.c +++ b/lundump.c @@ -143,8 +143,9 @@ static TString *loadStringN (LoadState *S, Proto *p) { return NULL; else if (size == 1) { /* previously saved string? */ int idx = loadInt(S); /* get its index */ - const TValue *stv = luaH_getint(S->h, idx); - return tsvalue(stv); + TValue stv; + luaH_getint(S->h, idx, &stv); + return tsvalue(&stv); } else if (size -= 2, size <= LUAI_MAXSHORTLEN) { /* short string? */ char buff[LUAI_MAXSHORTLEN]; -- cgit v1.2.3-55-g6feb