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

ruby-changes:18737

From: tenderlove <ko1@a...>
Date: Thu, 3 Feb 2011 07:07:55 +0900 (JST)
Subject: [ruby-changes:18737] Ruby:r30763 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb: ARG_ENCODING_NONE regular

tenderlove	2011-02-03 07:05:15 +0900 (Thu, 03 Feb 2011)

  New Revision: 30763

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

  Log:
    * ext/psych/lib/psych/visitors/to_ruby.rb: ARG_ENCODING_NONE regular
      expressions can round trip. [ruby-core:34969]
    * test/psych/test_yaml.rb: test for ARG_ENCODING_NONE regex
    * ext/sych/lib/syck/rubytypes.rb: ARG_ENCODING_NONE regular
      expressions can round trip.
    * test/syck/test_yaml.rb: test for ARG_ENCODING_NONE regex

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb
    trunk/ext/syck/lib/syck/rubytypes.rb
    trunk/test/psych/test_yaml.rb
    trunk/test/syck/test_yaml.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30762)
+++ ChangeLog	(revision 30763)
@@ -1,3 +1,15 @@
+Thu Feb  3 07:02:16 2011  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/visitors/to_ruby.rb: ARG_ENCODING_NONE regular
+	  expressions can round trip. [ruby-core:34969]
+
+	* test/psych/test_yaml.rb: test for ARG_ENCODING_NONE regex
+
+	* ext/sych/lib/syck/rubytypes.rb: ARG_ENCODING_NONE regular
+	  expressions can round trip.
+
+	* test/syck/test_yaml.rb: test for ARG_ENCODING_NONE regex
+
 Wed Feb  2 17:09:22 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* io.c (rb_io_fdatasync): Use fsync(2) if if the underlying
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 30762)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 30763)
@@ -60,7 +60,7 @@
         when "tag:yaml.org,2002:float", "!float"
           Float(@ss.tokenize(o.value))
         when "!ruby/regexp"
-          o.value =~ /^\/(.*)\/([mix]*)$/
+          o.value =~ /^\/(.*)\/([mixn]*)$/
           source  = $1
           options = 0
           lang    = nil
@@ -69,6 +69,9 @@
             when 'x' then options |= Regexp::EXTENDED
             when 'i' then options |= Regexp::IGNORECASE
             when 'm' then options |= Regexp::MULTILINE
+
+            # FIXME: there is no constant for ARG_ENCODING_NONE
+            when 'n' then options |= 32
             else lang = option
             end
           end
Index: ext/syck/lib/syck/rubytypes.rb
===================================================================
--- ext/syck/lib/syck/rubytypes.rb	(revision 30762)
+++ ext/syck/lib/syck/rubytypes.rb	(revision 30763)
@@ -261,7 +261,7 @@
 class Regexp
     yaml_as "tag:ruby.yaml.org,2002:regexp"
     def Regexp.yaml_new( klass, tag, val )
-        if String === val and val =~ /^\/(.*)\/([mix]*)$/
+        if String === val and val =~ /^\/(.*)\/([mixn]*)$/
             val = { 'regexp' => $1, 'mods' => $2 }
         end
         if Hash === val
@@ -271,6 +271,7 @@
                 mods |= Regexp::EXTENDED if val['mods'].include?( 'x' )
                 mods |= Regexp::IGNORECASE if val['mods'].include?( 'i' )
                 mods |= Regexp::MULTILINE if val['mods'].include?( 'm' )
+                mods |= 32 if val['mods'].include?( 'n' )
             end
             val.delete( 'mods' )
             r = YAML::object_maker( klass, {} )
Index: test/psych/test_yaml.rb
===================================================================
--- test/psych/test_yaml.rb	(revision 30762)
+++ test/psych/test_yaml.rb	(revision 30763)
@@ -13,6 +13,11 @@
     def teardown
         Psych.domain_types.clear
     end
+
+    # [ruby-core:34969]
+    def test_regexp_with_n
+        assert_cycle(Regexp.new('',0,'n'))
+    end
 	#
 	# Tests modified from 00basic.t in Psych.pm
 	#
Index: test/syck/test_yaml.rb
===================================================================
--- test/syck/test_yaml.rb	(revision 30762)
+++ test/syck/test_yaml.rb	(revision 30763)
@@ -22,6 +22,11 @@
         YAML::ENGINE.yamler = @current_engine
     end
 
+    # [ruby-core:34969]
+    def test_regexp_with_n
+        assert_cycle(Regexp.new('',0,'n'))
+    end
+
 	#
 	# Convert between YAML and the object to verify correct parsing and
 	# emitting

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

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