From c1d54991c009c77773519ccfa33c6583110e8c5b Mon Sep 17 00:00:00 2001 From: tocariimaa Date: Sun, 19 Jan 2025 19:23:39 -0300 Subject: [PATCH] remove usage of goto --- compiler/lex.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/lex.c b/compiler/lex.c index 17c879d..6c29b46 100644 --- a/compiler/lex.c +++ b/compiler/lex.c @@ -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: