summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-07 06:14:46 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-07 06:14:46 +0000
commit9f9388e57ea204d15f9ae073f043dc646739d0e7 (patch)
treee43aa9471d4b50e845ac2521648e11e2b851a446
parent3a2319f3e0eebe9e2024a52c095ae7201c7520e7 (diff)
* regexp.c (re_compile_pattern): allow zero times match for
non-greedy range repeatation. [ruby-core:30613] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--regex.c6
-rw-r--r--test/ruby/test_regexp.rb5
-rw-r--r--version.h6
4 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index cc28ec220d..fe866fff70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jun 7 12:27:29 2010 NARUSE, Yui <[email protected]>
+
+ * regexp.c (re_compile_pattern): allow zero times match for
+ non-greedy range repeatation. [ruby-core:30613]
+
Sat Jun 5 13:31:15 2010 Marc-Andre Lafortune <[email protected]>
* lib/matrix.rb: Matrix library copied from 1.9. It is now identical
diff --git a/regex.c b/regex.c
index e72c3cafbb..59dd3b82a3 100644
--- a/regex.c
+++ b/regex.c
@@ -2152,6 +2152,12 @@ re_compile_pattern(pattern, size, bufp)
more at the end of the loop. */
unsigned nbytes = upper_bound == 1 ? 10 : 20;
+ if (lower_bound == 0 && greedy == 0) {
+ GET_BUFFER_SPACE(3);
+ insert_jump(try_next, laststart, b + 3, b);
+ b += 3;
+ }
+
GET_BUFFER_SPACE(nbytes);
/* Initialize lower bound of the `succeed_n', even
though it will be set during matching by its
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 3f05d6a08a..e89c9e2081 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -467,4 +467,9 @@ class TestRegexp < Test::Unit::TestCase
assert_equal("1", $1)
assert_equal(" " * 4999999, $2)
end
+
+ def test_range_greedy
+ /wo{0,3}?/ =~ "woo"
+ assert_equal("w", $&)
+ end
end
diff --git a/version.h b/version.h
index 7c5cb8a57b..5beab4a9aa 100644
--- a/version.h
+++ b/version.h
@@ -1,7 +1,7 @@
#define RUBY_VERSION "1.8.8"
-#define RUBY_RELEASE_DATE "2010-06-05"
+#define RUBY_RELEASE_DATE "2010-06-07"
#define RUBY_VERSION_CODE 188
-#define RUBY_RELEASE_CODE 20100605
+#define RUBY_RELEASE_CODE 20100607
#define RUBY_PATCHLEVEL -1
#define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 8
#define RUBY_RELEASE_YEAR 2010
#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 5
+#define RUBY_RELEASE_DAY 7
#define NO_STRING_LITERAL_CONCATENATION 1
#ifdef RUBY_EXTERN