mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_enc_cr_str_buf_cat): ASCII incompatible encoding is
not compatible with any other encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e336136d8a
commit
968e404220
3 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Jan 24 11:14:56 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (rb_enc_cr_str_buf_cat): ASCII incompatible encoding is
|
||||
not compatible with any other encoding.
|
||||
|
||||
Thu Jan 24 07:34:34 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* parse.y (STR_NEW0): set encoding as US-ASCII.
|
||||
|
|
8
string.c
8
string.c
|
@ -1140,8 +1140,13 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
|
|||
}
|
||||
}
|
||||
else {
|
||||
rb_encoding *str_enc = rb_enc_from_index(str_encindex);
|
||||
rb_encoding *ptr_enc = rb_enc_from_index(ptr_encindex);
|
||||
if (!rb_enc_asciicompat(str_enc) || !rb_enc_asciicompat(ptr_enc)) {
|
||||
goto incompatible;
|
||||
}
|
||||
if (ptr_cr == ENC_CODERANGE_UNKNOWN) {
|
||||
ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex));
|
||||
ptr_cr = coderange_scan(ptr, len, ptr_enc);
|
||||
}
|
||||
if (str_cr == ENC_CODERANGE_UNKNOWN) {
|
||||
if (str_a8 || ptr_cr != ENC_CODERANGE_7BIT) {
|
||||
|
@ -1155,6 +1160,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
|
|||
if (str_encindex != ptr_encindex &&
|
||||
str_cr != ENC_CODERANGE_7BIT &&
|
||||
ptr_cr != ENC_CODERANGE_7BIT) {
|
||||
incompatible:
|
||||
rb_raise(rb_eArgError, "append incompatible encoding strings: %s and %s",
|
||||
rb_enc_name(rb_enc_from_index(str_encindex)),
|
||||
rb_enc_name(rb_enc_from_index(ptr_encindex)));
|
||||
|
|
|
@ -103,4 +103,12 @@ class TestUTF16 < Test::Unit::TestCase
|
|||
def test_slice!
|
||||
enccall("aa".force_encoding("UTF-16BE"), :slice!, -1)
|
||||
end
|
||||
|
||||
def test_concat
|
||||
s1 = ""
|
||||
s2 = "aa".force_encoding("utf-16be")
|
||||
assert_raise(ArgumentError, "#{encdump s1} << #{encdump s2}") {
|
||||
s1 << s2
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue