diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 12:34:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 12:34:13 +0000 |
commit | 4bf6a04f49a23ab33f6c9209a873c08b6f28fb37 (patch) | |
tree | 434f6d59df910aec76407fbb02968858d00b3344 /lib/scanf.rb | |
parent | 6fba455acbac14d1e5f0e789b8a74101fe060514 (diff) | |
download | ruby-4bf6a04f49a23ab33f6c9209a873c08b6f28fb37.tar.gz |
Fix bug about String#scanf("%a")
* lib/scanf.rb (extract_float, initialize): allow to omit a sign
on the binary exponent. [ruby-core:82435] [Bug #13833]
[Fix GH-1689]
From: tarotaro0 <tarousann11922960@yahoo.co.jp>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/scanf.rb')
-rw-r--r-- | lib/scanf.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/scanf.rb b/lib/scanf.rb index a98c359573..6bd7da4043 100644 --- a/lib/scanf.rb +++ b/lib/scanf.rb @@ -295,7 +295,7 @@ module Scanf def extract_float(s) return nil unless s &&! skip - if /\A(?<sign>[-+]?)0[xX](?<frac>\.\h+|\h+(?:\.\h*)?)[pP](?<exp>[-+]\d+)/ =~ s + if /\A(?<sign>[-+]?)0[xX](?<frac>\.\h+|\h+(?:\.\h*)?)[pP](?<exp>[-+]?\d+)/ =~ s f1, f2 = frac.split('.') f = f1.hex if f2 @@ -411,11 +411,11 @@ module Scanf # %f when /%\*?[aefgAEFG]/ - [ '([-+]?(?:0[xX](?:\.\h+|\h+(?:\.\h*)?)[pP][-+]\d+|\d+(?![\d.])|\d*\.\d*(?:[eE][-+]?\d+)?))', :extract_float ] + [ '([-+]?(?:0[xX](?:\.\h+|\h+(?:\.\h*)?)[pP][-+]?\d+|\d+(?![\d.])|\d*\.\d*(?:[eE][-+]?\d+)?))', :extract_float ] # %5f when /%\*?(\d+)[aefgAEFG]/ - [ '(?=[-+]?(?:0[xX](?:\.\h+|\h+(?:\.\h*)?)[pP][-+]\d+|\d+(?![\d.])|\d*\.\d*(?:[eE][-+]?\d+)?))' + + [ '(?=[-+]?(?:0[xX](?:\.\h+|\h+(?:\.\h*)?)[pP][-+]?\d+|\d+(?![\d.])|\d*\.\d*(?:[eE][-+]?\d+)?))' + "(\\S{1,#{$1}})", :extract_float ] # %5s |