summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-27 01:50:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-27 01:50:27 +0000
commit80429eed638c36baa3574704b1b567aa7acb4fa6 (patch)
tree387905f8803dc1cbf07736ac403351c38caeaeeb /time.c
parent2c3cc479a9b7d55e48d50d3c1712f28855faea12 (diff)
* io.c, process.c, time.c, ext: use rb_sys_fail_str instead of
rb_sys_fail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/time.c b/time.c
index d9e446b..5748c14 100644
--- a/time.c
+++ b/time.c
@@ -4290,7 +4290,7 @@ time_to_a(VALUE time)
#define SMALLBUF 100
static size_t
-rb_strftime_alloc(char **buf, const char *format, rb_encoding *enc,
+rb_strftime_alloc(char **buf, VALUE formatv, const char *format, rb_encoding *enc,
struct vtm *vtm, wideval_t timew, int gmt)
{
size_t size, len, flen;
@@ -4328,6 +4328,7 @@ rb_strftime_alloc(char **buf, const char *format, rb_encoding *enc,
if (len > 0) break;
xfree(*buf);
if (size >= 1024 * flen) {
+ if (!NIL_P(formatv)) rb_sys_fail_str(formatv);
rb_sys_fail(format);
break;
}
@@ -4345,7 +4346,7 @@ strftimev(const char *fmt, VALUE time, rb_encoding *enc)
GetTimeval(time, tobj);
MAKE_TM(time, tobj);
- len = rb_strftime_alloc(&buf, fmt, enc, &tobj->vtm, tobj->timew, TIME_UTC_P(tobj));
+ len = rb_strftime_alloc(&buf, Qnil, fmt, enc, &tobj->vtm, tobj->timew, TIME_UTC_P(tobj));
str = rb_enc_str_new(buf, len, enc);
if (buf != buffer) xfree(buf);
return str;
@@ -4563,7 +4564,8 @@ time_strftime(VALUE time, VALUE format)
str = rb_str_new(0, 0);
while (p < pe) {
- len = rb_strftime_alloc(&buf, p, enc, &tobj->vtm, tobj->timew, TIME_UTC_P(tobj));
+ len = rb_strftime_alloc(&buf, format, p, enc,
+ &tobj->vtm, tobj->timew, TIME_UTC_P(tobj));
rb_str_cat(str, buf, len);
p += strlen(p);
if (buf != buffer) {
@@ -4576,7 +4578,7 @@ time_strftime(VALUE time, VALUE format)
return str;
}
else {
- len = rb_strftime_alloc(&buf, RSTRING_PTR(format), enc,
+ len = rb_strftime_alloc(&buf, format, RSTRING_PTR(format), enc,
&tobj->vtm, tobj->timew, TIME_UTC_P(tobj));
}
str = rb_enc_str_new(buf, len, enc);