1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Update psych-2.2.1

It fixed segmentation fault related with GC.
  https://github.com/ruby/psych/pull/296

  and removed deprecated code of Ruby 1.8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2016-11-30 13:55:02 +00:00
parent 5e4b845522
commit 48e251df47
7 changed files with 21 additions and 68 deletions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: false
require 'psych/versions'
case RUBY_ENGINE
when 'jruby'
require 'psych_jars'
@ -223,9 +224,6 @@ require 'psych/class_loader'
# # => "a"
module Psych
# The version is Psych you're using
VERSION = '2.1.1'
# The version of libyaml Psych is using
LIBYAML_VERSION = Psych.libyaml_version.join '.'

View file

@ -1,4 +1,9 @@
# frozen_string_literal: false
module Psych
DEFAULT_SNAKEYAML_VERSION = '1.14'.freeze
# The version is Psych you're using
VERSION = '2.2.1'
if RUBY_ENGINE == 'jruby'
DEFAULT_SNAKEYAML_VERSION = '1.17'.freeze
end
end

View file

@ -1,10 +1,12 @@
# -*- encoding: utf-8 -*-
$LOAD_PATH.unshift './lib'
load 'psych/versions.rb'
Gem::Specification.new do |s|
s.name = "psych"
s.version = "2.2.0"
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org"]
s.version = Psych::VERSION
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
s.date = "2016-11-14"
s.summary = "Psych is a YAML parser and emitter"
s.description = <<-DESCRIPTION
@ -17,7 +19,7 @@ DESCRIPTION
s.require_paths = ["lib"]
# for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
s.files = [".gitignore", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "Mavenfile", "README.md", "Rakefile", "bin/console", "bin/setup", "ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java", "ext/java/PsychYamlTree.java", "ext/psych/.gitignore", "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", "psych.gemspec"]
s.files = [".gitignore", ".travis.yml", "CHANGELOG.rdoc", "Gemfile", "Mavenfile", "README.md", "Rakefile", "bin/console", "bin/setup", "ext/psych/.gitignore", "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", "psych.gemspec"]
s.rdoc_options = ["--main", "README.md"]
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.md"]
@ -29,9 +31,9 @@ DESCRIPTION
s.add_development_dependency 'rake-compiler', ">= 0.4.1"
s.add_development_dependency 'minitest', "~> 5.0"
if RUBY_PLATFORM =~ /java/
require 'psych/versions'
if RUBY_ENGINE == 'jruby'
s.platform = 'java'
s.files.concat ["ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java", "ext/java/PsychYamlTree.java", "lib/psych_jars.rb", "lib/psych.jar"]
s.requirements = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
s.add_dependency 'jar-dependencies', '>= 0.1.7'
s.add_development_dependency 'ruby-maven'

View file

@ -2,10 +2,7 @@
#define PSYCH_H
#include <ruby.h>
#ifdef HAVE_RUBY_ENCODING_H
#include <ruby/encoding.h>
#endif
#include <yaml.h>

View file

