From e48047fe0cedc0fa859f7940ab504c34dc4ea6d5 Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 20 Mar 2011 13:34:44 +0000 Subject: * ext/date/date_strftime.c: removed unused code and arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/date/date_strftime.c | 53 ++++++++---------------------------------------- 2 files changed, 12 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index b82fc9dd96..fb1fd49ce5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Mar 20 22:32:30 2011 Tadayoshi Funaba + + * ext/date/date_strftime.c: removed unused code and arguments. + Sun Mar 20 21:34:49 2011 Tadayoshi Funaba * ext/date/date_core.c: replacement of implementation of diff --git a/ext/date/date_strftime.c b/ext/date/date_strftime.c index 4a8bc21bde..06ca9b0aff 100644 --- a/ext/date/date_strftime.c +++ b/ext/date/date_strftime.c @@ -168,7 +168,8 @@ max(int a, int b) /* strftime --- produce formatted time */ static size_t -date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev, struct timespec *ts, int gmt) +date_strftime_wo_timespec(char *s, size_t maxsize, const char *format, + const struct vtm *vtm, VALUE timev) { char *endp = s + maxsize; char *start = s; @@ -234,7 +235,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s } while (0) #define STRFTIME(fmt) \ do { \ - i = date_strftime_with_timespec(s, endp - s, (fmt), vtm, timev, ts, gmt); \ + i = date_strftime_wo_timespec(s, endp - s, (fmt), vtm, timev); \ if (!i) return 0; \ if (precision > i) {\ if (start + maxsize < s + precision) { \ @@ -418,14 +419,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s case 's': SKIP_MODIFIER_EO; - if (ts) { - time_t sec = ts->tv_sec; - if (~(time_t)0 <= 0) - FMT('0', 1, PRI_TIMET_PREFIX"d", sec); - else - FMT('0', 1, PRI_TIMET_PREFIX"u", sec); - } - else { + { VALUE sec = div(timev, INT2FIX(1)); FMTV('0', 1, "d", sec); } @@ -495,12 +489,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s { int aoff, hl, hw; - if (gmt) { - off = 0; - } - else { - off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0)); - } + off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0)); aoff = off; if (aoff < 0) @@ -593,11 +582,6 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s flags &= ~(BIT_OF(UPPER)|BIT_OF(CHCASE)); flags |= BIT_OF(LOWER); } - if (gmt) { - i = 3; - tp = "UTC"; - break; - } if (vtm->zone == NULL) tp = ""; else @@ -761,22 +745,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s } NEEDS(precision); - if (ts) { - long subsec = ts->tv_nsec; - if (9 < precision) { - snprintf(s, endp - s, "%09ld", subsec); - memset(s+9, '0', precision-9); - s += precision; - } - else { - int i; - for (i = 0; i < 9-precision; i++) - subsec /= 10; - snprintf(s, endp - s, "%0*ld", precision, subsec); - s += precision; - } - } - else { + { VALUE subsec = mod(timev, INT2FIX(1)); int ww; long n; @@ -896,15 +865,9 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s } size_t -date_strftime(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev, int gmt) -{ - return date_strftime_with_timespec(s, maxsize, format, vtm, timev, NULL, gmt); -} - -size_t -date_strftime_timespec(char *s, size_t maxsize, const char *format, const struct vtm *vtm, struct timespec *ts, int gmt) +date_strftime(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev) { - return date_strftime_with_timespec(s, maxsize, format, vtm, Qnil, ts, gmt); + return date_strftime_wo_timespec(s, maxsize, format, vtm, timev); } /* isleap --- is a year a leap year? */ -- cgit v1.2.3