[前][次][番号順一覧][スレッド一覧]

ruby-changes:43866

From: usa <ko1@a...>
Date: Tue, 16 Aug 2016 20:58:46 +0900 (JST)
Subject: [ruby-changes:43866] usa:r55939 (ruby_2_2): merge revision(s) 55562: [Backport #12454]

usa	2016-08-16 20:58:41 +0900 (Tue, 16 Aug 2016)

  New Revision: 55939

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55939

  Log:
    merge revision(s) 55562: [Backport #12454]
    
    * regcomp.c (noname_disable_map): don't optimize out group 0
      Ruby's Regexp doesn't allow normal numbered groups if the regexp
      has named groups. On such case it optimizes out related NT_ENCLOSE.
      But even on the case it can use \g<0>.
      This fix not to remove NT_ENCLOSE whose regnum is 0.
      [ruby-core:75828] [Bug #12454]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/regcomp.c
    branches/ruby_2_2/test/ruby/test_regexp.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/regcomp.c
===================================================================
--- ruby_2_2/regcomp.c	(revision 55938)
+++ ruby_2_2/regcomp.c	(revision 55939)
@@ -1876,17 +1876,16 @@ noname_disable_map(Node** plink, GroupNu https://github.com/ruby/ruby/blob/trunk/ruby_2_2/regcomp.c#L1876
 	  (*counter)++;
 	  map[en->regnum].new_val = *counter;
 	  en->regnum = *counter;
-	  r = noname_disable_map(&(en->target), map, counter);
 	}
-	else {
+	else if (en->regnum != 0) {
 	  *plink = en->target;
 	  en->target = NULL_NODE;
 	  onig_node_free(node);
 	  r = noname_disable_map(plink, map, counter);
+	  break;
 	}
       }
-      else
-	r = noname_disable_map(&(en->target), map, counter);
+      r = noname_disable_map(&(en->target), map, counter);
     }
     break;
 
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 55938)
+++ ruby_2_2/ChangeLog	(revision 55939)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Tue Aug 16 20:58:11 2016  NARUSE, Yui  <naruse@r...>
+
+	* regcomp.c (noname_disable_map): don't optimize out group 0
+	  Ruby's Regexp doesn't allow normal numbered groups if the regexp
+	  has named groups. On such case it optimizes out related NT_ENCLOSE.
+	  But even on the case it can use \g<0>.
+	  This fix not to remove NT_ENCLOSE whose regnum is 0.
+	  [ruby-core:75828] [Bug #12454]
+
 Tue Aug 16 20:56:30 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* missing/crypt.c: fix size macros to use configured values
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 55938)
+++ ruby_2_2/version.h	(revision 55939)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.6"
 #define RUBY_RELEASE_DATE "2016-08-16"
-#define RUBY_PATCHLEVEL 365
+#define RUBY_PATCHLEVEL 366
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_2/test/ruby/test_regexp.rb
===================================================================
--- ruby_2_2/test/ruby/test_regexp.rb	(revision 55938)
+++ ruby_2_2/test/ruby/test_regexp.rb	(revision 55939)
@@ -390,6 +390,7 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_regexp.rb#L390
     assert_raise(RegexpError) { Regexp.new(")(") }
     assert_raise(RegexpError) { Regexp.new('[\\40000000000') }
     assert_raise(RegexpError) { Regexp.new('[\\600000000000.') }
+    assert_raise(RegexpError) { Regexp.new("((?<v>))\\g<0>") }
   end
 
   def test_unescape

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r55562


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]