diff options
| author | 2025-10-23 10:14:46 +0200 | |
|---|---|---|
| committer | 2025-10-23 10:14:46 +0200 | |
| commit | 6e7b3186952d5a0877312886747e95b1455db996 (patch) | |
| tree | 64e40713dda12614a4b966f88561f39b10899360 | |
| parent | 37643338d176c7612bddef054ae46c8cba8e352b (diff) | |
lex: fix base-16 literals adding an extra zero when there's a type suffix
| -rw-r--r-- | c/lex.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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; } } |