[前][次][番号順一覧][スレッド一覧]

ruby-changes:23217

From: tadf <ko1@a...>
Date: Mon, 9 Apr 2012 08:12:44 +0900 (JST)
Subject: [ruby-changes:23217] tadf:r35267 (trunk): * ext/date/date_strftime.c: gets the value with range() consistetly.

tadf	2012-04-09 08:12:30 +0900 (Mon, 09 Apr 2012)

  New Revision: 35267

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35267

  Log:
    * ext/date/date_strftime.c: gets the value with range() consistetly.
    * ext/date/date_strftime.c (range): now just replaces the given item.

  Modified files:
    trunk/ChangeLog
    trunk/ext/date/date_strftime.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35266)
+++ ChangeLog	(revision 35267)
@@ -1,3 +1,8 @@
+Mon Apr  9 08:01:15 2012  Tadayoshi Funaba  <tadf@d...>
+
+	* 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@d...>
 
 	* complex.c (nucomp_expt): [ruby-core:44170].
Index: ext/date/date_strftime.c
===================================================================
--- ext/date/date_strftime.c	(revision 35266)
+++ ext/date/date_strftime.c	(revision 35267)
@@ -122,7 +122,11 @@
 extern char *strchr();
 #endif
 
+#if 0
 #define range(low, item, hi)	max((low), min((item), (hi)))
+#else
+#define range(low, item, hi)	(item)
+#endif
 
 #undef min	/* just in case */
 
@@ -376,7 +380,8 @@
 			continue;
 
 		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;
 
 		case 'm':	/* month, 01 - 12 */
@@ -418,7 +423,8 @@
 			continue;
 
 		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;
 
 		case 'w':	/* weekday, Sunday == 0, 0 - 6 */
@@ -427,7 +433,8 @@
 			continue;
 
 		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;
 
 		case 'x':	/* appropriate date representation */
@@ -580,7 +587,8 @@
 			continue;
 
 		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;
 
 		case 'r':	/* time as %I:%M:%S %p */
@@ -637,12 +645,14 @@
 				goto again;
 			goto unknown;
 		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;
 
 		case 'u':
 		/* 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;
 #endif	/* POSIX2_DATE */
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]