ruby-changes:42176
From: nobu <ko1@a...>
Date: Fri, 25 Mar 2016 00:01:45 +0900 (JST)
Subject: [ruby-changes:42176] nobu:r54250 (trunk): strftime.c: refine r54248
nobu 2016-03-25 00:01:39 +0900 (Fri, 25 Mar 2016) New Revision: 54250 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54250 Log: strftime.c: refine r54248 * strftime.c (FMT_PRECISION): eliminate side effects. [Bug #12213] Modified files: trunk/strftime.c Index: strftime.c =================================================================== --- strftime.c (revision 54249) +++ strftime.c (revision 54250) @@ -283,11 +283,11 @@ rb_strftime_with_timespec(VALUE ftime, c https://github.com/ruby/ruby/blob/trunk/strftime.c#L283 (padding == '0' || (!padding && (def_pad) == '0')) ? \ rb_strlen_lit("%*"fmt)+1 : 0]) #define FMT_PRECISION(def_prec) \ - ((flags & BIT_OF(LEFT)) ? (precision = 1) : \ - (precision <= 0) ? (precision = (def_prec)) : (precision)) + ((flags & BIT_OF(LEFT)) ? (1) : \ + (precision <= 0) ? (def_prec) : (precision)) #define FMT(def_pad, def_prec, fmt, val) \ do { \ - FMT_PRECISION(def_prec); \ + precision = FMT_PRECISION(def_prec); \ len = s - start; \ NEEDS(precision); \ rb_str_set_len(ftime, len); \ @@ -324,7 +324,7 @@ rb_strftime_with_timespec(VALUE ftime, c https://github.com/ruby/ruby/blob/trunk/strftime.c#L324 } \ else { \ const char *fmts = FMT_PADDING(fmt, def_pad); \ - FMT_PRECISION(def_prec); \ + precision = FMT_PRECISION(def_prec); \ tmp = format_value(fmts, tmp, precision); \ rb_str_append(ftime, tmp); \ RSTRING_GETMEM(ftime, s, len); \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/