From e93e93faa829afdbc420947828bf0bcdb32af574 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 22 Jul 2025 20:26:46 +0900 Subject: refactor: use variadic arguments in fatal_error() --- tokenize.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tokenize.c') diff --git a/tokenize.c b/tokenize.c index f177d82..b6b5233 100644 --- a/tokenize.c +++ b/tokenize.c @@ -205,7 +205,6 @@ Lexer* lexer_new(PpToken* pp_tokens) { } void tokenize_all(Lexer* l) { - char* buf; int ch; int start; while (l->src[l->pos].kind != PpTokenKind_eof) { @@ -214,7 +213,7 @@ void tokenize_all(Lexer* l) { PpTokenKind k = pp_tok->kind; ++l->pos; if (k == PpTokenKind_header_name) { - fatal_error("not implemented yet"); + unimplemented(); } else if (k == PpTokenKind_identifier) { if (string_equals_cstr(&pp_tok->raw, "break")) { tok->kind = TokenKind_keyword_break; @@ -284,7 +283,7 @@ void tokenize_all(Lexer* l) { ch = '\v'; } } - buf = calloc(4, sizeof(char)); + char* buf = calloc(4, sizeof(char)); sprintf(buf, "%d", ch); tok->raw.data = buf; tok->raw.len = strlen(buf); @@ -356,8 +355,7 @@ void tokenize_all(Lexer* l) { } else if (string_equals_cstr(&pp_tok->raw, ">")) { tok->kind = TokenKind_gt; } else { - sprintf(buf, "unknown token: %.*s", pp_tok->raw.len, pp_tok->raw.data); - fatal_error(buf); + fatal_error("unknown token: %.*s", pp_tok->raw.len, pp_tok->raw.data); } tok->raw.data = pp_tok->raw.data; tok->raw.len = pp_tok->raw.len; -- cgit v1.2.3-70-g09d2