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

ruby-changes:60684

From: Nobuyoshi <ko1@a...>
Date: Wed, 8 Apr 2020 01:21:22 +0900 (JST)
Subject: [ruby-changes:60684] 2f1895fa15 (master): Fixed formatted substring expansion [Bug #16767]

https://git.ruby-lang.org/ruby.git/commit/?id=2f1895fa15

From 2f1895fa15386fb3cdc91c5604171290828b9da8 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 8 Apr 2020 01:13:03 +0900
Subject: Fixed formatted substring expansion [Bug #16767]


diff --git a/strftime.c b/strftime.c
index 911bcda..15e29e0 100644
--- a/strftime.c
+++ b/strftime.c
@@ -331,7 +331,9 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len, https://github.com/ruby/ruby/blob/trunk/strftime.c#L331
 			s += len; \
 			if (i > 0) case_conv(s, i, flags); \
 			if (precision > i) {\
+				s += i; \
 				NEEDS(precision); \
+				s -= i; \
 				memmove(s + precision - i, s, i);\
 				memset(s, padding ? padding : ' ', precision - i); \
 				s += precision;	\
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 785376f..247bc34 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -893,6 +893,13 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L893
     assert_equal(8192, Time.now.strftime('%8192z').size)
   end
 
+  def test_strftime_wide_precision
+    t2000 = get_t2000
+    s = t2000.strftime("%28c")
+    assert_equal(28, s.size)
+    assert_equal(t2000.strftime("%c"), s.strip)
+  end
+
   def test_strfimte_zoneoffset
     t2000 = get_t2000
     t = t2000.getlocal("+09:00:00")
-- 
cgit v0.10.2


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

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