ruby-changes:16872
From: nobu <ko1@a...>
Date: Thu, 5 Aug 2010 18:25:55 +0900 (JST)
Subject: [ruby-changes:16872] Ruby:r28868 (trunk): * marshal.c (w_float): should not append a dot if no fractal part
nobu 2010-08-05 18:25:39 +0900 (Thu, 05 Aug 2010) New Revision: 28868 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28868 Log: * marshal.c (w_float): should not append a dot if no fractal part exists. [ruby-dev:41936] Modified files: trunk/ChangeLog trunk/marshal.c trunk/test/ruby/test_marshal.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28867) +++ ChangeLog (revision 28868) @@ -1,3 +1,8 @@ +Thu Aug 5 18:25:33 2010 Nobuyoshi Nakada <nobu@r...> + + * marshal.c (w_float): should not append a dot if no fractal part + exists. [ruby-dev:41936] + Thu Aug 5 17:11:43 2010 Yukihiro Matsumoto <matz@r...> * parse.y (void_expr_gen): add 'possibly' to warning message. Index: marshal.c =================================================================== --- marshal.c (revision 28867) +++ marshal.c (revision 28868) @@ -376,8 +376,8 @@ digs = (int)(e - p); if (decpt < -3 || decpt > digs) { buf[len++] = p[0]; - buf[len++] = '.'; - memcpy(buf + len, p + 1, --digs); + if (--digs > 0) buf[len++] = '.'; + memcpy(buf + len, p + 1, digs); len += digs; len += snprintf(buf + len, sizeof(buf) - len, "e%d", decpt - 1); } Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 28867) +++ test/ruby/test_marshal.rb (revision 28868) @@ -40,6 +40,11 @@ obj = (x.to_f + y.to_f / z.to_f) * Math.exp(w.to_f / (x.to_f + y.to_f / z.to_f)) assert_equal obj, Marshal.load(Marshal.dump(obj)) } + + bug3659 = '[ruby-dev:41936]' + [1.0, 10.0, 100.0, 110.0].each {|x| + assert_equal(x, Marshal.load(Marshal.dump(x)), bug3659) + } end StrClone = String.clone -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/