From 1efa5d37a11b18f5822a8dc0222ca5de2ad7aa0c Mon Sep 17 00:00:00 2001 From: shyouhei Date: Sun, 15 Jun 2008 13:17:08 +0000 Subject: merge revision(s) 16114: * time.c (rb_strftime): check errno to detect strftime(3)'s error. this is workaround for recent version of MSVCRT. [ruby-dev:34456] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'time.c') diff --git a/time.c b/time.c index 00061f78ff..97eeb6a365 100644 --- a/time.c +++ b/time.c @@ -18,6 +18,7 @@ #include #endif +#include #include VALUE rb_cTime; @@ -1776,8 +1777,9 @@ rb_strftime(buf, format, time) if (flen == 0) { return 0; } + errno = 0; len = strftime(*buf, SMALLBUF, format, time); - if (len != 0 || **buf == '\0') return len; + if (len != 0 || (**buf == '\0' && errno != ERANGE)) return len; for (size=1024; ; size*=2) { *buf = xmalloc(size); (*buf)[0] = '\0'; -- cgit v1.2.3