summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/scanf.rb2
-rw-r--r--test/scanf/test_scanf.rb7
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c40e751330..6790515ea8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Sep 3 21:49:00 2008 David A. Black <dblack@rubypal.com>
+
+ * 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 <akr@fsij.org>
* 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