ruby-changes:44871
From: hsbt <ko1@a...>
Date: Wed, 30 Nov 2016 22:55:08 +0900 (JST)
Subject: [ruby-changes:44871] hsbt:r56944 (trunk): Update psych-2.2.1
hsbt 2016-11-30 22:55:02 +0900 (Wed, 30 Nov 2016) New Revision: 56944 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56944 Log: 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. Modified files: trunk/ext/psych/lib/psych/versions.rb trunk/ext/psych/lib/psych.rb trunk/ext/psych/psych.gemspec trunk/ext/psych/psych.h trunk/ext/psych/psych_emitter.c trunk/ext/psych/psych_parser.c trunk/ext/psych/psych_to_ruby.c Index: ext/psych/psych_emitter.c =================================================================== --- ext/psych/psych_emitter.c (revision 56943) +++ ext/psych/psych_emitter.c (revision 56944) @@ -8,6 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L8 #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 * emitte https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L22 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L91 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, https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L166 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, https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L189 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( https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L251 ) { 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( https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L269 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( https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L303 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( https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L314 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( https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L365 ) { 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( https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L380 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 anc https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L425 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) https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L545 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"); Index: ext/psych/lib/psych/versions.rb =================================================================== --- ext/psych/lib/psych/versions.rb (revision 56943) +++ ext/psych/lib/psych/versions.rb (revision 56944) @@ -1,4 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/versions.rb#L1 # 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 Index: ext/psych/lib/psych.rb =================================================================== --- ext/psych/lib/psych.rb (revision 56943) +++ ext/psych/lib/psych.rb (revision 56944) @@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L1 # frozen_string_literal: false +require 'psych/versions' case RUBY_ENGINE when 'jruby' require 'psych_jars' @@ -223,9 +224,6 @@ require 'psych/class_loader' https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L224 # # => "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 '.' Index: ext/psych/psych.gemspec =================================================================== --- ext/psych/psych.gemspec (revision 56943) +++ ext/psych/psych.gemspec (revision 56944) @@ -1,10 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L1 # -*- 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@t...", "hsbt@r..."] + s.version = Psych::VERSION + s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"] + s.email = ["aaron@t...", "hsbt@r...", "headius@h..."] s.date = "2016-11-14" s.summary = "Psych is a YAML parser and emitter" s.description = <<-DESCRIPTION @@ -17,7 +19,7 @@ DESCRIPTION https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L19 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/ha ndlers/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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.gemspec#L31 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' Index: ext/psych/psych_to_ruby.c =================================================================== --- ext/psych/psych_to_ruby.c (revision 56943) +++ ext/psych/psych_to_ruby.c (revision 56944) @@ -21,11 +21,7 @@ static VALUE build_exception(VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_to_ruby.c#L21 */ 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) Index: ext/psych/psych.h =================================================================== --- ext/psych/psych.h (revision 56943) +++ ext/psych/psych.h (revision 56944) @@ -2,10 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych.h#L2 #define PSYCH_H #include <ruby.h> - -#ifdef HAVE_RUBY_ENCODING_H #include <ruby/encoding.h> -#endif #include <yaml.h> Index: ext/psych/psych_parser.c =================================================================== --- ext/psych/psych_parser.c (revision 56943) +++ ext/psych/psych_parser.c (revision 56944) @@ -93,7 +93,6 @@ static VALUE make_exception(yaml_parser_ https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L93 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L170 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L250 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L269 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L329 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L364 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L384 ); 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L425 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 https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_parser.c#L461 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 = -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/