mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_dump): fix expected length. [ruby-core:32935]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87c0b99446
commit
30ab36c7dc
3 changed files with 23 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Oct 29 03:04:16 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_dump): fix expected length. [ruby-core:32935]
|
||||||
|
|
||||||
Thu Oct 28 23:31:39 2010 Koichi Sasada <ko1@atdot.net>
|
Thu Oct 28 23:31:39 2010 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* gc.c (before_gc_sweep, run_final): fix decrement timing of final_num.
|
* gc.c (before_gc_sweep, run_final): fix decrement timing of final_num.
|
||||||
|
|
9
string.c
9
string.c
|
@ -4315,12 +4315,11 @@ rb_str_dump(VALUE str)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (u8) { /* \u{NN} */
|
if (u8) { /* \u{NN} */
|
||||||
char buf[32];
|
|
||||||
int n = rb_enc_precise_mbclen(p-1, pend, enc);
|
int n = rb_enc_precise_mbclen(p-1, pend, enc);
|
||||||
if (MBCLEN_CHARFOUND_P(n)) {
|
if (MBCLEN_CHARFOUND_P(n-1)) {
|
||||||
int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc);
|
unsigned int cc = rb_enc_mbc_to_codepoint(p-1, pend, enc);
|
||||||
sprintf(buf, "%x", cc);
|
while (cc >>= 4) len++;
|
||||||
len += strlen(buf)+4;
|
len += 5;
|
||||||
p += MBCLEN_CHARFOUND_LEN(n)-1;
|
p += MBCLEN_CHARFOUND_LEN(n)-1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,4 +163,19 @@ EOS
|
||||||
s.delete!("a-z")
|
s.delete!("a-z")
|
||||||
assert_equal("BB", s)
|
assert_equal("BB", s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dump
|
||||||
|
bug3996 = '[ruby-core:32935]'
|
||||||
|
Encoding.list.find_all {|enc| enc.ascii_compatible?}.each do |enc|
|
||||||
|
(0..256).map do |c|
|
||||||
|
begin
|
||||||
|
s = c.chr(enc)
|
||||||
|
rescue RangeError, ArgumentError
|
||||||
|
break
|
||||||
|
else
|
||||||
|
assert_not_match(/\0/, s.dump, bug3996)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue