ruby-changes:23812
From: naruse <ko1@a...>
Date: Sat, 2 Jun 2012 17:02:36 +0900 (JST)
Subject: [ruby-changes:23812] naruse:r35863 (trunk): * string.c (rb_enc_cr_str_buf_cat): don't reset coderange as unknown.
naruse 2012-06-02 17:02:23 +0900 (Sat, 02 Jun 2012) New Revision: 35863 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35863 Log: * 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] Modified files: trunk/ChangeLog trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 35862) +++ ChangeLog (revision 35863) @@ -1,3 +1,12 @@ +Sat Jun 2 16:59:00 2012 NARUSE, Yui <naruse@r...> + + * 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 <drbrain@s...> * doc/re.rdoc (Performance): Replaced incorrect example of reducing Index: string.c =================================================================== --- string.c (revision 35862) +++ string.c (revision 35863) @@ -1925,10 +1925,11 @@ 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)); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/