diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-11-27 08:20:41 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-11-27 08:20:41 +0000 |
| commit | bb5a9b1e2f5a7bbcd73470cb34e1959f10ea0b17 (patch) | |
| tree | 63df22e0360e3f2ae1484ce94ca8fac97a92fca8 | |
| parent | c17733641035ca4e9edf7ad666a8407ec832e2ca (diff) | |
| download | ruby-bb5a9b1e2f5a7bbcd73470cb34e1959f10ea0b17.tar.gz ruby-bb5a9b1e2f5a7bbcd73470cb34e1959f10ea0b17.tar.xz ruby-bb5a9b1e2f5a7bbcd73470cb34e1959f10ea0b17.zip | |
* sprintf.c (rb_f_sprintf): need not to truncate string if no
width specifier given for %s. [ruby-dev:29952]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@11311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | sprintf.c | 20 |
2 files changed, 7 insertions, 18 deletions
@@ -1,3 +1,8 @@ +Mon Nov 27 17:18:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org> + + * sprintf.c (rb_f_sprintf): need not to truncate string if no + width specifier given for %s. [ruby-dev:29952] + Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org> * version.h: addition of RUBY_PATCHLEVEL. @@ -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--) { |
