summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/string.c b/string.c
index d72d0352c7..57b5cd837b 100644
--- a/string.c
+++ b/string.c
@@ -1076,12 +1076,14 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
(ptr_a8 && str_cr != ENC_CODERANGE_7BIT)) {
ptr_cr = ENC_CODERANGE_UNKNOWN;
}
- else {
+ else if (ptr_cr == ENC_CODERANGE_UNKNOWN) {
ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex));
}
}
else {
- ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex));
+ if (ptr_cr == ENC_CODERANGE_UNKNOWN) {
+ ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex));
+ }
if (str_cr == ENC_CODERANGE_UNKNOWN) {
if (str_a8 || ptr_cr != ENC_CODERANGE_7BIT) {
str_cr = rb_enc_str_coderange(str);