mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
9f2ddef227
commit
df645bf79c
2 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
|
7
string.c
7
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)) {
|
||||
|
|
Loading…
Reference in a new issue