ruby-changes:39660
From: hsbt <ko1@a...>
Date: Wed, 2 Sep 2015 18:50:28 +0900 (JST)
Subject: [ruby-changes:39660] hsbt:r51741 (trunk): * ext/psych/*: merge psych master(8737e5b). It contains following fixes.
hsbt 2015-09-02 18:50:00 +0900 (Wed, 02 Sep 2015) New Revision: 51741 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51741 Log: * ext/psych/*: merge psych master(8737e5b). It contains following fixes. https://github.com/tenderlove/psych/pull/242 https://github.com/tenderlove/psych/pull/246 [ruby-list:50219] * test/psych/*: ditto. Modified files: trunk/ChangeLog trunk/ext/psych/lib/psych/visitors/yaml_tree.rb trunk/ext/psych/lib/psych.rb trunk/ext/psych/psych_emitter.c trunk/test/psych/test_encoding.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 51740) +++ ChangeLog (revision 51741) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 2 18:49:55 2015 SHIBATA Hiroshi <hsbt@r...> + + * ext/psych/*: merge psych master(8737e5b). It contains following fixes. + https://github.com/tenderlove/psych/pull/242 + https://github.com/tenderlove/psych/pull/246 [ruby-list:50219] + * test/psych/*: ditto. + Wed Sep 2 18:04:13 2015 Koichi Sasada <ko1@a...> * vm_insnhelper.h (GET_PC_COUNT): remove unused macro. Index: ext/psych/psych_emitter.c =================================================================== --- ext/psych/psych_emitter.c (revision 51740) +++ ext/psych/psych_emitter.c (revision 51741) @@ -15,7 +15,11 @@ static void emit(yaml_emitter_t * emitte https://github.com/ruby/ruby/blob/trunk/ext/psych/psych_emitter.c#L15 static int writer(void *ctx, unsigned char *buffer, size_t size) { VALUE io = (VALUE)ctx; +#ifdef HAVE_RUBY_ENCODING_H + 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); } Index: ext/psych/lib/psych/visitors/yaml_tree.rb =================================================================== --- ext/psych/lib/psych/visitors/yaml_tree.rb (revision 51740) +++ ext/psych/lib/psych/visitors/yaml_tree.rb (revision 51741) @@ -156,7 +156,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/visitors/yaml_tree.rb#L156 end def visit_Psych_Omap o - seq = @emitter.start_sequence(nil, '!omap', false, Nodes::Sequence::BLOCK) + seq = @emitter.start_sequence(nil, 'tag:yaml.org,2002:omap', false, Nodes::Sequence::BLOCK) register(o, seq) o.each { |k,v| visit_Hash k => v } Index: ext/psych/lib/psych.rb =================================================================== --- ext/psych/lib/psych.rb (revision 51740) +++ ext/psych/lib/psych.rb (revision 51741) @@ -223,7 +223,7 @@ require 'psych/class_loader' https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych.rb#L223 module Psych # The version is Psych you're using - VERSION = '2.0.14' + VERSION = '2.0.15' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' Index: test/psych/test_encoding.rb =================================================================== --- test/psych/test_encoding.rb (revision 51740) +++ test/psych/test_encoding.rb (revision 51741) @@ -249,6 +249,15 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_encoding.rb#L249 assert_encodings @utf8, @handler.strings end + def test_dump_non_ascii_string_to_file + Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t| + h = {'one' => ''} + Psych.dump(h, t) + t.close + assert_equal h, Psych.load_file(t.path) + end + end + private def assert_encodings encoding, strings strings.each do |str| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/