summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--include/ruby/oniguruma.h2
-rw-r--r--regcomp.c13
-rw-r--r--test/ruby/test_regexp.rb17
-rw-r--r--version.h6
5 files changed, 40 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c441a9c59..b7e7d4364f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Jul 5 00:55:05 2013 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.
+
+ * [bug] (thanks Akinori MUSHA and Ippei Obayashi)
+ Fix a renumbering bug in condition regexp with a named
+ capture. [Bug #8583]
+ * [spec] (thanks Akinori MUSHA)
+ Allow ENCLOSE_OPTION in look-behind.
+
Wed Jul 3 23:31:26 2013 Shota Fukumori <sorah@cookpad.com>
* lib/mkmf.rb (try_config): Fix to not replace $LDFLAGS with $libs
diff --git a/include/ruby/oniguruma.h b/include/ruby/oniguruma.h
index f41c685fb8..0b645bd935 100644
--- a/include/ruby/oniguruma.h
+++ b/include/ruby/oniguruma.h
@@ -40,7 +40,7 @@ extern "C" {
#define ONIGURUMA
#define ONIGURUMA_VERSION_MAJOR 5
#define ONIGURUMA_VERSION_MINOR 13
-#define ONIGURUMA_VERSION_TEENY 4
+#define ONIGURUMA_VERSION_TEENY 5
#ifdef __cplusplus
# ifndef HAVE_PROTOTYPES
diff --git a/regcomp.c b/regcomp.c
index 1373ff2eb4..705e0faad7 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -1943,7 +1943,12 @@ renumber_by_map(Node* node, GroupNumRemap* map)
r = renumber_by_map(NQTFR(node)->target, map);
break;
case NT_ENCLOSE:
- r = renumber_by_map(NENCLOSE(node)->target, map);
+ {
+ EncloseNode* en = NENCLOSE(node);
+ if (en->type == ENCLOSE_CONDITION)
+ en->regnum = map[en->regnum].new_val;
+ r = renumber_by_map(en->target, map);
+ }
break;
case NT_BREF:
@@ -4090,8 +4095,8 @@ restart:
( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \
BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL )
-#define ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY )
-#define ALLOWED_ENCLOSE_IN_LB_NOT 0
+#define ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY | ENCLOSE_OPTION )
+#define ALLOWED_ENCLOSE_IN_LB_NOT ENCLOSE_OPTION
#define ALLOWED_ANCHOR_IN_LB \
( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \
@@ -6646,7 +6651,7 @@ print_indent_tree(FILE* f, Node* node, int indent)
fprintf(f, "<enclose:%"PRIxPTR"> ", (intptr_t)node);
switch (NENCLOSE(node)->type) {
case ENCLOSE_OPTION:
- fprintf(f, "option:%d\n", NENCLOSE(node)->option);
+ fprintf(f, "option:%d", NENCLOSE(node)->option);
break;
case ENCLOSE_MEMORY:
fprintf(f, "memory:%d", NENCLOSE(node)->regnum);
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 46fd4531a0..a62e004918 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -942,4 +942,21 @@ class TestRegexp < Test::Unit::TestCase
err = assert_raise(TypeError){ Regexp.quote(42) }
assert_equal 'no implicit conversion of Fixnum into String', err.message, bug7539
end
+
+ def test_conditional_expression
+ bug8583 = '[ruby-dev:47480] [Bug #8583]'
+
+ conds = {"xy"=>true, "yx"=>true, "xx"=>false, "yy"=>false}
+ assert_match_each(/\A((x)|(y))(?(2)y|x)\z/, conds, bug8583)
+ assert_match_each(/\A((?<x>x)|(?<y>y))(?(<x>)y|x)\z/, conds, bug8583)
+ end
+
+ def assert_match_each(re, conds, msg = nil)
+ errs = conds.select {|str, match| match ^ (re =~ str)}
+ msg = message(msg) {
+ "Expected #{re.inspect} to\n" +
+ errs.map {|str, match| "\t#{'not ' unless match}match #{str.inspect}"}.join(",\n")
+ }
+ assert(errs.empty?, msg)
+ end
end
diff --git a/version.h b/version.h
index e5b444923b..356c27ac6f 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-07-03"
-#define RUBY_PATCHLEVEL 250
+#define RUBY_RELEASE_DATE "2013-07-05"
+#define RUBY_PATCHLEVEL 251
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 7
-#define RUBY_RELEASE_DAY 3
+#define RUBY_RELEASE_DAY 5
#include "ruby/version.h"