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

ruby-changes:43423

From: hsbt <ko1@a...>
Date: Fri, 24 Jun 2016 18:06:13 +0900 (JST)
Subject: [ruby-changes:43423] hsbt:r55497 (trunk): * ext/psych/*, test/psych/*: Upate psych 2.1.0

hsbt	2016-06-24 18:06:08 +0900 (Fri, 24 Jun 2016)

  New Revision: 55497

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

  Log:
    * ext/psych/*, test/psych/*: Upate psych 2.1.0
      This version fixed [Bug #11988][ruby-core:72850]

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/yaml_tree.rb
    trunk/ext/psych/lib/psych.rb
    trunk/ext/psych/psych.gemspec
    trunk/ext/psych/yaml/loader.c
    trunk/ext/psych/yaml/scanner.c
    trunk/test/psych/test_psych.rb
    trunk/test/psych/visitors/test_yaml_tree.rb
Index: ext/psych/yaml/scanner.c
===================================================================
--- ext/psych/yaml/scanner.c	(revision 55496)
+++ ext/psych/yaml/scanner.c	(revision 55497)
@@ -1251,7 +1251,7 @@ yaml_parser_roll_indent(yaml_parser_t *p https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L1251
 
 /*
  * Pop indentation levels from the indents stack until the current level
- * becomes less or equal to the column.  For each intendation level, append
+ * becomes less or equal to the column.  For each indentation level, append
  * the BLOCK-END token.
  */
 
