Skip to content

Commit

Permalink
* lib/scanf.rb: fix %[egEFG] isn't accept.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Mar 28, 2010
1 parent c08277c commit 63dd509
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Sun Mar 28 09:28:33 2010 NARUSE, Yui <[email protected]>

* lib/scanf.rb: fix %[egEFG] isn't accept.

Sun Mar 28 09:53:02 2010 Tanaka Akira <[email protected]>

* time.c: rename small integer specialization related identifiers.
Expand Down
6 changes: 3 additions & 3 deletions lib/scanf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,11 @@ def initialize(str)
[ "([-+][0-7]{1,#{$1.to_i-1}}|[0-7]{1,#{$1}})", :extract_octal ]

# %f
when /%\*?f/
when /%\*?[efgEFG]/
[ '([-+]?((\d+(?>(?=[^\d.]|$)))|(\d*(\.(\d*([eE][-+]?\d+)?)))))', :extract_float ]

# %5f
when /%\*?(\d+)f/
when /%\*?(\d+)[efgEFG]/
[ "(\\S{1,#{$1}})", :extract_float ]

# %5s
Expand Down Expand Up @@ -490,7 +490,7 @@ class FormatString
attr_reader :string_left, :last_spec_tried,
:last_match_tried, :matched_count, :space

SPECIFIERS = 'diuXxofeEgsc'
SPECIFIERS = 'diuXxofFeEgGsc'
REGEX = /
# possible space, followed by...
(?:\s*
Expand Down
10 changes: 5 additions & 5 deletions test/scanf/test_scanf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ def tests

# Testing 'f'
[ "%2f", "x", [0.0] ], # width-floats match anything (by design)
[ "%f", "1.23e45", [1.23e+45] ],
[ "%f", "3.25ee", [3.25] ],
[ "%f", "3..25", [3.0] ],
[ "%f", "+3.25", [3.25] ],
[ "%f", "+3.25e2", [325.0] ],
[ "%F", "1.23e45", [1.23e+45] ],
[ "%e", "3.25ee", [3.25] ],
[ "%E", "3..25", [3.0] ],
[ "%g", "+3.25", [3.25] ],
[ "%G", "+3.25e2", [325.0] ],
[ "%f", "3.z", [3.0] ],

# Testing embedded matches including literal '[' behavior
Expand Down

0 comments on commit 63dd509

Please sign in to comment.