@ -8,6 +8,7 @@
#endif
VALUE cPsychEmitter;
static ID id_io;
static ID id_write;
static ID id_line_width;
static ID id_indentation;
@ -21,12 +22,8 @@ static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
static int writer(void *ctx, unsigned char *buffer, size_t size)
{
VALUE io = (VALUE)ctx;
#ifdef HAVE_RUBY_ENCODING_H
VALUE self = (VALUE)ctx, io = rb_attr_get(self, id_io);
VALUE str = rb_enc_str_new((const char *)buffer, (long)size, rb_utf8_encoding());
#else
VALUE str = rb_str_new((const char *)buffer, (long)size);
#endif
VALUE wrote = rb_funcall(io, id_write, 1, str);
return (int)NUM2INT(wrote);
}
@ -94,7 +91,8 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
}
yaml_emitter_set_output(emitter, writer, (void *)io);
rb_ivar_set(self, id_io, io);
yaml_emitter_set_output(emitter, writer, (void *)self);
return self;
}
@ -168,9 +166,7 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
if(RTEST(tags)) {
long i = 0;
long len;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding * encoding = rb_utf8_encoding();
#endif
Check_Type(tags, T_ARRAY);
@ -193,10 +189,8 @@ static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
value = RARRAY_AREF(tuple, 1);
StringValue(name);
StringValue(value);
#ifdef HAVE_RUBY_ENCODING_H
name = rb_str_export_to_enc(name, encoding);
value = rb_str_export_to_enc(value, encoding);
#endif
tail->handle = (yaml_char_t *)RSTRING_PTR(name);
tail->prefix = (yaml_char_t *)RSTRING_PTR(value);
@ -257,14 +251,11 @@ static VALUE scalar(
) {
yaml_emitter_t * emitter;
yaml_event_t event;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding *encoding;
#endif
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
Check_Type(value, T_STRING);
#ifdef HAVE_RUBY_ENCODING_H
encoding = rb_utf8_encoding();
value = rb_str_export_to_enc(value, encoding);
@ -278,7 +269,6 @@ static VALUE scalar(
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}
#endif
yaml_scalar_event_initialize(
&event,
@ -313,7 +303,6 @@ static VALUE start_sequence(
yaml_emitter_t * emitter;
yaml_event_t event;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding * encoding = rb_utf8_encoding();
if(!NIL_P(anchor)) {
@ -325,7 +314,6 @@ static VALUE start_sequence(
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}
#endif
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
@ -377,12 +365,10 @@ static VALUE start_mapping(
) {
yaml_emitter_t * emitter;
yaml_event_t event;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding *encoding;
#endif
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
#ifdef HAVE_RUBY_ENCODING_H
encoding = rb_utf8_encoding();
if(!NIL_P(anchor)) {
@ -394,7 +380,6 @@ static VALUE start_mapping(
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}
#endif
yaml_mapping_start_event_initialize(
&event,
@ -440,12 +425,10 @@ static VALUE alias(VALUE self, VALUE anchor)
yaml_event_t event;
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
#ifdef HAVE_RUBY_ENCODING_H
if(!NIL_P(anchor)) {
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
}
#endif
yaml_alias_event_initialize(
&event,
@ -562,6 +545,7 @@ void Init_psych_emitter(void)
rb_define_method(cPsychEmitter, "line_width", line_width, 0);
rb_define_method(cPsychEmitter, "line_width=", set_line_width, 1);
id_io = rb_intern("io");
id_write = rb_intern("write");
id_line_width = rb_intern("line_width");
id_indentation = rb_intern("indentation");

View file

@ -93,7 +93,6 @@ static VALUE make_exception(yaml_parser_t * parser, VALUE path)
parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
}
#ifdef HAVE_RUBY_ENCODING_H
static VALUE transcode_string(VALUE src, int * parser_encoding)
{
int utf8 = rb_utf8_encindex();
@ -171,8 +170,6 @@ static VALUE transcode_io(VALUE src, int * parser_encoding)
return src;
}
#endif
static VALUE protected_start_stream(VALUE pointer)
{
VALUE *args = (VALUE *)pointer;
@ -253,10 +250,8 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
int tainted = 0;
int state = 0;
int parser_encoding = YAML_ANY_ENCODING;
#ifdef HAVE_RUBY_ENCODING_H
int encoding = rb_utf8_encindex();
rb_encoding * internal_enc = rb_default_internal_encoding();
#endif
VALUE handler = rb_iv_get(self, "@handler");
if (rb_scan_args(argc, argv, "11", &yaml, &path) == 1) {
@ -274,18 +269,14 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
if (OBJ_TAINTED(yaml)) tainted = 1;
if (rb_respond_to(yaml, id_read)) {
#ifdef HAVE_RUBY_ENCODING_H
yaml = transcode_io(yaml, &parser_encoding);
yaml_parser_set_encoding(parser, parser_encoding);
#endif
yaml_parser_set_input(parser, io_reader, (void *)yaml);
if (RTEST(rb_obj_is_kind_of(yaml, rb_cIO))) tainted = 1;
} else {
StringValue(yaml);
#ifdef HAVE_RUBY_ENCODING_H
yaml = transcode_string(yaml, &parser_encoding);
yaml_parser_set_encoding(parser, parser_encoding);
#endif
yaml_parser_set_input_string(
parser,
(const unsigned char *)RSTRING_PTR(yaml),
@ -338,17 +329,13 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
if(start->handle) {
handle = rb_str_new2((const char *)start->handle);
if (tainted) OBJ_TAINT(handle);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(handle, encoding, internal_enc);
#endif
}
if(start->prefix) {
prefix = rb_str_new2((const char *)start->prefix);
if (tainted) OBJ_TAINT(prefix);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(prefix, encoding, internal_enc);
#endif
}
rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix));
@ -377,9 +364,7 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
if(event.data.alias.anchor) {
alias = rb_str_new2((const char *)event.data.alias.anchor);
if (tainted) OBJ_TAINT(alias);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(alias, encoding, internal_enc);
#endif
}
args[0] = handler;
@ -399,24 +384,18 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
);
if (tainted) OBJ_TAINT(val);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(val, encoding, internal_enc);
#endif
if(event.data.scalar.anchor) {
anchor = rb_str_new2((const char *)event.data.scalar.anchor);
if (tainted) OBJ_TAINT(anchor);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(anchor, encoding, internal_enc);
#endif
}
if(event.data.scalar.tag) {
tag = rb_str_new2((const char *)event.data.scalar.tag);
if (tainted) OBJ_TAINT(tag);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(tag, encoding, internal_enc);
#endif
}
plain_implicit =
@ -446,18 +425,14 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
if(event.data.sequence_start.anchor) {
anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
if (tainted) OBJ_TAINT(anchor);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(anchor, encoding, internal_enc);
#endif
}
tag = Qnil;
if(event.data.sequence_start.tag) {
tag = rb_str_new2((const char *)event.data.sequence_start.tag);
if (tainted) OBJ_TAINT(tag);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(tag, encoding, internal_enc);
#endif
}
implicit =
@ -486,17 +461,13 @@ static VALUE parse(int argc, VALUE *argv, VALUE self)
if(event.data.mapping_start.anchor) {
anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
if (tainted) OBJ_TAINT(anchor);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(anchor, encoding, internal_enc);
#endif
}
if(event.data.mapping_start.tag) {
tag = rb_str_new2((const char *)event.data.mapping_start.tag);
if (tainted) OBJ_TAINT(tag);
#ifdef HAVE_RUBY_ENCODING_H
PSYCH_TRANSCODE(tag, encoding, internal_enc);
#endif
}
implicit =

View file

@ -21,11 +21,7 @@ static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
*/
static VALUE path2class(VALUE self, VALUE path)
{
#ifdef HAVE_RUBY_ENCODING_H
return rb_path_to_class(path);
#else
return rb_path2class(StringValuePtr(path));
#endif
}
void Init_psych_to_ruby(void)