@@ -1266,7 +1266,7 @@ yaml_parser_unroll_indent(yaml_parser_t https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L1266
     if (parser->flow_level)
         return 1;
 
-    /* Loop through the intendation levels in the stack. */
+    /* Loop through the indentation levels in the stack. */
 
     while (parser->indent > column)
     {
@@ -2775,15 +2775,15 @@ yaml_parser_scan_block_scalar(yaml_parse https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2775
 
         if (IS_DIGIT(parser->buffer))
         {
-            /* Check that the intendation is greater than 0. */
+            /* Check that the indentation is greater than 0. */
 
             if (CHECK(parser->buffer, '0')) {
                 yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
-                        start_mark, "found an intendation indicator equal to 0");
+                        start_mark, "found an indentation indicator equal to 0");
                 goto error;
             }
 
-            /* Get the intendation level and eat the indicator. */
+            /* Get the indentation level and eat the indicator. */
 
             increment = AS_DIGIT(parser->buffer);
 
@@ -2797,7 +2797,7 @@ yaml_parser_scan_block_scalar(yaml_parse https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2797
     {
         if (CHECK(parser->buffer, '0')) {
             yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
-                    start_mark, "found an intendation indicator equal to 0");
+                    start_mark, "found an indentation indicator equal to 0");
             goto error;
         }
 
@@ -2847,7 +2847,7 @@ yaml_parser_scan_block_scalar(yaml_parse https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2847
 
     end_mark = parser->mark;
 
-    /* Set the intendation level if it was specified. */
+    /* Set the indentation level if it was specified. */
 
     if (increment) {
         indent = parser->indent >= 0 ? parser->indent+increment : increment;
@@ -2913,7 +2913,7 @@ yaml_parser_scan_block_scalar(yaml_parse https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2913
 
         if (!READ_LINE(parser, leading_break)) goto error;
 
-        /* Eat the following intendation spaces and line breaks. */
+        /* Eat the following indentation spaces and line breaks. */
 
         if (!yaml_parser_scan_block_scalar_breaks(parser,
                     &indent, &trailing_breaks, start_mark, &end_mark)) goto error;
@@ -2948,8 +2948,8 @@ error: https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2948
 }
 
 /*
- * Scan intendation spaces and line breaks for a block scalar.  Determine the
- * intendation level if needed.
+ * Scan indentation spaces and line breaks for a block scalar.  Determine the
+ * indentation level if needed.
  */
 
 static int
@@ -2961,11 +2961,11 @@ yaml_parser_scan_block_scalar_breaks(yam https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2961
 
     *end_mark = parser->mark;
 
-    /* Eat the intendation spaces and line breaks. */
+    /* Eat the indentation spaces and line breaks. */
 
     while (1)
     {
-        /* Eat the intendation spaces. */
+        /* Eat the indentation spaces. */
 
         if (!CACHE(parser, 1)) return 0;
 
@@ -2978,12 +2978,12 @@ yaml_parser_scan_block_scalar_breaks(yam https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L2978
         if ((int)parser->mark.column > max_indent)
             max_indent = (int)parser->mark.column;
 
-        /* Check for a tab character messing the intendation. */
+        /* Check for a tab character messing the indentation. */
 
         if ((!*indent || (int)parser->mark.column < *indent)
                 && IS_TAB(parser->buffer)) {
             return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
-                    start_mark, "found a tab character where an intendation space is expected");
+                    start_mark, "found a tab character where an indentation space is expected");
         }
 
         /* Have we found a non-empty line? */
@@ -3504,12 +3504,12 @@ yaml_parser_scan_plain_scalar(yaml_parse https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L3504
         {
             if (IS_BLANK(parser->buffer))
             {
-                /* Check for tab character that abuse intendation. */
+                /* Check for tab character that abuse indentation. */
 
                 if (leading_blanks && (int)parser->mark.column < indent
                         && IS_TAB(parser->buffer)) {
                     yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
-                            start_mark, "found a tab character that violate intendation");
+                            start_mark, "found a tab character that violate indentation");
                     goto error;
                 }
 
@@ -3542,7 +3542,7 @@ yaml_parser_scan_plain_scalar(yaml_parse https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/scanner.c#L3542
             if (!CACHE(parser, 1)) goto error;
         }
 
-        /* Check intendation level. */
+        /* Check indentation level. */
 
         if (!parser->flow_level && (int)parser->mark.column < indent)
             break;
Index: ext/psych/yaml/loader.c
===================================================================
--- ext/psych/yaml/loader.c	(revision 55496)
+++ ext/psych/yaml/loader.c	(revision 55497)
@@ -239,8 +239,8 @@ yaml_parser_register_anchor(yaml_parser_ https://github.com/ruby/ruby/blob/trunk/ext/psych/yaml/loader.c#L239
         if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
             yaml_free(anchor);
             return yaml_parser_set_composer_error_context(parser,
-                    "found duplicate anchor; first occurence",
-                    alias_data->mark, "second occurence", data.mark);
+                    "found duplicate anchor; first occurrence",
+                    alias_data->mark, "second occurrence", data.mark);
         }
     }
 
Index: ext/psych/lib/psych.rb
===================================================================
--- ext/psych/lib/psych.rb	(revision 55496)
+++ ext/psych/lib/psych.rb	(revision 55497)
@@ -224,11 +224,13 @@ require 'psych/class_loader' https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L224
 
 module Psych
   # The version is Psych you're using
-  VERSION         = '2.0.17'
+  VERSION         = '2.1.0'
 
   # The version of libyaml Psych is using
   LIBYAML_VERSION = Psych.libyaml_version.join '.'
 
+  FALLBACK        = Struct.new :to_ruby # :nodoc:
+
   ###
   # Load +yaml+ in to a Ruby data structure.  If multiple documents are
   # provided, the object contained in the first document will be returned.
@@ -248,8 +250,8 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L250
   #     ex.file    # => 'file.txt'
   #     ex.message # => "(file.txt): found character that cannot start any token"
   #   end
-  def self.load yaml, filename = nil
-    result = parse(yaml, filename)
+  def self.load yaml, filename = nil, fallback = false
+    result = parse(yaml, filename, fallback)
     result ? result.to_ruby : result
   end
 
@@ -321,11 +323,11 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L323
   #   end
   #
   # See Psych::Nodes for more information about YAML AST.
-  def self.parse yaml, filename = nil
+  def self.parse yaml, filename = nil, fallback = false
     parse_stream(yaml, filename) do |node|
       return node
     end
-    false
+    fallback
   end
 
   ###
@@ -466,9 +468,12 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L468
 
   ###
   # Load the document contained in +filename+.  Returns the yaml contained in
-  # +filename+ as a Ruby object
-  def self.load_file filename
-    File.open(filename, 'r:bom|utf-8') { |f| self.load f, filename }
+  # +filename+ as a Ruby object, or if the file is empty, it returns
+  # the specified default return value, which defaults to an empty Hash 
+  def self.load_file filename, fallback = false
+    File.open(filename, 'r:bom|utf-8') { |f|
+      self.load f, filename, FALLBACK.new(fallback)
+    }
   end
 
   # :stopdoc:
Index: ext/psych/lib/psych/visitors/yaml_tree.rb
===================================================================
--- ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 55496)
+++ ext/psych/lib/psych/visitors/yaml_tree.rb	(revision 55497)
@@ -331,7 +331,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/yaml_tree.rb#L331
           style = Nodes::Scalar::FOLDED
         elsif o =~ /^[^[:word:]][^"]*$/
           style = Nodes::Scalar::DOUBLE_QUOTED
-        elsif not String === @ss.tokenize(o)
+        elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/ =~ o
           style = Nodes::Scalar::SINGLE_QUOTED
         end
 
Index: ext/psych/psych.gemspec
===================================================================
--- ext/psych/psych.gemspec	(revision 55496)
+++ ext/psych/psych.gemspec	(revision 55497)
@@ -1,25 +1,45 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L1
 # -*- encoding: utf-8 -*-
-# stub: psych 2.0.17 ruby lib
+# stub: psych 2.1.0 ruby lib
 # stub: ext/psych/extconf.rb
 
 Gem::Specification.new do |s|
   s.name = "psych"
-  s.version = "2.0.17"
+  s.version = "2.1.0"
 
   s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
   s.require_paths = ["lib"]
   s.authors = ["Aaron Patterson"]
-  s.date = "2015-12-07"
+  s.date = "2016-06-24"
   s.description = "Psych is a YAML parser and emitter.  Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]\nfor its YAML parsing and emitting capabilities.  In addition to wrapping\nlibyaml, Psych also knows how to serialize and de-serialize most Ruby objects\nto and from the YAML format."
   s.email = ["aaron@t..."]
   s.extensions = ["ext/psych/extconf.rb"]
-  s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
+  s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "CHANGELOG.rdoc", "README.rdoc"]
   s.files = [".autotest", ".travis.yml", "CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb
 ", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb", "lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "lib/psych_jars.rb", "test/psych/handlers/test_recorder.rb", "test/psych/helper.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb
 ", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "te
 st/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"]
   s.homepage = "http://github.com/tenderlove/psych"
   s.licenses = ["MIT"]
   s.rdoc_options = ["--main", "README.rdoc"]
   s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
-  s.rubygems_version = "2.5.0"
+  s.rubygems_version = "2.5.1"
   s.summary = "Psych is a YAML parser and emitter"
-  s.test_files = ["test/psych/handlers/test_recorder.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_marshalable.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/t
 est_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"]
+
+  if s.respond_to? :specification_version then
+    s.specification_version = 4
+
+    if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+      s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
+      s.add_development_dependency(%q<rake-compiler>, [">= 0.4.1"])
+      s.add_development_dependency(%q<minitest>, ["~> 5.0"])
+      s.add_development_dependency(%q<hoe>, ["~> 3.15"])
+    else
+      s.add_dependency(%q<rdoc>, ["~> 4.0"])
+      s.add_dependency(%q<rake-compiler>, [">= 0.4.1"])
+      s.add_dependency(%q<minitest>, ["~> 5.0"])
+      s.add_dependency(%q<hoe>, ["~> 3.15"])
+    end
+  else
+    s.add_dependency(%q<rdoc>, ["~> 4.0"])
+    s.add_dependency(%q<rake-compiler>, [">= 0.4.1"])
+    s.add_dependency(%q<minitest>, ["~> 5.0"])
+    s.add_dependency(%q<hoe>, ["~> 3.15"])
+  end
 end
Index: test/psych/visitors/test_yaml_tree.rb
===================================================================
--- test/psych/visitors/test_yaml_tree.rb	(revision 55496)
+++ test/psych/visitors/test_yaml_tree.rb	(revision 55497)
@@ -156,6 +156,12 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/visitors/test_yaml_tree.rb#L156
         assert_equal(-1, Psych.load(Psych.dump(-1 / 0.0)).infinite?)
       end
 
+      def test_string
+        assert_match(/'017'/, Psych.dump({'a' => '017'}))
+        assert_match(/'019'/, Psych.dump({'a' => '019'}))
+        assert_match(/'01818'/, Psych.dump({'a' => '01818'}))
+      end
+
       # http://yaml.org/type/null.html
       def test_nil
         assert_cycle nil
Index: test/psych/test_psych.rb
===================================================================
--- test/psych/test_psych.rb	(revision 55496)
+++ test/psych/test_psych.rb	(revision 55497)
@@ -144,6 +144,11 @@ class TestPsych < Psych::TestCase https://github.com/ruby/ruby/blob/trunk/test/psych/test_psych.rb#L144
     }
   end
 
+  def test_load_file_with_fallback
+    t = Tempfile.create(['empty', 'yml'])
+    assert_equal Hash.new, Psych.load_file(t.path, Hash.new)
+  end
+
   def test_parse_file
     Tempfile.create(['yikes', 'yml']) {|t|
       t.binmode
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55496)
+++ ChangeLog	(revision 55497)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun 24 17:04:21 2016  SHIBATA Hiroshi  <hsbt@r...>
+
+	* ext/psych/*, test/psych/*: Upate psych 2.1.0
+	  This version fixed [Bug #11988][ruby-core:72850]
+
 Fri Jun 24 13:12:41 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*:

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

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