Permalink
Browse files

merge revision(s) 41764,41765,41767: [Backport #8583]

	* regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.
	  https://bugs.ruby-lang.org/issues/8583
	  * [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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 4090bd7 commit 16f70c0e89f50e034a2a5d5cf2ec3d5127d34d6c @nagachika nagachika committed Jul 4, 2013
Showing with 40 additions and 8 deletions.
  1. +10 −0 ChangeLog
  2. +1 −1 include/ruby/oniguruma.h
  3. +9 −4 regcomp.c
  4. +17 −0 test/ruby/test_regexp.rb
  5. +3 −3 version.h
View
@@ -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
View
@@ -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
View
@@ -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 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
( 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);
View
@@ -942,4 +942,21 @@ def test_error_message_on_failed_conversion
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
View
@@ -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"

0 comments on commit 16f70c0

Please sign in to comment.