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

ruby-changes:37609

From: naruse <ko1@a...>
Date: Sun, 22 Feb 2015 21:21:22 +0900 (JST)
Subject: [ruby-changes:37609] naruse:r49690 (ruby_2_2): merge revision(s) 49675:

naruse	2015-02-22 21:20:57 +0900 (Sun, 22 Feb 2015)

  New Revision: 49690

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

  Log:
    merge revision(s) 49675:
    
    * re.c (match_aref): RMatch::regexp is Qnil after matching by a
      string since r45451.  [ruby-core:68209] [Bug #10877]

  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_regexp.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/re.c
===================================================================
--- ruby_2_2/re.c	(revision 49689)
+++ ruby_2_2/re.c	(revision 49690)
@@ -1787,7 +1787,7 @@ name_to_backref_error(VALUE name) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/re.c#L1787
 static VALUE
 match_aref(int argc, VALUE *argv, VALUE match)
 {
-    VALUE idx, rest;
+    VALUE idx, rest, re;
 
     match_check(match);
     rb_scan_args(argc, argv, "11", &idx, &rest);
@@ -1808,7 +1808,8 @@ match_aref(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/re.c#L1808
 		/* fall through */
 	      case T_STRING:
 		p = StringValuePtr(idx);
-		if (!rb_enc_compatible(RREGEXP(RMATCH(match)->regexp)->src, idx) ||
+		re = RMATCH(match)->regexp;
+		if (NIL_P(re) || !rb_enc_compatible(RREGEXP(re)->src, idx) ||
 		    (num = name_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp,
 						  p, p + RSTRING_LEN(idx))) < 1) {
 		    name_to_backref_error(idx);
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 49689)
+++ ruby_2_2/ChangeLog	(revision 49690)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sun Feb 22 21:20:37 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* re.c (match_aref): RMatch::regexp is Qnil after matching by a
+	  string since r45451.  [ruby-core:68209] [Bug #10877]
+
 Sun Feb 22 17:11:25 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* Makefile.in (probes.stamp): rebuild dtrace dependent objects
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 49689)
+++ ruby_2_2/version.h	(revision 49690)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.0"
 #define RUBY_RELEASE_DATE "2015-02-22"
-#define RUBY_PATCHLEVEL 76
+#define RUBY_PATCHLEVEL 77
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_2/test/ruby/test_regexp.rb
===================================================================
--- ruby_2_2/test/ruby/test_regexp.rb	(revision 49689)
+++ ruby_2_2/test/ruby/test_regexp.rb	(revision 49690)
@@ -545,6 +545,19 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_regexp.rb#L545
     assert_equal("foo", $&)
   end
 
+  def test_match_without_regexp
+    bug10877 = '[ruby-core:68209] [Bug #10877]'
+    "abc".sub("a", "")
+    assert_raise_with_message(IndexError, /foo/, bug10877) {$~["foo"]}
+    key = "\u{3042}"
+    [Encoding::UTF_8, Encoding::Shift_JIS, Encoding::EUC_JP].each do |enc|
+      idx = key.encode(enc)
+      EnvUtil.with_default_external(enc) do
+        assert_raise_with_message(IndexError, /#{idx}/, bug10877) {$~[idx]}
+      end
+    end
+  end
+
   def test_last_match
     /(...)(...)(...)(...)?/.match("foobarbaz")
     assert_equal("foobarbaz", Regexp.last_match(0))

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


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

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