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

ruby-changes:45145

From: usa <ko1@a...>
Date: Tue, 27 Dec 2016 19:55:38 +0900 (JST)
Subject: [ruby-changes:45145] usa:r57218 (ruby_2_2): merge revision(s) 57098: [Backport #13042]

usa	2016-12-27 19:55:32 +0900 (Tue, 27 Dec 2016)

  New Revision: 57218

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

  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_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/re.c
    branches/ruby_2_2/test/ruby/test_string.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 57217)
+++ ruby_2_2/ChangeLog	(revision 57218)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Tue Dec 27 19:55:10 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	 * re.c (rb_reg_regsub): other than regexp has no name references.
+	  [Bug #13042]
+
 Tue Dec 27 19:51:43 2016  Kazuki Yamaguchi  <k@r...>
 
 	* encoding.c (rb_enc_ascget): handle needmore error from
Index: ruby_2_2/re.c
===================================================================
--- ruby_2_2/re.c	(revision 57217)
+++ ruby_2_2/re.c	(revision 57218)
@@ -3468,7 +3468,8 @@ rb_reg_regsub(VALUE str, VALUE src, stru https://github.com/ruby/ruby/blob/trunk/ruby_2_2/re.c#L3468
                 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_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 57217)
+++ ruby_2_2/version.h	(revision 57218)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2016-12-27"
-#define RUBY_PATCHLEVEL 408
+#define RUBY_PATCHLEVEL 409
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 12
Index: ruby_2_2/test/ruby/test_string.rb
===================================================================
--- ruby_2_2/test/ruby/test_string.rb	(revision 57217)
+++ ruby_2_2/test/ruby/test_string.rb	(revision 57218)
@@ -1507,6 +1507,10 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_string.rb#L1507
     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_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57098


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

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