From e1d6add4f36419ca4fd5fee7b9ba6202c9bf8a5a Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 17 Aug 2025 16:16:22 -0400 Subject: Bugfix for integer parsing --- src/stdlib/integers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/stdlib') diff --git a/src/stdlib/integers.c b/src/stdlib/integers.c index 86be790d..037aba0f 100644 --- a/src/stdlib/integers.c +++ b/src/stdlib/integers.c @@ -429,22 +429,22 @@ public OptionalInt_t Int$parse(Text_t text, Text_t *remainder) { mpz_t i; int result; if (strncmp(str, "0x", 2) == 0) { - const char *end = str + 2 + strcspn(str + 2, "0123456789abcdefABCDEF"); + const char *end = str + 2 + strspn(str + 2, "0123456789abcdefABCDEF"); if (remainder) *remainder = Text$from_str(end); else if (*end != '\0') return NONE_INT; result = mpz_init_set_str(i, str + 2, 16); } else if (strncmp(str, "0o", 2) == 0) { - const char *end = str + 2 + strcspn(str + 2, "01234567"); + const char *end = str + 2 + strspn(str + 2, "01234567"); if (remainder) *remainder = Text$from_str(end); else if (*end != '\0') return NONE_INT; result = mpz_init_set_str(i, str + 2, 8); } else if (strncmp(str, "0b", 2) == 0) { - const char *end = str + 2 + strcspn(str + 2, "01"); + const char *end = str + 2 + strspn(str + 2, "01"); if (remainder) *remainder = Text$from_str(end); else if (*end != '\0') return NONE_INT; result = mpz_init_set_str(i, str + 2, 2); } else { - const char *end = str + 2 + strcspn(str + 2, "0123456789"); + const char *end = str + 2 + strspn(str + 2, "0123456789"); if (remainder) *remainder = Text$from_str(end); else if (*end != '\0') return NONE_INT; result = mpz_init_set_str(i, str, 10); -- cgit v1.2.3