diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-06-05 12:48:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-05 12:48:44 +0100 |
| commit | a747e47582238cf3203ec1d59e099d849682ee7b (patch) | |
| tree | d7adb2d9ba8ad94107df03d4b709762cab021341 /core/strconv | |
| parent | adcda88501bba78865c21fde536a862531b08df1 (diff) | |
| parent | 25feff3eb4c3845e6da4e8e56010301e316b2dd9 (diff) | |
Merge pull request #3675 from Feoramund/fix-partial-infinity
Fix partial parsing of `infinity`
Diffstat (limited to 'core/strconv')
| -rw-r--r-- | core/strconv/strconv.odin | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index c21a06760..11590fa1b 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -882,13 +882,16 @@ 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 3 <= m && m < 9 { // "inf" to "infinity" f = 0h7ff00000_00000000 if sign == 1 else 0hfff00000_00000000 - n = nsign + 3 + if m == 8 { + // We only count the entire prefix if it is precisely "infinity". + n = nsign + m + } else { + // The string was either only "inf" or incomplete. + n = nsign + 3 + } ok = true return } |