summaryrefslogtreecommitdiff
path: root/strftime.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-24 15:01:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-24 15:01:39 +0000
commit7d488c4e4eb30e8d9d3cde5dc628beaf0639bb51 (patch)
tree33cbd02c5e935f16234fc5cac5c1554ac3ff10ec /strftime.c
parent5c233dcd408f1df2259ec0c7de2cc0e013dd44c8 (diff)
strftime.c: refine r54248
* strftime.c (FMT_PRECISION): eliminate side effects. [Bug #12213] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/strftime.c b/strftime.c
index 2f1888d457..42761f0d7c 100644
--- a/strftime.c
+++ b/strftime.c
@@ -283,11 +283,11 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
(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, const char *format, size_t format_len,
} \
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); \