1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

strftime.c: set buffer length

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-03-24 15:12:56 +00:00
parent f4f7d49705
commit 2460214780
2 changed files with 2 additions and 1 deletions

View file

@ -326,6 +326,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
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); \

View file

@ -758,7 +758,7 @@ class TestTime < Test::Unit::TestCase
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