summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--regparse.c4
-rw-r--r--test/ruby/test_regexp.rb4
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 51c2c35908..4b82b9f7f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Nov 29 19:19:32 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regparse.c (is_invalid_quantifier_target): Perl and old Ruby
+ accepts quantifier on anchors. [ruby-core:20161]
+
Sat Nov 29 00:18:30 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* cont.c (fiber_alloc): separate allocation and initialization.
diff --git a/regparse.c b/regparse.c
index c7b42eaf74..8a02966def 100644
--- a/regparse.c
+++ b/regparse.c
@@ -2112,6 +2112,7 @@ conv_backslash_value(int c, ScanEnv* env)
return c;
}
+#if 0 /* no invalid quantifier */
static int
is_invalid_quantifier_target(Node* node)
{
@@ -2143,6 +2144,9 @@ is_invalid_quantifier_target(Node* node)
}
return 0;
}
+#else
+#define is_invalid_quantifier_target(node) 0
+#endif
/* ?:0, *:1, +:2, ??:3, *?:4, +?:5 */
static int
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index fdfef04b4d..d6441c9573 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -604,11 +604,13 @@ class TestRegexp < Test::Unit::TestCase
check(/\Aa{0}+\z/, "", %w(a aa aab))
check(/\Aa{1}+\z/, %w(a aa), ["", "aab"])
check(/\Aa{1,2}b{1,2}\z/, %w(ab aab abb aabb), ["", "aaabb", "abbb"])
+ check(/(?!x){0,1}/, [ ['', 'ab'], ['', ''] ])
+ check(/c\z{0,1}/, [ ['c', 'abc'], ['c', 'cab']], ['abd'])
+ check(/\A{0,1}a/, [ ['a', 'abc'], ['a', '____abc']], ['bcd'])
failcheck('.{100001}')
failcheck('.{0,100001}')
failcheck('.{1,0}')
failcheck('{0}')
- failcheck('(?!x){0,1}')
end
def test_parse_comment