mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (str_nth_len): count ascii-only run at the end. this
bug appears only when single-byte-optimization is disabled due to unknown coderange. [ruby-core:41896] [Bug #5836] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
79e0379a75
commit
460528289a
3 changed files with 16 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Jan 4 14:24:33 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (str_nth_len): count ascii-only run at the end. this
|
||||
bug appears only when single-byte-optimization is disabled due
|
||||
to unknown coderange. [ruby-core:41896] [Bug #5836]
|
||||
|
||||
Wed Jan 4 11:32:07 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (check_valid_dir): special case for a root directory.
|
||||
|
|
1
string.c
1
string.c
|
@ -1483,6 +1483,7 @@ str_nth_len(const char *p, const char *e, long *nthp, rb_encoding *enc)
|
|||
if (ISASCII(*p)) {
|
||||
p2 = search_nonascii(p, e2);
|
||||
if (!p2) {
|
||||
nth -= e2 - p;
|
||||
*nthp = nth;
|
||||
return (char *)e2;
|
||||
}
|
||||
|
|
|
@ -930,6 +930,15 @@ class TestM17N < Test::Unit::TestCase
|
|||
assert_equal("\u{439}", "a\u{439}bcdefghijklmnop"[1, 1][0, 1], bug2379)
|
||||
end
|
||||
|
||||
def test_str_aref_force_encoding
|
||||
bug5836 = '[ruby-core:41896]'
|
||||
Encoding.list.each do |enc|
|
||||
next unless enc.ascii_compatible?
|
||||
s = "abc".force_encoding(enc)
|
||||
assert_equal("", s[3, 1], bug5836)
|
||||
end
|
||||
end
|
||||
|
||||
def test_aset
|
||||
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
|
||||
assert_raise(Encoding::CompatibilityError){s["\xb0\xa3"] = "foo"}
|
||||
|
|
Loading…
Add table
Reference in a new issue