Skip to content

Commit

Permalink
* encoding.c (rb_enc_compatible): ASCII compatible string and US-ASCII
Browse files Browse the repository at this point in the history
  regexp is compatible. [ruby-dev:36033]

* string.c (rb_str_index_m): second argument is position of character.
  by usa. [ruby-dev:36033]

* string.c (rb_str_rindex_m): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Aug 29, 2008
1 parent d2d3717 commit 7fc16c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Fri Aug 29 11:04:03 2008 NARUSE, Yui <naruse@ruby-lang.org>

* encoding.c (rb_enc_compatible): ASCII compatible string and US-ASCII
regexp is compatible. [ruby-dev:36033]

* string.c (rb_str_index_m): second argument is position of character.
by usa. [ruby-dev:36033]

* string.c (rb_str_rindex_m): ditto.

Fri Aug 29 04:47:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>

* win32/win32.c (rb_w32_read, rb_w32_write): more accurate handling
Expand Down
6 changes: 5 additions & 1 deletion encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ rb_enc_compatible(VALUE str1, VALUE str2)
if (!rb_enc_asciicompat(enc1) || !rb_enc_asciicompat(enc2)) {
return 0;
}
if (BUILTIN_TYPE(str2) == T_REGEXP && idx2 == ENCINDEX_US_ASCII)
return enc1;
if (BUILTIN_TYPE(str1) == T_REGEXP && idx1 == ENCINDEX_US_ASCII)
return enc2;

if (BUILTIN_TYPE(str1) != T_STRING) {
VALUE tmp = str1;
Expand All @@ -652,7 +656,7 @@ rb_enc_compatible(VALUE str1, VALUE str2)
if (cr2 == ENC_CODERANGE_7BIT) return enc1;
}
if (cr2 == ENC_CODERANGE_7BIT) {
if (idx1 == 0) return enc2;
if (idx1 == ENCINDEX_ASCII) return enc2;
return enc1;
}
}
Expand Down
6 changes: 6 additions & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,9 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
}
}

pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
rb_enc_check(str, sub), single_byte_optimizable(str));

switch (TYPE(sub)) {
case T_REGEXP:
pos = rb_reg_adjust_startpos(sub, str, pos, 0);
Expand Down Expand Up @@ -2277,6 +2280,9 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
pos = len;
}

pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
rb_enc_check(str, sub), single_byte_optimizable(str));

switch (TYPE(sub)) {
case T_REGEXP:
/* enc = rb_get_check(str, sub); */
Expand Down

0 comments on commit 7fc16c2

Please sign in to comment.