More disciplined use of 'getstr' and 'tsslen'

We may want to add other string variants in the future; this change
documents better where the code may need to handle those variants.
This commit is contained in:
Roberto Ierusalimschy
2023-08-17 15:59:28 -03:00
parent f4211a5ea4
commit 9b4f39ab14
9 changed files with 37 additions and 33 deletions

View File

@@ -426,7 +426,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
*/
static void kname (const Proto *p, int c, const char **name) {
TValue *kvalue = &p->k[c];
*name = (ttisstring(kvalue)) ? svalue(kvalue) : "?";
*name = (ttisstring(kvalue)) ? getstr(tsvalue(kvalue)) : "?";
}
@@ -569,7 +569,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
int b = (op == OP_LOADK) ? GETARG_Bx(i)
: GETARG_Ax(p->code[pc + 1]);
if (ttisstring(&p->k[b])) {
*name = svalue(&p->k[b]);
*name = getstr(tsvalue(&p->k[b]));
return "constant";
}
break;
@@ -627,7 +627,7 @@ static const char *funcnamefromcode (lua_State *L, const Proto *p,
default:
return NULL; /* cannot find a reasonable name */
}
*name = getstr(G(L)->tmname[tm]) + 2;
*name = getshrstr(G(L)->tmname[tm]) + 2;
return "metamethod";
}