remove usage of goto

This commit is contained in:
tocariimaa 2025-01-19 19:23:39 -03:00
parent c984c94ac8
commit c1d54991c0

View file

@ -265,7 +265,7 @@ string_literal(LexState *ls)
while (chr.val != '"') {
if (i + 1 == STRING_LITERAL_MAX_SIZE) {
lex_error(ls, "string literal length exceeds maximum of %d bytes", STRING_LITERAL_MAX_SIZE);
goto err;
return make_error();
}
if (i + 1 > str_buf_len) {
str_buf = realloc(str_buf, str_buf_len *= 2);
@ -274,7 +274,7 @@ string_literal(LexState *ls)
chr = read_chr(ls);
if (!chr.ok || chr.val == '\n') {
lex_error(ls, "unterminated string literal");
goto err;
return make_error();
}
}
if (i > 0) {
@ -288,8 +288,6 @@ string_literal(LexState *ls)
token.str = Str_from_buf(str_buf, i);
token.len = i;
return token;
err:
return make_error();
}
/* Identifies a numeric literal that may have a prefix: