* ext/date/date_strftime.c: gets the value with range() consistetly.

* ext/date/date_strftime.c (range): now just replaces the given item.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2012-04-08 23:12:30 +00:00
parent 228a99a0b2
commit 6cb7ac7e15
2 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,8 @@
Mon Apr 9 08:01:15 2012 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_strftime.c: gets the value with range() consistetly.
* ext/date/date_strftime.c (range): now just replaces the given item.
Mon Apr 9 06:58:01 2012 Tadayoshi Funaba <tadf@dotrb.org> Mon Apr 9 06:58:01 2012 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (nucomp_expt): [ruby-core:44170]. * complex.c (nucomp_expt): [ruby-core:44170].

View File

@ -122,7 +122,11 @@ extern char *getenv();
extern char *strchr(); extern char *strchr();
#endif #endif
#if 0
#define range(low, item, hi) max((low), min((item), (hi))) #define range(low, item, hi) max((low), min((item), (hi)))
#else
#define range(low, item, hi) (item)
#endif
#undef min /* just in case */ #undef min /* just in case */
@ -376,7 +380,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
continue; continue;
case 'j': /* day of the year, 001 - 366 */ case 'j': /* day of the year, 001 - 366 */
FMT('0', 3, "d", tmx_yday); v = range(1, tmx_yday, 366);
FMT('0', 3, "d", v);
continue; continue;
case 'm': /* month, 01 - 12 */ case 'm': /* month, 01 - 12 */
@ -418,7 +423,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
continue; continue;
case 'U': /* week of year, Sunday is first day of week */ case 'U': /* week of year, Sunday is first day of week */
FMT('0', 2, "d", tmx_wnum0); v = range(0, tmx_wnum0, 53);
FMT('0', 2, "d", v);
continue; continue;
case 'w': /* weekday, Sunday == 0, 0 - 6 */ case 'w': /* weekday, Sunday == 0, 0 - 6 */
@ -427,7 +433,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
continue; continue;
case 'W': /* week of year, Monday is first day of week */ case 'W': /* week of year, Monday is first day of week */
FMT('0', 2, "d", tmx_wnum1); v = range(0, tmx_wnum1, 53);
FMT('0', 2, "d", v);
continue; continue;
case 'x': /* appropriate date representation */ case 'x': /* appropriate date representation */
@ -580,7 +587,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
continue; continue;
case 'e': /* day of month, blank padded */ case 'e': /* day of month, blank padded */
FMT(' ', 2, "d", range(1, tmx_mday, 31)); v = range(1, tmx_mday, 31);
FMT(' ', 2, "d", v);
continue; continue;
case 'r': /* time as %I:%M:%S %p */ case 'r': /* time as %I:%M:%S %p */
@ -637,12 +645,14 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
goto again; goto again;
goto unknown; goto unknown;
case 'V': /* week of year according ISO 8601 */ case 'V': /* week of year according ISO 8601 */
FMT('0', 2, "d", tmx_cweek); v = range(1, tmx_cweek, 53);
FMT('0', 2, "d", v);
continue; continue;
case 'u': case 'u':
/* ISO 8601: Weekday as a decimal number [1 (Monday) - 7] */ /* ISO 8601: Weekday as a decimal number [1 (Monday) - 7] */
FMT('0', 1, "d", tmx_cwday); v = range(1, tmx_cwday, 7);
FMT('0', 1, "d", v);
continue; continue;
#endif /* POSIX2_DATE */ #endif /* POSIX2_DATE */