diff options
author | Parashurama <Rhagdamaziel@ymail.com> | 2016-05-19 21:03:22 +0200 |
---|---|---|
committer | Parashurama <Rhagdamaziel@ymail.com> | 2016-05-19 21:03:22 +0200 |
commit | 5d7d8816e527155aa2a4845dfce6507df872eb92 (patch) | |
tree | 8692effbd119a81ddcc8d0ead03229afd08fa749 /lib/system/sysstr.nim | |
parent | d3e9589b3d6ae682c7f42103e5ae3b255e6a77fb (diff) | |
download | Nim-5d7d8816e527155aa2a4845dfce6507df872eb92.tar.gz |
fixes some issues with underscores in float literals. add more tests.
fixes some potential issues with underscores in float literals. adds more checks for badly positionned underscores in float literals. adds more test files.
Diffstat (limited to 'lib/system/sysstr.nim')
-rw-r--r-- | lib/system/sysstr.nim | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 3177d05bd..64d6634d2 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -328,7 +328,7 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, fraction: uint64 frac_exponent= 0 exp_sign = 1 - first_digit = 0 + first_digit = -1 has_sign = false # Sign? @@ -359,6 +359,7 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, # Skip leading zero while s[i] == '0': inc(i) + while s[i] == '_': inc(i) if s[i] in {'0'..'9'}: first_digit = (s[i].ord - '0'.ord) @@ -366,7 +367,7 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, while s[i] in {'0'..'9'}: inc(kdigits) integer = integer * 10'u64 + (s[i].ord - '0'.ord).uint64 - inc(i); + inc(i) while s[i] == '_': inc(i) # Fractional part? @@ -374,11 +375,12 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, inc(i) # if no integer part, Skip leading zeros if kdigits <= 0: - while s[i] in {'_','0'}: - inc(i) + while s[i] == '0': inc(frac_exponent) + inc(i) + while s[i] == '_': inc(i) - if s[i] in {'0'..'9'}: + if first_digit == -1 and s[i] in {'0'..'9'}: first_digit = (s[i].ord - '0'.ord) # get fractional part while s[i] in {'0'..'9'}: |