diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-23 01:04:39 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-23 01:04:39 +0000 |
commit | 6f8f950cc3aec12826c72e7e67bf54022444aacc (patch) | |
tree | 81c4f7ff4b02bab28c347e5dc19061276ff9f18c /sprintf.c | |
parent | a6f0ec21e9d07a7a10f5a2fe06728fdad5b4d1d6 (diff) | |
download | ruby-6f8f950cc3aec12826c72e7e67bf54022444aacc.tar.gz |
Fix space flag when Inf/NaN and width==3
* sprintf.c (rb_str_format): while `"% 2f"` and `"% 4f"` result in
`" Inf"` and `" Inf"` respectively, `"% 3f"` results in
`"Inf"` (no space).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -1136,7 +1136,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) expr = "Inf"; } need = (int)strlen(expr); - if ((!isnan(fval) && fval < 0.0) || (flags & FPLUS)) + if ((!isnan(fval) && fval < 0.0) || (flags & (FPLUS|FSPACE))) need++; if ((flags & FWIDTH) && need < width) need = width; @@ -1157,8 +1157,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) buf[blen + need - strlen(expr) - 1] = '-'; else if (flags & FPLUS) buf[blen + need - strlen(expr) - 1] = '+'; - else if ((flags & FSPACE) && need > width) - blen++; memcpy(&buf[blen + need - strlen(expr)], expr, strlen(expr)); } |