[前][次][番号順一覧][スレッド一覧]

ruby-changes:42178

From: nobu <ko1@a...>
Date: Fri, 25 Mar 2016 00:13:00 +0900 (JST)
Subject: [ruby-changes:42178] nobu:r54252 (trunk): strftime.c: set buffer length

nobu	2016-03-25 00:12:56 +0900 (Fri, 25 Mar 2016)

  New Revision: 54252

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54252

  Log:
    strftime.c: set buffer length
    
    * strftime.c (FMTV): set the buffer length before appending to
      keep just put part.

  Modified files:
    trunk/strftime.c
    trunk/test/ruby/test_time.rb
Index: strftime.c
===================================================================
--- strftime.c	(revision 54251)
+++ strftime.c	(revision 54252)
@@ -326,6 +326,7 @@ rb_strftime_with_timespec(VALUE ftime, c https://github.com/ruby/ruby/blob/trunk/strftime.c#L326
 				const char *fmts = FMT_PADDING(fmt, def_pad); \
 				precision = FMT_PRECISION(def_prec); \
 				tmp = format_value(fmts, tmp, precision); \
+				rb_str_set_len(ftime, s-start); \
 				rb_str_append(ftime, tmp); \
 				RSTRING_GETMEM(ftime, s, len); \
 				endp = (start = s) + rb_str_capacity(ftime); \
Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 54251)
+++ test/ruby/test_time.rb	(revision 54252)
@@ -758,7 +758,7 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L758
     assert_equal("-0001", t.strftime("%G"))
 
     t = Time.utc(10000000000000000000000,1,1)
-    assert_equal("10000000000000000000000", t.strftime("%Y"))
+    assert_equal("<<10000000000000000000000>>", t.strftime("<<%Y>>"))
   end
 
   def test_strftime_weeknum

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]