Skip to content

Commit

Permalink
Use ascii_only_p() instead of ascii_only_
Browse files Browse the repository at this point in the history
ascii_only_ does not usually have a correct value, so we ascii_only_p()
to make sure it does.

Related to #3531
  • Loading branch information
ahmadsherif committed Feb 15, 2016
1 parent 9765ca9 commit cdc89a9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vm/builtin/string.cpp
Expand Up @@ -602,7 +602,7 @@ namespace rubinius {
native_int String::char_size(STATE) {
if(num_chars_->nil_p()) {
OnigEncodingType* enc = encoding(state)->get_encoding();
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
num_chars(state, num_bytes_);
} else if(fixed_width_p(encoding_)) {
num_chars(state, Fixnum::from((byte_size() + ONIGENC_MBC_MINLEN(enc) - 1) / ONIGENC_MBC_MINLEN(enc)));
Expand Down Expand Up @@ -1337,7 +1337,7 @@ namespace rubinius {
if(i >= byte_size() || i < 0) return cNil;

native_int len = char_size(state);
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
return byte_substring(state, i, 1);
} else {
// Assumptions above about size are possibly invalid, recalculate.
Expand All @@ -1355,7 +1355,7 @@ namespace rubinius {
native_int String::find_character_byte_index(STATE, native_int index,
native_int start) {
OnigEncodingType* enc = encoding(state)->get_encoding();
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
return start + index;
} else if(fixed_width_p(encoding_)) {
return start + index * ONIGENC_MBC_MINLEN(enc);
Expand Down Expand Up @@ -1391,7 +1391,7 @@ namespace rubinius {
native_int String::find_byte_character_index(STATE, native_int index,
native_int start) {
OnigEncodingType* enc = encoding(state)->get_encoding();
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
return index;
} else if(fixed_width_p(encoding_)) {
return index / ONIGENC_MBC_MINLEN(enc);
Expand Down Expand Up @@ -1500,7 +1500,7 @@ namespace rubinius {
n = size - i;
}

if(n == 0 || byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
if(n == 0 || byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
return byte_substring(state, i, n);
} else {
return char_substring(state, i, n);
Expand Down Expand Up @@ -1564,7 +1564,7 @@ namespace rubinius {
uint8_t* s;
uint8_t* ss;

if(byte_compatible_p(encoding()) || CBOOL(ascii_only_)) {
if(byte_compatible_p(encoding()) || CBOOL(ascii_only_p(state))) {
for(s = p += offset, ss = pp; p < e; s = ++p) {
if(*p != *pp) continue;

Expand Down

0 comments on commit cdc89a9

Please sign in to comment.