New macro 'getlstr'

Accesses content and length of a 'TString'.
This commit is contained in:
Roberto Ierusalimschy
2023-08-30 11:26:16 -03:00
parent 96f7714237
commit f33cda8d6e
5 changed files with 37 additions and 22 deletions

View File

@@ -520,7 +520,8 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
** local variable.
*/
static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {
const char *varname = getstr(getlocalvardesc(ls->fs, gt->nactvar)->vd.name);
TString *tsname = getlocalvardesc(ls->fs, gt->nactvar)->vd.name;
const char *varname = getstr(tsname);
const char *msg = "<goto %s> at line %d jumps into the scope of local '%s'";
msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line, varname);
luaK_semerror(ls, msg); /* raise the error */
@@ -1708,7 +1709,8 @@ static void localfunc (LexState *ls) {
static int getlocalattribute (LexState *ls) {
/* ATTRIB -> ['<' Name '>'] */
if (testnext(ls, '<')) {
const char *attr = getstr(str_checkname(ls));
TString *ts = str_checkname(ls);
const char *attr = getstr(ts);
checknext(ls, '>');
if (strcmp(attr, "const") == 0)
return RDKCONST; /* read-only variable */