aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/scanf.rb6
-rw-r--r--test/scanf/test_scanf.rb1
2 files changed, 4 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
diff --git a/test/scanf/test_scanf.rb b/test/scanf/test_scanf.rb
index 827eb2fc3b..988ff99adc 100644
--- a/test/scanf/test_scanf.rb
+++ b/test/scanf/test_scanf.rb
@@ -258,6 +258,7 @@ module ScanfTests
[ "%G", "+3.25e2", [325.0] ],
[ "%f", "3.z", [3.0] ],
[ "%a", "0X1P+10", [1024.0] ],
+ [ "%a", "0X1P10", [1024.0] ],
[ "%A", "0x1.deadbeefp+99", [1.1851510441583988e+30] ],
# Testing embedded matches including literal '[' behavior