summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-24 09:06:08 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-24 09:06:08 +0000
commita099c5420c371d941953358896de861030fda421 (patch)
tree5e3555134a652cf8c927afcaaba299fd94d44531
parent656c458665324a674e703cc65927696ad3210820 (diff)
* ext/psych/*, test/psych/*: Upate psych 2.1.0
This version fixed [Bug #11988][ruby-core:72850] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/psych/lib/psych.rb21
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb2
-rw-r--r--ext/psych/psych.gemspec32
-rw-r--r--ext/psych/yaml/loader.c4
-rw-r--r--ext/psych/yaml/scanner.c34
-rw-r--r--test/psych/test_psych.rb5
-rw-r--r--test/psych/visitors/test_yaml_tree.rb6
8 files changed, 75 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index fac4fad4e75..0bb102a0f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jun 24 17:04:21 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*:
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index f442e544ce3..15371cde586 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -224,11 +224,13 @@ require 'psych/class_loader'
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
# 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
# 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
###
# 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:
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 7c400504fa8..11214ecbf4c 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -331,7 +331,7 @@ module Psych
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
diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec
index 70ac510f559..11e22d7a187 100644
--- a/ext/psych/psych.gemspec
+++ b/ext/psych/psych.gemspec
@@ -1,25 +1,45 @@
# -*- 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@tenderlovemaking.com"]
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", "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"]
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/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", "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
diff --git a/ext/psych/yaml/loader.c b/ext/psych/yaml/loader.c
index cb3ea930891..def67933e7b 100644
--- a/ext/psych/yaml/loader.c
+++ b/ext/psych/yaml/loader.c
@@ -239,8 +239,8 @@ yaml_parser_register_anchor(yaml_parser_t *parser,
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);
}
}
diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c
index c8627e278ed..5e4875d7f9f 100644
--- a/ext/psych/yaml/scanner.c
+++ b/ext/psych/yaml/scanner.c
@@ -1251,7 +1251,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
/*
* 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 *parser, ptrdiff_t column)
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_parser_t *parser, yaml_token_t *token,
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_parser_t *parser, yaml_token_t *token,
{
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_parser_t *parser, yaml_token_t *token,
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_parser_t *parser, yaml_token_t *token,
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:
}
/*
- * 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(yaml_parser_t *parser,
*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(yaml_parser_t *parser,
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_parser_t *parser, yaml_token_t *token)
{
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_parser_t *parser, yaml_token_t *token)
if (!CACHE(parser, 1)) goto error;
}
- /* Check intendation level. */
+ /* Check indentation level. */
if (!parser->flow_level && (int)parser->mark.column < indent)
break;
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 7de9e07fdcf..508519b012a 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -144,6 +144,11 @@ class TestPsych < Psych::TestCase
}
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
diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index b3890bcd724..5755f5863e2 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -156,6 +156,12 @@ module Psych
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