From 6e7b3186952d5a0877312886747e95b1455db996 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 23 Oct 2025 10:14:46 +0200 Subject: lex: fix base-16 literals adding an extra zero when there's a type suffix --- c/lex.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'c') diff --git a/c/lex.c b/c/lex.c index 6c0d4c8..7c9b615 100644 --- a/c/lex.c +++ b/c/lex.c @@ -212,11 +212,10 @@ parsenumlit(uvlong *outi, double *outf, const struct token *tk, bool ispp) for (; sx < tk->s + tk->len; ++sx) { if (base < 16) { if (!in_range(c = *sx, '0', '0'+base-1)) break; - n = n * base + c - '0'; + n = n*base + c - '0'; } else { - n *= base; - if (in_range(c = *sx, '0', '9')) n += c - '0'; - else if (in_range(c|32, 'a', 'f')) n += 0xa + (c|32) - 'a'; + if (in_range(c = *sx, '0', '9')) n = n*base + c - '0'; + else if (in_range(c|32, 'a', 'f')) n = n*base + 0xa + (c|32) - 'a'; else break; } } -- cgit v1.2.3