* string.c (rb_str_coderange_scan_restartable): coderange is always

ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non
  ASCII character.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-04-21 10:15:54 +00:00
Родитель 9f2ddef227
Коммит df645bf79c
2 изменённых файлов: 10 добавлений и 3 удалений

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

@ -1,3 +1,9 @@
Mon Apr 21 19:12:20 2014 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (rb_str_coderange_scan_restartable): coderange is always
ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non
ASCII character.
Mon Apr 21 19:02:44 2014 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (coderange_scan): remove useless condtion `p < e` after

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

@ -304,7 +304,7 @@ coderange_scan(const char *p, long len, rb_encoding *enc)
{
const char *e = p + len;
if (rb_enc_to_index(enc) == 0) {
if (rb_enc_to_index(enc) == rb_ascii8bit_encindex()) {
/* enc is ASCII-8BIT. ASCII-8BIT string never be broken. */
p = search_nonascii(p, e);
return p ? ENC_CODERANGE_VALID : ENC_CODERANGE_7BIT;
@ -340,10 +340,11 @@ rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc
if (*cr == ENC_CODERANGE_BROKEN)
return e - s;
if (rb_enc_to_index(enc) == 0) {
if (rb_enc_to_index(enc) == rb_ascii8bit_encindex()) {
/* enc is ASCII-8BIT. ASCII-8BIT string never be broken. */
if (*cr == ENC_CODERANGE_VALID) return e - s;
p = search_nonascii(p, e);
*cr = (!p && *cr != ENC_CODERANGE_VALID) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
*cr = p ? ENC_CODERANGE_VALID : ENC_CODERANGE_7BIT;
return e - s;
}
else if (rb_enc_asciicompat(enc)) {