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

ruby-changes:45276

From: nagachika <ko1@a...>
Date: Tue, 17 Jan 2017 04:34:59 +0900 (JST)
Subject: [ruby-changes:45276] nagachika:r57349 (ruby_2_3): merge revision(s) 57098: [Backport #13042]

nagachika	2017-01-17 04:34:52 +0900 (Tue, 17 Jan 2017)

  New Revision: 57349

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

  Log:
    merge revision(s) 57098: [Backport #13042]
    
    re.c: non-regexp name reference
    
    * re.c (rb_reg_regsub): other than regexp has no name references.
      [ruby-core:78686] [Bug #13042]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/re.c
    branches/ruby_2_3/test/ruby/test_string.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/re.c
===================================================================
--- ruby_2_3/re.c	(revision 57348)
+++ ruby_2_3/re.c	(revision 57349)
@@ -3465,7 +3465,8 @@ rb_reg_regsub(VALUE str, VALUE src, stru https://github.com/ruby/ruby/blob/trunk/ruby_2_3/re.c#L3465
                 if (name_end < e) {
 		    VALUE n = rb_str_subseq(str, (long)(name - RSTRING_PTR(str)),
 					    (long)(name_end - name));
-		    if (!rb_enc_compatible(RREGEXP(regexp)->src, n) ||
+		    if (NIL_P(regexp) ||
+		        !rb_enc_compatible(RREGEXP(regexp)->src, n) ||
 			(no = name_to_backref_number(regs, regexp, name, name_end)) < 1) {
 			name_to_backref_error(n);
 		    }
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 57348)
+++ ruby_2_3/version.h	(revision 57349)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.3"
 #define RUBY_RELEASE_DATE "2017-01-17"
-#define RUBY_PATCHLEVEL 233
+#define RUBY_PATCHLEVEL 234
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 1
Index: ruby_2_3/test/ruby/test_string.rb
===================================================================
--- ruby_2_3/test/ruby/test_string.rb	(revision 57348)
+++ ruby_2_3/test/ruby/test_string.rb	(revision 57349)
@@ -1483,6 +1483,10 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_string.rb#L1483
     assert_equal(S("Abc"), S("abc").sub("a") {m = $~; "A"})
     assert_equal(S("a"), m[0])
     assert_equal(/a/, m.regexp)
+    bug = '[ruby-core:78686] [Bug #13042] other than regexp has no name references'
+    assert_raise_with_message(IndexError, /oops/, bug) {
+      'hello'.gsub('hello', '\k<oops>')
+    }
   end
 
   def test_sub!

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57098


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

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