String buffers, part 2a: internal SBuf reorg. Use full pointers.

Sponsored by fmad.io.
This commit is contained in:
Mike Pall
2021-06-01 00:45:06 +02:00
parent b5dafe5891
commit 394fb6267a
24 changed files with 153 additions and 160 deletions

View File

@@ -105,7 +105,7 @@ static void lex_number(LexState *ls, TValue *tv)
lex_savenext(ls);
}
lex_save(ls, '\0');
fmt = lj_strscan_scan((const uint8_t *)sbufB(&ls->sb), sbuflen(&ls->sb)-1, tv,
fmt = lj_strscan_scan((const uint8_t *)ls->sb.b, sbuflen(&ls->sb)-1, tv,
(LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) |
(LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0));
if (LJ_DUALNUM && fmt == STRSCAN_INT) {
@@ -180,7 +180,7 @@ static void lex_longstring(LexState *ls, TValue *tv, int sep)
}
} endloop:
if (tv) {
GCstr *str = lj_parse_keepstr(ls, sbufB(&ls->sb) + (2 + (MSize)sep),
GCstr *str = lj_parse_keepstr(ls, ls->sb.b + (2 + (MSize)sep),
sbuflen(&ls->sb) - 2*(2 + (MSize)sep));
setstrV(ls->L, tv, str);
}
@@ -286,7 +286,7 @@ static void lex_string(LexState *ls, TValue *tv)
}
lex_savenext(ls); /* Skip trailing delimiter. */
setstrV(ls->L, tv,
lj_parse_keepstr(ls, sbufB(&ls->sb)+1, sbuflen(&ls->sb)-2));
lj_parse_keepstr(ls, ls->sb.b+1, sbuflen(&ls->sb)-2));
}
/* -- Main lexical scanner ------------------------------------------------ */
@@ -306,7 +306,7 @@ static LexToken lex_scan(LexState *ls, TValue *tv)
do {
lex_savenext(ls);
} while (lj_char_isident(ls->c));
s = lj_parse_keepstr(ls, sbufB(&ls->sb), sbuflen(&ls->sb));
s = lj_parse_keepstr(ls, ls->sb.b, sbuflen(&ls->sb));
setstrV(ls->L, tv, s);
if (s->reserved > 0) /* Reserved word? */
return TK_OFS + s->reserved;
@@ -496,7 +496,7 @@ void lj_lex_error(LexState *ls, LexToken tok, ErrMsg em, ...)
tokstr = NULL;
} else if (tok == TK_name || tok == TK_string || tok == TK_number) {
lex_save(ls, '\0');
tokstr = sbufB(&ls->sb);
tokstr = ls->sb.b;
} else {
tokstr = lj_lex_token2str(ls, tok);
}