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

ruby-changes:28011

From: naruse <ko1@a...>
Date: Tue, 2 Apr 2013 17:46:29 +0900 (JST)
Subject: [ruby-changes:28011] naruse:r40063 (trunk): * re.c (rb_reg_to_s): suppress duplicated charclass warning.

naruse	2013-04-02 17:44:16 +0900 (Tue, 02 Apr 2013)

  New Revision: 40063

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

  Log:
    * re.c (rb_reg_to_s): suppress duplicated charclass warning.
      Regexp#to_s suppress extra its whole regexp options by calling
      onig_new with its source, but it doesn't call rb_reg_preprocess.
      Therefore its Unicode escapes (\u{XXXX}) are given as is,
      and it may cause duplicated charclass warning for example
      "[\u{33}]" (3 is duplicated) or "[\u{a}\u{b}]" (u is duplicated).
      [ruby-core:53649] [Bug #8151]

  Modified files:
    trunk/ChangeLog
    trunk/re.c
    trunk/test/ruby/test_regexp.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40062)
+++ ChangeLog	(revision 40063)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Apr  2 17:38:20 2013  NARUSE, Yui  <naruse@r...>
+
+	* re.c (rb_reg_to_s): suppress duplicated charclass warning.
+	  Regexp#to_s suppress extra its whole regexp options by calling
+	  onig_new with its source, but it doesn't call rb_reg_preprocess.
+	  Therefore its Unicode escapes (\u{XXXX}) are given as is,
+	  and it may cause duplicated charclass warning for example
+	  "[\u{33}]" (3 is duplicated) or "[\u{a}\u{b}]" (u is duplicated).
+	  [ruby-core:53649] [Bug #8151]
+
 Tue Apr  2 16:00:06 2013  NARUSE, Yui  <naruse@r...>
 
 	* vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.
Index: re.c
===================================================================
--- re.c	(revision 40062)
+++ re.c	(revision 40063)
@@ -571,12 +571,15 @@ rb_reg_to_s(VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L571
 	}
 	if (*ptr == ':' && ptr[len-1] == ')') {
 	    Regexp *rp;
+	    VALUE verbose = ruby_verbose;
+	    ruby_verbose = Qfalse;
 
 	    ++ptr;
 	    len -= 2;
             err = onig_new(&rp, ptr, ptr + len, ONIG_OPTION_DEFAULT,
 			   enc, OnigDefaultSyntax, NULL);
 	    onig_free(rp);
+	    ruby_verbose = verbose;
 	}
 	if (err) {
 	    options = RREGEXP(re)->ptr->options;
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 40062)
+++ test/ruby/test_regexp.rb	(revision 40063)
@@ -915,6 +915,9 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L915
 
     bug7471 = '[ruby-core:50344]'
     assert_warning('', bug7471) { Regexp.new('[\D]') =~ "\u3042" }
+
+    bug8151 = '[ruby-core:53649]'
+    assert_warning(/\A\z/, bug8151) { Regexp.new('(?:[\u{33}])').to_s }
   end
 
   def test_property_warn

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

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