summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-09 01:38:33 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-09 16:21:02 +0900
commite2257831ab20915b839eeaff79c6ec45b498de77 (patch)
tree5b6f516ef614b00751328c81fc50f1b03a7515f9 /string.c
parent4e2f98be3907b85c6f470c41e7c00f53653b6e68 (diff)
[Bug #19763] Raise same message exception for regexp
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8045
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/string.c b/string.c
index 849f526c43..1f564f9661 100644
--- a/string.c
+++ b/string.c
@@ -3861,6 +3861,7 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
{
VALUE sub;
VALUE initpos;
+ rb_encoding *enc = STR_ENC_GET(str);
long pos;
if (rb_scan_args(argc, argv, "11", &sub, &initpos) == 2) {
@@ -3885,7 +3886,7 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
return Qnil;
}
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
- rb_enc_check(str, sub), single_byte_optimizable(str));
+ enc, single_byte_optimizable(str));
if (rb_reg_search(sub, str, pos, 0) < 0) {
return Qnil;
@@ -4182,7 +4183,7 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
}
if (RB_TYPE_P(sub, T_REGEXP)) {
- /* enc = rb_get_check(str, sub); */
+ /* enc = rb_enc_check(str, sub); */
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
enc, single_byte_optimizable(str));