mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: fix coderange for non-endianness string
* string.c (rb_enc_str_coderange): dummy wchar, non-endianness encoding string cannot be ascii only. [ruby-core:66835] [Bug #10598] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b2a128fa7c
commit
020fcc95fe
3 changed files with 23 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
Mon Dec 15 16:19:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_enc_str_coderange): dummy wchar, non-endianness
|
||||
encoding string cannot be ascii only.
|
||||
[ruby-core:66835] [Bug #10598]
|
||||
|
||||
Sun Dec 14 20:11:42 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (primary): restore current_arg so that circular
|
||||
|
|
11
string.c
11
string.c
|
@ -487,8 +487,15 @@ rb_enc_str_coderange(VALUE str)
|
|||
int cr = ENC_CODERANGE(str);
|
||||
|
||||
if (cr == ENC_CODERANGE_UNKNOWN) {
|
||||
rb_encoding *enc = STR_ENC_GET(str);
|
||||
cr = coderange_scan(RSTRING_PTR(str), RSTRING_LEN(str), enc);
|
||||
int encidx = ENCODING_GET(str);
|
||||
rb_encoding *enc = rb_enc_from_index(encidx);
|
||||
if (rb_enc_mbminlen(enc) > 1 && rb_enc_dummy_p(enc)) {
|
||||
cr = ENC_CODERANGE_BROKEN;
|
||||
}
|
||||
else {
|
||||
cr = coderange_scan(RSTRING_PTR(str), RSTRING_LEN(str),
|
||||
get_actual_encoding(encidx, str));
|
||||
}
|
||||
ENC_CODERANGE_SET(str, cr);
|
||||
}
|
||||
return cr;
|
||||
|
|
|
@ -260,6 +260,14 @@ class TestM17N < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_utf_without_bom_asciionly
|
||||
bug10598 = '[ruby-core:66835] [Bug #10598]'
|
||||
encs = [Encoding::UTF_16, Encoding::UTF_32].find_all {|enc|
|
||||
"abcd".force_encoding(enc).ascii_only?
|
||||
}
|
||||
assert_empty(encs, bug10598)
|
||||
end
|
||||
|
||||
def test_object_utf16_32_inspect
|
||||
EnvUtil.suppress_warning do
|
||||
begin
|
||||
|
|
Loading…
Reference in a new issue