ruby-changes:23596
From: tadf <ko1@a...>
Date: Tue, 15 May 2012 06:41:07 +0900 (JST)
Subject: [ruby-changes:23596] tadf:r35647 (trunk): trivial changes
tadf 2012-05-15 06:39:25 +0900 (Tue, 15 May 2012) New Revision: 35647 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35647 Log: trivial changes Modified files: trunk/ext/date/date_core.c trunk/ext/date/date_strftime.c Index: ext/date/date_core.c =================================================================== --- ext/date/date_core.c (revision 35646) +++ ext/date/date_core.c (revision 35647) @@ -4207,7 +4207,7 @@ * Parses the given representation of date and time with the given * template, and returns a hash of parsed elements. _strptime does * not support specification of flags and width unlike strftime. - * + * * For example: * * Date._strptime('2001-02-03', '%Y-%m-%d') Index: ext/date/date_strftime.c =================================================================== --- ext/date/date_strftime.c (revision 35646) +++ ext/date/date_strftime.c (revision 35647) @@ -1,6 +1,6 @@ /* date_strftime.c: based on a public-domain implementation of ANSI C - library routine of strftime, which is originally written by Arnold + library routine strftime, which is originally written by Arnold Robbins. */ @@ -84,7 +84,8 @@ if (precision <= 0) precision = (def_prec); \ if (flags & BIT_OF(LEFT)) precision = 1; \ l = snprintf(s, endp - s, \ - ((padding == '0' || (!padding && (def_pad) == '0')) ? "%0*"fmt : "%*"fmt), \ + ((padding == '0' || (!padding && (def_pad) == '0')) ? \ + "%0*"fmt : "%*"fmt), \ precision, (val)); \ if (l < 0) goto err; \ s += l; \ @@ -121,8 +122,8 @@ result = rb_str_format(2, args, rb_str_new2("%0*"fmt)); \ else \ result = rb_str_format(2, args, rb_str_new2("%*"fmt)); \ - l = strlcpy(s, StringValueCStr(result), endp-s); \ - if ((size_t)(endp-s) <= l) \ + l = strlcpy(s, StringValueCStr(result), endp - s); \ + if ((size_t)(endp - s) <= l) \ goto err; \ s += l; \ } \ @@ -176,14 +177,14 @@ i = 1, tp = "?"; else { if (*format == 'B') - i = strlen(tp = months_l[mon-1]); + i = strlen(tp = months_l[mon - 1]); else - i = 3, tp = months_l[mon-1]; + i = 3, tp = months_l[mon - 1]; } } break; - case 'C': + case 'C': /* century (year/100) */ FMTV('0', 2, "d", div(tmx_year, INT2FIX(100))); continue; @@ -272,7 +273,8 @@ subsec = div(subsec, INT2FIX(1)); if (FIXNUM_P(subsec)) { - (void)snprintf(s, endp - s, "%0*ld", precision, FIX2LONG(subsec)); + (void)snprintf(s, endp - s, "%0*ld", + precision, FIX2LONG(subsec)); s += precision; } else { @@ -280,7 +282,7 @@ args[0] = INT2FIX(precision); args[1] = subsec; result = rb_str_format(2, args, rb_str_new2("%0*d")); - (void)strlcpy(s, StringValueCStr(result), endp-s); + (void)strlcpy(s, StringValueCStr(result), endp - s); s += precision; } } @@ -321,7 +323,7 @@ i = 2; break; - case 'Q': + case 'Q': /* microseconds since Unix epoch */ FMTV('0', 1, "d", tmx_msecs); continue; @@ -338,7 +340,7 @@ FMT('0', 2, "d", v); continue; - case 's': + case 's': /* seconds since Unix epoch */ FMTV('0', 1, "d", tmx_secs); continue; @@ -352,8 +354,7 @@ FMT('0', 2, "d", v); continue; - case 'u': - /* ISO 8601: Weekday as a decimal number [1 (Monday) - 7] */ + case 'u': /* weekday, Monday == 1, 1 - 7 */ v = range(1, tmx_cwday, 7); FMT('0', 1, "d", v); continue; @@ -413,7 +414,7 @@ } break; - case 'z': /* time zone offset east of UTC e.g. -0600 */ + case 'z': /* offset from UTC */ { long off, aoff; int hl, hw; @@ -434,32 +435,35 @@ switch (colons) { case 0: /* %z -> +hhmm */ - precision = precision <= (3 + hw) ? hw : precision-3; + precision = precision <= (3 + hw) ? hw : precision - 3; NEEDS(precision + 3); break; case 1: /* %:z -> +hh:mm */ - precision = precision <= (4 + hw) ? hw : precision-4; + precision = precision <= (4 + hw) ? hw : precision - 4; NEEDS(precision + 4); break; case 2: /* %::z -> +hh:mm:ss */ - precision = precision <= (7 + hw) ? hw : precision-7; + precision = precision <= (7 + hw) ? hw : precision - 7; NEEDS(precision + 7); break; case 3: /* %:::z -> +hh[:mm[:ss]] */ { if (aoff % 3600 == 0) { - precision = precision <= (1 + hw) ? hw : precision-1; + precision = precision <= (1 + hw) ? + hw : precision - 1; NEEDS(precision + 3); } else if (aoff % 60 == 0) { - precision = precision <= (4 + hw) ? hw : precision-4; + precision = precision <= (4 + hw) ? + hw : precision - 4; NEEDS(precision + 4); } else { - precision = precision <= (7 + hw) ? hw : precision-7; + precision = precision <= (7 + hw) ? + hw : precision - 7; NEEDS(precision + 7); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/