aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/integers.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-17 16:16:22 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-17 16:16:22 -0400
commite1d6add4f36419ca4fd5fee7b9ba6202c9bf8a5a (patch)
treec4ce403f838e998582ac430c7b875400c2ee6d26 /src/stdlib/integers.c
parent4188d627c6869cb6b443ae3b6dece40486f4a039 (diff)
Bugfix for integer parsing
Diffstat (limited to 'src/stdlib/integers.c')
-rw-r--r--src/stdlib/integers.c8
1 files changed, 4 insertions, 4 deletions
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);