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

ruby-changes:37443

From: tenderlove <ko1@a...>
Date: Fri, 6 Feb 2015 17:01:14 +0900 (JST)
Subject: [ruby-changes:37443] tenderlove:r49524 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: fix support for regular

tenderlove	2015-02-06 17:00:54 +0900 (Fri, 06 Feb 2015)

  New Revision: 49524

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

  Log:
    * ext/psych/lib/psych/visitors/to_ruby.rb: fix support for regular
      expressions with newlines. tenderlove/psych#222
    
    * test/psych/test_yaml.rb: test for change.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb
    trunk/test/psych/test_yaml.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49523)
+++ ChangeLog	(revision 49524)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Feb  6 16:58:31 2015  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/to_ruby.rb: fix support for regular
+	  expressions with newlines. tenderlove/psych#222
+
+	* test/psych/test_yaml.rb: test for change.
+
 Fri Feb  6 10:31:50 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 49523)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 49524)
@@ -32,7 +32,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L32
         return result if @domain_types.empty? || !target.tag
 
         key = target.tag.sub(/^[!\/]*/, '').sub(/(,\d+)\//, '\1:')
-        key = "tag:#{key}" unless key =~ /^(tag:|x-private)/
+        key = "tag:#{key}" unless key =~ /^(?:tag:|x-private)/
 
         if @domain_types.key? key
           value, block = @domain_types[key]
@@ -89,7 +89,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/to_ruby.rb#L89
           Float(@ss.tokenize(o.value))
         when "!ruby/regexp"
           klass = class_loader.regexp
-          o.value =~ /^\/(.*)\/([mixn]*)$/
+          o.value =~ /^\/(.*)\/([mixn]*)$/m
           source  = $1
           options = 0
           lang    = nil
Index: test/psych/test_yaml.rb
===================================================================
--- test/psych/test_yaml.rb	(revision 49523)
+++ test/psych/test_yaml.rb	(revision 49524)
@@ -27,6 +27,10 @@ class Psych_Unit_Tests < Psych::TestCase https://github.com/ruby/ruby/blob/trunk/test/psych/test_yaml.rb#L27
       assert_match "2010-10-10 00:00:00.000000000 Z", yaml
     end
 
+    def test_multiline_regexp
+        assert_cycle(Regexp.new("foo\nbar"))
+    end
+
     # [ruby-core:34969]
     def test_regexp_with_n
         assert_cycle(Regexp.new('',0,'n'))

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

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