aboutsummaryrefslogtreecommitdiff
path: root/core/strconv
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-04 13:24:46 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-04 13:24:46 -0400
commitd33668fa91b0f64cb6f69f315a2b2e8609fdbee0 (patch)
treef94ceec24036ab915687d958aa509f16c658e804 /core/strconv
parent3b7100f8e5cdf325a51926ba02f785a5443b0415 (diff)
Fix partial parsing of "infinity" in `parse_f64_prefix`
It was previously reporting an invalid number of characters parsed for any string other than "inf", "+inf", or "-inf".
Diffstat (limited to 'core/strconv')
-rw-r--r--core/strconv/strconv.odin9
1 files changed, 3 insertions, 6 deletions
diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin
index 94842617e..990b2be2f 100644
--- a/core/strconv/strconv.odin
+++ b/core/strconv/strconv.odin
@@ -878,13 +878,10 @@ parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) {
s = s[1:]
fallthrough
case 'i', 'I':
- n = common_prefix_len_ignore_case(s, "infinity")
- if 3 < n && n < 8 { // "inf" or "infinity"
- n = 3
- }
- if n == 3 || n == 8 {
+ m := common_prefix_len_ignore_case(s, "infinity")
+ if m == 3 || m == 8 { // "inf" or "infinity"
f = 0h7ff00000_00000000 if sign == 1 else 0hfff00000_00000000
- n = nsign + 3
+ n = nsign + m
ok = true
return
}