Skip to content

Commit

Permalink
* ext/date/date_core.c: reverted r34825.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
tadf committed Feb 28, 2012
1 parent f3b685d commit f400ba1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
Wed Feb 29 06:14:51 2012 Tadayoshi Funaba <tadf@dotrb.org>

* ext/date/date_core.c: reverted r34825.

Tue Feb 28 23:20:01 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> Tue Feb 28 23:20:01 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com>


* Makefile.in (PLATFORM_DIR): add a variable for `win32` directory. * Makefile.in (PLATFORM_DIR): add a variable for `win32` directory.
Expand Down
35 changes: 17 additions & 18 deletions ext/date/date_core.c
Expand Up @@ -6587,7 +6587,7 @@ d_lite_hash(VALUE self)


#include "date_tmx.h" #include "date_tmx.h"
static void set_tmx(VALUE, struct tmx *); static void set_tmx(VALUE, struct tmx *);
static VALUE strftimev(VALUE, const char *, VALUE, static VALUE strftimev(const char *, VALUE,
void (*)(VALUE, struct tmx *)); void (*)(VALUE, struct tmx *));


/* /*
Expand All @@ -6604,7 +6604,7 @@ static VALUE strftimev(VALUE, const char *, VALUE,
static VALUE static VALUE
d_lite_to_s(VALUE self) d_lite_to_s(VALUE self)
{ {
return strftimev(Qnil, "%Y-%m-%d", self, set_tmx); return strftimev("%Y-%m-%d", self, set_tmx);
} }


#ifndef NDEBUG #ifndef NDEBUG
Expand Down Expand Up @@ -6729,7 +6729,7 @@ size_t date_strftime(char *s, size_t maxsize, const char *format,


#define SMALLBUF 100 #define SMALLBUF 100
static size_t static size_t
date_strftime_alloc(char **buf, VALUE formatv, const char *format, date_strftime_alloc(char **buf, const char *format,
struct tmx *tmx) struct tmx *tmx)
{ {
size_t size, len, flen; size_t size, len, flen;
Expand All @@ -6756,7 +6756,6 @@ date_strftime_alloc(char **buf, VALUE formatv, const char *format,
if (len > 0) break; if (len > 0) break;
xfree(*buf); xfree(*buf);
if (size >= 1024 * flen) { if (size >= 1024 * flen) {
if (!NIL_P(formatv)) rb_sys_fail_str(formatv);
rb_sys_fail(format); rb_sys_fail(format);
break; break;
} }
Expand Down Expand Up @@ -6869,7 +6868,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,


str = rb_str_new(0, 0); str = rb_str_new(0, 0);
while (p < pe) { while (p < pe) {
len = date_strftime_alloc(&buf, vfmt, p, &tmx); len = date_strftime_alloc(&buf, p, &tmx);
rb_str_cat(str, buf, len); rb_str_cat(str, buf, len);
p += strlen(p); p += strlen(p);
if (buf != buffer) { if (buf != buffer) {
Expand All @@ -6884,7 +6883,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
return str; return str;
} }
else else
len = date_strftime_alloc(&buf, vfmt, fmt, &tmx); len = date_strftime_alloc(&buf, fmt, &tmx);


str = rb_str_new(buf, len); str = rb_str_new(buf, len);
if (buf != buffer) xfree(buf); if (buf != buffer) xfree(buf);
Expand Down Expand Up @@ -7078,7 +7077,7 @@ d_lite_strftime(int argc, VALUE *argv, VALUE self)
} }


static VALUE static VALUE
strftimev(VALUE vfmt, const char *fmt, VALUE self, strftimev(const char *fmt, VALUE self,
void (*func)(VALUE, struct tmx *)) void (*func)(VALUE, struct tmx *))
{ {
char buffer[SMALLBUF], *buf = buffer; char buffer[SMALLBUF], *buf = buffer;
Expand All @@ -7087,7 +7086,7 @@ strftimev(VALUE vfmt, const char *fmt, VALUE self,
VALUE str; VALUE str;


(*func)(self, &tmx); (*func)(self, &tmx);
len = date_strftime_alloc(&buf, vfmt, fmt, &tmx); len = date_strftime_alloc(&buf, fmt, &tmx);
str = rb_usascii_str_new(buf, len); str = rb_usascii_str_new(buf, len);
if (buf != buffer) xfree(buf); if (buf != buffer) xfree(buf);
return str; return str;
Expand All @@ -7106,7 +7105,7 @@ strftimev(VALUE vfmt, const char *fmt, VALUE self,
static VALUE static VALUE
d_lite_asctime(VALUE self) d_lite_asctime(VALUE self)
{ {
return strftimev(Qnil, "%a %b %e %H:%M:%S %Y", self, set_tmx); return strftimev("%a %b %e %H:%M:%S %Y", self, set_tmx);
} }


/* /*
Expand All @@ -7119,7 +7118,7 @@ d_lite_asctime(VALUE self)
static VALUE static VALUE
d_lite_iso8601(VALUE self) d_lite_iso8601(VALUE self)
{ {
return strftimev(Qnil, "%Y-%m-%d", self, set_tmx); return strftimev("%Y-%m-%d", self, set_tmx);
} }


/* /*
Expand All @@ -7131,7 +7130,7 @@ d_lite_iso8601(VALUE self)
static VALUE static VALUE
d_lite_rfc3339(VALUE self) d_lite_rfc3339(VALUE self)
{ {
return strftimev(Qnil, "%Y-%m-%dT%H:%M:%S%:z", self, set_tmx); return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx);
} }


/* /*
Expand All @@ -7144,7 +7143,7 @@ d_lite_rfc3339(VALUE self)
static VALUE static VALUE
d_lite_rfc2822(VALUE self) d_lite_rfc2822(VALUE self)
{ {
return strftimev(Qnil, "%a, %-d %b %Y %T %z", self, set_tmx); return strftimev("%a, %-d %b %Y %T %z", self, set_tmx);
} }


/* /*
Expand All @@ -7158,7 +7157,7 @@ static VALUE
d_lite_httpdate(VALUE self) d_lite_httpdate(VALUE self)
{ {
volatile VALUE dup = dup_obj_with_new_offset(self, 0); volatile VALUE dup = dup_obj_with_new_offset(self, 0);
return strftimev(Qnil, "%a, %d %b %Y %T GMT", dup, set_tmx); return strftimev("%a, %d %b %Y %T GMT", dup, set_tmx);
} }


static VALUE static VALUE
Expand Down Expand Up @@ -7205,7 +7204,7 @@ d_lite_jisx0301(VALUE self)
get_d1(self); get_d1(self);
s = jisx0301_date(m_real_local_jd(dat), s = jisx0301_date(m_real_local_jd(dat),
m_real_year(dat)); m_real_year(dat));
return strftimev(s, RSTRING_PTR(s), self, set_tmx); return strftimev(RSTRING_PTR(s), self, set_tmx);
} }


#ifndef NDEBUG #ifndef NDEBUG
Expand Down Expand Up @@ -8295,7 +8294,7 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
static VALUE static VALUE
dt_lite_to_s(VALUE self) dt_lite_to_s(VALUE self)
{ {
return strftimev(Qnil, "%Y-%m-%dT%H:%M:%S%:z", self, set_tmx); return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx);
} }


/* /*
Expand Down Expand Up @@ -8502,7 +8501,7 @@ iso8601_timediv(VALUE self, VALUE n)
rb_str_append(fmt, rb_f_sprintf(3, argv)); rb_str_append(fmt, rb_f_sprintf(3, argv));
} }
rb_str_append(fmt, rb_usascii_str_new2("%:z")); rb_str_append(fmt, rb_usascii_str_new2("%:z"));
return strftimev(fmt, RSTRING_PTR(fmt), self, set_tmx); return strftimev(RSTRING_PTR(fmt), self, set_tmx);
} }


/* /*
Expand All @@ -8528,7 +8527,7 @@ dt_lite_iso8601(int argc, VALUE *argv, VALUE self)
if (argc < 1) if (argc < 1)
n = INT2FIX(0); n = INT2FIX(0);


return f_add(strftimev(Qnil, "%Y-%m-%d", self, set_tmx), return f_add(strftimev("%Y-%m-%d", self, set_tmx),
iso8601_timediv(self, n)); iso8601_timediv(self, n));
} }


Expand Down Expand Up @@ -8576,7 +8575,7 @@ dt_lite_jisx0301(int argc, VALUE *argv, VALUE self)
get_d1(self); get_d1(self);
s = jisx0301_date(m_real_local_jd(dat), s = jisx0301_date(m_real_local_jd(dat),
m_real_year(dat)); m_real_year(dat));
return rb_str_append(strftimev(s, RSTRING_PTR(s), self, set_tmx), return rb_str_append(strftimev(RSTRING_PTR(s), self, set_tmx),
iso8601_timediv(self, n)); iso8601_timediv(self, n));
} }
} }
Expand Down

0 comments on commit f400ba1

Please sign in to comment.