diff options
author | dblack <dblack@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-03 12:54:13 +0000 |
---|---|---|
committer | dblack <dblack@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-03 12:54:13 +0000 |
commit | 9cab7d15ca791d0b14db03217485a7c756097a71 (patch) | |
tree | 36e2d3c91003a075b2b65a6240d6efa09f482394 | |
parent | 6378201f8b202e493613d1c0936788ddbe708c76 (diff) |
* lib/scanf.rb: fixed bug involving matching literal '['
* test/scanf/test_scanf.rb: added test for scanf.rb fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/scanf.rb | 2 | ||||
-rw-r--r-- | test/scanf/test_scanf.rb | 7 |
3 files changed, 14 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Wed Sep 3 21:49:00 2008 David A. Black <[email protected]> + + * lib/scanf.rb: fixed bug involving matching literal '[' + + * test/scanf/test_scanf.rb: added test for scanf.rb fix + Wed Sep 3 21:31:59 2008 Tanaka Akira <[email protected]> * transcode_data.h (WORDINDEX_SHIFT_BITS): defined. diff --git a/lib/scanf.rb b/lib/scanf.rb index 564ce11fee..cbb98b6f9f 100644 --- a/lib/scanf.rb +++ b/lib/scanf.rb @@ -325,7 +325,7 @@ module Scanf end def count_space? - /(?:\A|\S)%\*?\d*c|\[/.match(@spec_string) + /(?:\A|\S)%\*?\d*c|%\d*\[/.match(@spec_string) end def initialize(str) diff --git a/test/scanf/test_scanf.rb b/test/scanf/test_scanf.rb index fe4ac507b4..66ca629f54 100644 --- a/test/scanf/test_scanf.rb +++ b/test/scanf/test_scanf.rb @@ -276,6 +276,13 @@ def tests [ "%f", "+3.25", [3.25] ], [ "%f", "+3.25e2", [325.0] ], [ "%f", "3.z", [3.0] ], + +# Testing embedded matches including literal '[' behavior + [",%d,%f", ",10,1.1", [10,1.1] ], + [" ,%d,%f", " ,10,1.1", [10,1.1] ], + ["[%d,%f", "[10,1.1", [10,1.1] ], + [" [%d,%f", " [10,1.1", [10,1.1] ], + ] end end |