* 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
This commit is contained in:
naruse 2012-06-02 08:02:23 +00:00
Родитель 5f85fcc11f
Коммит 7671e7dd35
2 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Sat Jun 2 16:59:00 2012 NARUSE, Yui <naruse@ruby-lang.org>
* 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@segment7.net>
* doc/re.rdoc (Performance): Replaced incorrect example of reducing

Просмотреть файл

@ -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));
}