From 7671e7dd35e5f116664d5bc7ae22438a6e40677b Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 2 Jun 2012 08:02:23 +0000 Subject: [PATCH] * string.c (rb_enc_cr_str_buf_cat): don't reset coderange as unknown. the condition 'ptr_a8 && str_cr != ENC_CODERANGE_7BIT' means not unknown, str is also ASCII-8BIT because str_encindex == ptr_encindex, and nont (str_cr == ENC_CODERANGE_UNKNOWN) and str_cr != ENC_CODERANGE_7BIT means str_cr is valid because ASCII-8BIT can't be broken. [ruby-dev:45688] [Bug #6509] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ string.c | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 401dd3a590..2459099712 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sat Jun 2 16:59:00 2012 NARUSE, Yui + + * string.c (rb_enc_cr_str_buf_cat): don't reset coderange as unknown. + the condition 'ptr_a8 && str_cr != ENC_CODERANGE_7BIT' means not + unknown, str is also ASCII-8BIT because str_encindex == ptr_encindex, + and nont (str_cr == ENC_CODERANGE_UNKNOWN) and + str_cr != ENC_CODERANGE_7BIT means str_cr is valid because ASCII-8BIT + can't be broken. [ruby-dev:45688] [Bug #6509] + Sat Jun 2 07:04:48 2012 Eric Hodel * doc/re.rdoc (Performance): Replaced incorrect example of reducing diff --git a/string.c b/string.c index 9238e6c7f8..d724a28f2b 100644 --- a/string.c +++ b/string.c @@ -1925,10 +1925,11 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, str_cr = ENC_CODERANGE(str); if (str_encindex == ptr_encindex) { - if (str_cr == ENC_CODERANGE_UNKNOWN || - (ptr_a8 && str_cr != ENC_CODERANGE_7BIT)) { + if (str_cr == ENC_CODERANGE_UNKNOWN) ptr_cr = ENC_CODERANGE_UNKNOWN; - } + else if (ptr_a8 && str_cr == ENC_CODERANGE_VALID) + /* since str is also ASCII-8BIT, 7bit nor unknown means valid */ + ptr_cr = ENC_CODERANGE_VALID; else if (ptr_cr == ENC_CODERANGE_UNKNOWN) { ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex)); }