aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2025-10-23 10:14:46 +0200
committer lemon<lsof@mailbox.org>2025-10-23 10:14:46 +0200
commit6e7b3186952d5a0877312886747e95b1455db996 (patch)
tree64e40713dda12614a4b966f88561f39b10899360
parent37643338d176c7612bddef054ae46c8cba8e352b (diff)
lex: fix base-16 literals adding an extra zero when there's a type suffix
-rw-r--r--c/lex.c7
1 files changed, 3 insertions, 4 deletions
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;
}
}