diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 09:33:00 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 09:33:00 +0000 |
commit | 6a80859a161de8606d2eca289807c05d8f57dee1 (patch) | |
tree | 5e6c2a49bbdc5cc54f00aa2776dbad97d705f9be | |
parent | 3de31e69edf7f509e4907842435add124893ecfc (diff) | |
download | ruby-6a80859a161de8606d2eca289807c05d8f57dee1.tar.gz |
merge revision(s) 28192:
* 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_7@28224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | regex.c | 6 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 5 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 17 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Tue Jun 8 18:31:02 2010 NARUSE, Yui <naruse@ruby-lang.org> + + * regexp.c (re_compile_pattern): allow zero times match for + non-greedy range repeatation. [ruby-core:30613] + Tue Jun 8 18:08:18 2010 URABE Shyouhei <shyouhei@ruby-lang.org> * Makefile.in (fake.rb): double the backslash. @@ -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 52ac5f5324..93ffb17ec4 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -457,4 +457,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 @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2010-06-08" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20100608 -#define RUBY_PATCHLEVEL 288 +#define RUBY_PATCHLEVEL 289 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 |