diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-08 10:02:06 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-11-08 10:02:06 -0300 |
commit | 19afd916870a0621b59e8728d439b0fe10288b99 (patch) | |
tree | 297896bffc970723f98b2292868adfd97c61bd25 | |
parent | 37c215b43f27a1c41e8a920987e1c3bd7b34330d (diff) | |
download | lua-19afd916870a0621b59e8728d439b0fe10288b99.tar.gz lua-19afd916870a0621b59e8728d439b0fe10288b99.tar.bz2 lua-19afd916870a0621b59e8728d439b0fe10288b99.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | ldump.c | 8 | ||||
-rw-r--r-- | lundump.c | 5 |
2 files changed, 7 insertions, 6 deletions
@@ -116,10 +116,10 @@ static void dumpString (DumpState *D, TString *ts) { | |||
116 | if (ts == NULL) | 116 | if (ts == NULL) |
117 | dumpSize(D, 0); | 117 | dumpSize(D, 0); |
118 | else { | 118 | else { |
119 | const TValue *idx = luaH_getstr(D->h, ts); | 119 | TValue idx; |
120 | if (ttisinteger(idx)) { /* string already saved? */ | 120 | if (luaH_getstr(D->h, ts, &idx) == HOK) { /* string already saved? */ |
121 | dumpSize(D, 1); /* reuse a saved string */ | 121 | dumpSize(D, 1); /* reuse a saved string */ |
122 | dumpInt(D, ivalue(idx)); /* index of saved string */ | 122 | dumpInt(D, ivalue(&idx)); /* index of saved string */ |
123 | } | 123 | } |
124 | else { /* must write and save the string */ | 124 | else { /* must write and save the string */ |
125 | TValue key, value; /* to save the string in the hash */ | 125 | TValue key, value; /* to save the string in the hash */ |
@@ -130,7 +130,7 @@ static void dumpString (DumpState *D, TString *ts) { | |||
130 | D->nstr++; /* one more saved string */ | 130 | D->nstr++; /* one more saved string */ |
131 | setsvalue(D->L, &key, ts); /* the string is the key */ | 131 | setsvalue(D->L, &key, ts); /* the string is the key */ |
132 | setivalue(&value, D->nstr); /* its index is the value */ | 132 | setivalue(&value, D->nstr); /* its index is the value */ |
133 | luaH_finishset(D->L, D->h, &key, idx, &value); /* h[ts] = nstr */ | 133 | luaH_set(D->L, D->h, &key, &value); /* h[ts] = nstr */ |
134 | /* integer value does not need barrier */ | 134 | /* integer value does not need barrier */ |
135 | } | 135 | } |
136 | } | 136 | } |
@@ -143,8 +143,9 @@ static TString *loadStringN (LoadState *S, Proto *p) { | |||
143 | return NULL; | 143 | return NULL; |
144 | else if (size == 1) { /* previously saved string? */ | 144 | else if (size == 1) { /* previously saved string? */ |
145 | int idx = loadInt(S); /* get its index */ | 145 | int idx = loadInt(S); /* get its index */ |
146 | const TValue *stv = luaH_getint(S->h, idx); | 146 | TValue stv; |
147 | return tsvalue(stv); | 147 | luaH_getint(S->h, idx, &stv); |
148 | return tsvalue(&stv); | ||
148 | } | 149 | } |
149 | else if (size -= 2, size <= LUAI_MAXSHORTLEN) { /* short string? */ | 150 | else if (size -= 2, size <= LUAI_MAXSHORTLEN) { /* short string? */ |
150 | char buff[LUAI_MAXSHORTLEN]; | 151 | char buff[LUAI_MAXSHORTLEN]; |