summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2021-08-04 09:44:49 -0700
committerGitHub <noreply@github.com>2021-08-04 09:44:49 -0700
commit0179e0cf481018c83f711211bb0f15a1871fa335 (patch)
treea868e07d7e3dba0e67dc113b8d953275670aec11 /lib
parent50fd106a657c4437f946cdd5044da39596f028ef (diff)
parent6e0e7a1e9f83b85615f82d26c5bf1a7d66844a3b (diff)
downloadpsych-0179e0cf481018c83f711211bb0f15a1871fa335.tar.gz
Merge pull request #460 from tbrisker/floatscanner
Improve float scalar scanner
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/scalar_scanner.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb
index 37e9313..5fafaf3 100644
--- a/lib/psych/scalar_scanner.rb
+++ b/lib/psych/scalar_scanner.rb
@@ -9,9 +9,8 @@ module Psych
TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
# Taken from http://yaml.org/type/float.html
- FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
- |[-+]?\.(inf|Inf|INF)(?# infinity)
- |\.(nan|NaN|NAN)(?# not a number))$/x
+ # Base 60, [-+]inf and NaN are handled separately
+ FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10))$/x
# Taken from http://yaml.org/type/int.html
INTEGER = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
@@ -61,7 +60,7 @@ module Psych
rescue ArgumentError
string
end
- elsif string.match?(/^\.inf$/i)
+ elsif string.match?(/^\+?\.inf$/i)
Float::INFINITY
elsif string.match?(/^-\.inf$/i)
-Float::INFINITY