mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_inspect): get rid of adding garbage to short
UTF-8 string. [ruby-dev:39550] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f582b224bd
commit
20a2b656c2
3 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Oct 27 22:05:46 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_inspect): get rid of adding garbage to shor
|
||||
UTF-8 string. [ruby-dev:39550]
|
||||
|
||||
Tue Oct 27 21:20:35 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk/variable.rb: add TkVariable#+@ and -@ method.
|
||||
|
|
4
string.c
4
string.c
|
@ -2718,8 +2718,8 @@ rb_str_inspect(str)
|
|||
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
|
||||
while (p < pend) {
|
||||
char c = *p++;
|
||||
if (ismbchar(c) && p < pend) {
|
||||
int len = mbclen(c);
|
||||
int len;
|
||||
if (ismbchar(c) && p + (len = mbclen(c)) <= pend) {
|
||||
rb_str_buf_cat(result, p - 1, len);
|
||||
p += len - 1;
|
||||
}
|
||||
|
|
|
@ -140,4 +140,17 @@ class TestString < Test::Unit::TestCase
|
|||
ensure
|
||||
$KCODE = original_kcode
|
||||
end
|
||||
|
||||
def test_inspect
|
||||
original_kcode = $KCODE
|
||||
|
||||
$KCODE = 'n'
|
||||
assert_equal('"\343\201\202"', "\xe3\x81\x82".inspect)
|
||||
|
||||
$KCODE = 'u'
|
||||
assert_equal("\"\xe3\x81\x82\"", "\xe3\x81\x82".inspect)
|
||||
assert_no_match(/\0/, "\xe3\x81".inspect, '[ruby-dev:39550]')
|
||||
ensure
|
||||
$KCODE = original_kcode
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue