aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-24 02:17:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-24 02:17:26 +0000
commit968e404220762d5adfc04b8c030c6f186cb47c0e (patch)
tree6e5e7f36c252217328cf5d4e95bcfbdb2bc0d690 /string.c
parente336136d8a4943b4778ce93df7c3d944614416d4 (diff)
downloadruby-968e404220762d5adfc04b8c030c6f186cb47c0e.tar.gz
* 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
Diffstat (limited to 'string.c')
-rw-r--r--string.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/string.c b/string.c
index 0dfb098679..3ac56b56c5 100644
--- a/string.c
+++ b/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)));