mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
5c233dcd40
commit
7d488c4e4e
1 changed files with 4 additions and 4 deletions
|
@ -283,11 +283,11 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
|
||||||
(padding == '0' || (!padding && (def_pad) == '0')) ? \
|
(padding == '0' || (!padding && (def_pad) == '0')) ? \
|
||||||
rb_strlen_lit("%*"fmt)+1 : 0])
|
rb_strlen_lit("%*"fmt)+1 : 0])
|
||||||
#define FMT_PRECISION(def_prec) \
|
#define FMT_PRECISION(def_prec) \
|
||||||
((flags & BIT_OF(LEFT)) ? (precision = 1) : \
|
((flags & BIT_OF(LEFT)) ? (1) : \
|
||||||
(precision <= 0) ? (precision = (def_prec)) : (precision))
|
(precision <= 0) ? (def_prec) : (precision))
|
||||||
#define FMT(def_pad, def_prec, fmt, val) \
|
#define FMT(def_pad, def_prec, fmt, val) \
|
||||||
do { \
|
do { \
|
||||||
FMT_PRECISION(def_prec); \
|
precision = FMT_PRECISION(def_prec); \
|
||||||
len = s - start; \
|
len = s - start; \
|
||||||
NEEDS(precision); \
|
NEEDS(precision); \
|
||||||
rb_str_set_len(ftime, len); \
|
rb_str_set_len(ftime, len); \
|
||||||
|
@ -324,7 +324,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len,
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
const char *fmts = FMT_PADDING(fmt, def_pad); \
|
const char *fmts = FMT_PADDING(fmt, def_pad); \
|
||||||
FMT_PRECISION(def_prec); \
|
precision = FMT_PRECISION(def_prec); \
|
||||||
tmp = format_value(fmts, tmp, precision); \
|
tmp = format_value(fmts, tmp, precision); \
|
||||||
rb_str_append(ftime, tmp); \
|
rb_str_append(ftime, tmp); \
|
||||||
RSTRING_GETMEM(ftime, s, len); \
|
RSTRING_GETMEM(ftime, s, len); \
|
||||||
|
|
Loading…
Reference in a new issue