aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-07-15 14:40:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-07-15 14:40:27 -0300
commit60b6599e8322dd93e3b33c9496ff035a1c45552f (patch)
treeeb0d9ffd85b1062aea36fa5b82e714931e718082 /ltests.c
parentc612685d4b9ecdf0525b4d4410efa9f70d4b4518 (diff)
downloadlua-60b6599e8322dd93e3b33c9496ff035a1c45552f.tar.gz
lua-60b6599e8322dd93e3b33c9496ff035a1c45552f.tar.bz2
lua-60b6599e8322dd93e3b33c9496ff035a1c45552f.zip
Short strings can be external, too
That complicates a little object equality (and therefore table access for long strings), but the old behavior was somewhat weird. (Short strings, a concept otherwise absent from the manual, could not be external.)
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ltests.c b/ltests.c
index e7bc66dd..d92cd6c5 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1066,8 +1066,12 @@ static int tracegc (lua_State *L) {
1066 1066
1067static int hash_query (lua_State *L) { 1067static int hash_query (lua_State *L) {
1068 if (lua_isnone(L, 2)) { 1068 if (lua_isnone(L, 2)) {
1069 TString *ts;
1069 luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); 1070 luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
1070 lua_pushinteger(L, cast_int(tsvalue(obj_at(L, 1))->hash)); 1071 ts = tsvalue(obj_at(L, 1));
1072 if (ts->tt == LUA_VLNGSTR)
1073 luaS_hashlongstr(ts); /* make sure long string has a hash */
1074 lua_pushinteger(L, cast_int(ts->hash));
1071 } 1075 }
1072 else { 1076 else {
1073 TValue *o = obj_at(L, 1); 1077 TValue *o = obj_at(L, 1);