From df645bf79c00f5014e09d123f1f768fdab4b8110 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 21 Apr 2014 10:15:54 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 ++++++ string.c | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7fd673de1..064f4e6dad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Apr 21 19:12:20 2014 NARUSE, Yui + + * 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 * string.c (coderange_scan): remove useless condtion `p < e` after diff --git a/string.c b/string.c index 79ac7aeecc..c589c80d2e 100644 --- a/string.c +++ b/string.c @@ -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)) {