ruby-changes:34910
From: nobu <ko1@a...>
Date: Tue, 29 Jul 2014 12:28:53 +0900 (JST)
Subject: [ruby-changes:34910] nobu:r46993 (trunk): marshal.c: fix symlink index
nobu 2014-07-29 12:28:43 +0900 (Tue, 29 Jul 2014) New Revision: 46993 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46993 Log: marshal.c: fix symlink index * marshal.c (w_symbol): fix symlink index. register the given symbols, not its name. Modified files: trunk/marshal.c trunk/test/ruby/test_marshal.rb Index: marshal.c =================================================================== --- marshal.c (revision 46992) +++ marshal.c (revision 46993) @@ -422,6 +422,7 @@ w_symbol(VALUE sym, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/marshal.c#L422 w_long((long)num, arg); } else { + const VALUE orig_sym = sym; sym = rb_sym2str(sym); if (!sym) { rb_raise(rb_eTypeError, "can't dump anonymous ID %"PRIdVALUE, sym); @@ -436,7 +437,7 @@ w_symbol(VALUE sym, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/marshal.c#L437 } w_byte(TYPE_SYMBOL, arg); w_bytes(RSTRING_PTR(sym), RSTRING_LEN(sym), arg); - st_add_direct(arg->symbols, sym, arg->symbols->num_entries); + st_add_direct(arg->symbols, orig_sym, arg->symbols->num_entries); if (!NIL_P(encname)) { struct dump_call_arg c_arg; c_arg.limit = 1; Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 46992) +++ test/ruby/test_marshal.rb (revision 46993) @@ -248,6 +248,10 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L248 assert_equal(ary, Marshal.load(Marshal.dump(ary)), bug2548) end + def test_symlink + assert_include(Marshal.dump([:a, :a]), ';') + end + ClassUTF8 = eval("class R\u{e9}sum\u{e9}; self; end") iso_8859_1 = Encoding::ISO_8859_1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/