mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_setstrbuf): cut down the buffer if longer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
799680354e
commit
52cb46337e
2 changed files with 12 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Feb 14 16:00:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (io_setstrbuf): cut down the buffer if longer.
|
||||
|
||||
Tue Feb 14 15:06:37 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/test/unit/assertions.rb (build_message): skip escaped
|
||||
|
|
11
io.c
11
io.c
|
@ -2072,7 +2072,7 @@ io_shift_cbuf(rb_io_t *fptr, int len, VALUE *strp)
|
|||
}
|
||||
|
||||
static void
|
||||
io_setstrbuf(VALUE *str,long len)
|
||||
io_setstrbuf(VALUE *str, long len)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
len = (len + 1) & ~1L; /* round up for wide char */
|
||||
|
@ -2081,8 +2081,13 @@ io_setstrbuf(VALUE *str,long len)
|
|||
*str = rb_str_new(0, 0);
|
||||
}
|
||||
else {
|
||||
StringValue(*str);
|
||||
len -= RSTRING_LEN(*str);
|
||||
VALUE s = StringValue(*str);
|
||||
long clen = RSTRING_LEN(s);
|
||||
if (clen >= len) {
|
||||
if (clen != len) rb_str_set_len(s, len);
|
||||
return;
|
||||
}
|
||||
len -= clen;
|
||||
}
|
||||
rb_str_modify_expand(*str, len);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue