Skip to content

Commit cdc89a9

Browse files
committed
Use ascii_only_p() instead of ascii_only_
ascii_only_ does not usually have a correct value, so we ascii_only_p() to make sure it does. Related to #3531
1 parent 9765ca9 commit cdc89a9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

vm/builtin/string.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ namespace rubinius {
602602
native_int String::char_size(STATE) {
603603
if(num_chars_->nil_p()) {
604604
OnigEncodingType* enc = encoding(state)->get_encoding();
605-
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
605+
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
606606
num_chars(state, num_bytes_);
607607
} else if(fixed_width_p(encoding_)) {
608608
num_chars(state, Fixnum::from((byte_size() + ONIGENC_MBC_MINLEN(enc) - 1) / ONIGENC_MBC_MINLEN(enc)));
@@ -1337,7 +1337,7 @@ namespace rubinius {
13371337
if(i >= byte_size() || i < 0) return cNil;
13381338

13391339
native_int len = char_size(state);
1340-
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
1340+
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
13411341
return byte_substring(state, i, 1);
13421342
} else {
13431343
// Assumptions above about size are possibly invalid, recalculate.
@@ -1355,7 +1355,7 @@ namespace rubinius {
13551355
native_int String::find_character_byte_index(STATE, native_int index,
13561356
native_int start) {
13571357
OnigEncodingType* enc = encoding(state)->get_encoding();
1358-
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
1358+
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
13591359
return start + index;
13601360
} else if(fixed_width_p(encoding_)) {
13611361
return start + index * ONIGENC_MBC_MINLEN(enc);
@@ -1391,7 +1391,7 @@ namespace rubinius {
13911391
native_int String::find_byte_character_index(STATE, native_int index,
13921392
native_int start) {
13931393
OnigEncodingType* enc = encoding(state)->get_encoding();
1394-
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
1394+
if(byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
13951395
return index;
13961396
} else if(fixed_width_p(encoding_)) {
13971397
return index / ONIGENC_MBC_MINLEN(enc);
@@ -1500,7 +1500,7 @@ namespace rubinius {
15001500
n = size - i;
15011501
}
15021502

1503-
if(n == 0 || byte_compatible_p(encoding_) || CBOOL(ascii_only_)) {
1503+
if(n == 0 || byte_compatible_p(encoding_) || CBOOL(ascii_only_p(state))) {
15041504
return byte_substring(state, i, n);
15051505
} else {
15061506
return char_substring(state, i, n);
@@ -1564,7 +1564,7 @@ namespace rubinius {
15641564
uint8_t* s;
15651565
uint8_t* ss;
15661566

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

0 commit comments

Comments
 (0)