summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-11-27 08:20:41 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-11-27 08:20:41 +0000
commit165b284f72b7c0f78232e59587a75d06f6fa2d94 (patch)
tree63df22e0360e3f2ae1484ce94ca8fac97a92fca8 /sprintf.c
parenta03f42d1cdb9a4beab51af0e805660a184277a39 (diff)
downloadruby-165b284f72b7c0f78232e59587a75d06f6fa2d94.tar.gz
* sprintf.c (rb_f_sprintf): need not to truncate string if no
width specifier given for %s. [ruby-dev:29952] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/sprintf.c b/sprintf.c
index 26142dea51..ffe4e22855 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -420,23 +420,7 @@ rb_f_sprintf(argc, argv)
len = prec;
}
}
- {
- char *s, *send;
- long l;
-
- s = RSTRING(str)->ptr;
- send = s + RSTRING(str)->len;
- l = 0;
- while (s < send) {
- long n = mbclen(*s);
- if (l + n > len) {
- len = l;
- break;
- }
- l += n;
- s += n;
- }
- }
+ /* need to adjust multi-byte string pos */
if (flags&FWIDTH) {
if (width > len) {
CHECK(width);
@@ -446,7 +430,7 @@ rb_f_sprintf(argc, argv)
buf[blen++] = ' ';
}
}
- memcpy(&buf[blen], RSTRING(str)->ptr, len);
+ memcpy(&buf[blen], RSTRING_PTR(str), len);
blen += len;
if (flags&FMINUS) {
while (width--) {