summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-12 07:43:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-12 07:43:14 +0000
commitd80a859d98a86e201075156a2b2cc5fa91aa4e08 (patch)
tree72239be9d685929ad72596a76b51faea86ddd8be /numeric.c
parentd2a68945e6c20cf5e68ef27387b31ac102fd493f (diff)
* numeric.c (flo_to_s): fixed broken output including nuls.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index d6dd1c4a5c..00d670b70f 100644
--- a/numeric.c
+++ b/numeric.c
@@ -585,10 +585,15 @@ flo_to_s(VALUE flt)
}
else if (decpt - digs < float_dig) {
long len;
+ char *ptr;
rb_str_cat(s, buf, digs);
rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2);
- if (decpt > digs) memset(RSTRING_PTR(s) + len, '0', decpt - digs);
- rb_str_cat(s, ".0", 2);
+ ptr = RSTRING_PTR(s) + len;
+ if (decpt > digs) {
+ memset(ptr, '0', decpt - digs);
+ ptr += decpt - digs;
+ }
+ memcpy(ptr, ".0", 2);
}
else {
goto exp;