mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (reg_match_pos): adjust offset based on characters, not
bytes. [ruby-dev:38722] * string.c (rb_str_offset): new function. * string.c (rb_str_index_m): no call to rb_reg_adjust_startpos(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b472f9b61a
commit
5d7a215f6e
4 changed files with 19 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Tue Jun 30 17:44:24 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (reg_match_pos): adjust offset based on characters, not
|
||||||
|
bytes. [ruby-dev:38722]
|
||||||
|
|
||||||
|
* string.c (rb_str_offset): new function.
|
||||||
|
|
||||||
|
* string.c (rb_str_index_m): no call to rb_reg_adjust_startpos().
|
||||||
|
|
||||||
Tue Jun 30 16:57:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Jun 30 16:57:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* tool/rbinstall.rb: renamed to get rid of collision agains
|
* tool/rbinstall.rb: renamed to get rid of collision agains
|
||||||
|
|
|
@ -643,6 +643,7 @@ void rb_str_setter(VALUE, ID, VALUE*);
|
||||||
VALUE rb_str_intern(VALUE);
|
VALUE rb_str_intern(VALUE);
|
||||||
VALUE rb_sym_to_s(VALUE);
|
VALUE rb_sym_to_s(VALUE);
|
||||||
VALUE rb_str_length(VALUE);
|
VALUE rb_str_length(VALUE);
|
||||||
|
long rb_str_offset(VALUE, long);
|
||||||
size_t rb_str_capacity(VALUE);
|
size_t rb_str_capacity(VALUE);
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
#define rb_str_new_cstr(str) __extension__ ( \
|
#define rb_str_new_cstr(str) __extension__ ( \
|
||||||
|
|
2
re.c
2
re.c
|
@ -2564,7 +2564,7 @@ reg_match_pos(VALUE re, VALUE *strp, long pos)
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = rb_reg_adjust_startpos(re, str, pos, 0);
|
pos = rb_str_offset(str, pos);
|
||||||
}
|
}
|
||||||
return rb_reg_search(re, str, pos, 0);
|
return rb_reg_search(re, str, pos, 0);
|
||||||
}
|
}
|
||||||
|
|
11
string.c
11
string.c
|
@ -1440,6 +1440,13 @@ str_offset(const char *p, const char *e, long nth, rb_encoding *enc, int singleb
|
||||||
return pp - p;
|
return pp - p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
rb_str_offset(VALUE str, long pos)
|
||||||
|
{
|
||||||
|
return str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
|
||||||
|
STR_ENC_GET(str), single_byte_optimizable(str));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef NONASCII_MASK
|
#ifdef NONASCII_MASK
|
||||||
static char *
|
static char *
|
||||||
str_utf8_nth(const char *p, const char *e, long nth)
|
str_utf8_nth(const char *p, const char *e, long nth)
|
||||||
|
@ -2563,9 +2570,8 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
|
||||||
switch (TYPE(sub)) {
|
switch (TYPE(sub)) {
|
||||||
case T_REGEXP:
|
case T_REGEXP:
|
||||||
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
|
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
|
||||||
rb_enc_check(str, sub), single_byte_optimizable(str));
|
rb_enc_check(str, sub), single_byte_optimizable(str));
|
||||||
|
|
||||||
pos = rb_reg_adjust_startpos(sub, str, pos, 0);
|
|
||||||
pos = rb_reg_search(sub, str, pos, 0);
|
pos = rb_reg_search(sub, str, pos, 0);
|
||||||
pos = rb_str_sublen(str, pos);
|
pos = rb_str_sublen(str, pos);
|
||||||
break;
|
break;
|
||||||
|
@ -2680,7 +2686,6 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
|
||||||
STR_ENC_GET(str), single_byte_optimizable(str));
|
STR_ENC_GET(str), single_byte_optimizable(str));
|
||||||
|
|
||||||
if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
|
if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
|
||||||
pos = rb_reg_adjust_startpos(sub, str, pos, 1);
|
|
||||||
pos = rb_reg_search(sub, str, pos, 1);
|
pos = rb_reg_search(sub, str, pos, 1);
|
||||||
pos = rb_str_sublen(str, pos);
|
pos = rb_str_sublen(str, pos);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue