ruby-changes:12230
From: matz <ko1@a...>
Date: Tue, 30 Jun 2009 18:07:21 +0900 (JST)
Subject: [ruby-changes:12230] Ruby:r23916 (trunk): * re.c (reg_match_pos): adjust offset based on characters, not
matz 2009-06-30 18:06:48 +0900 (Tue, 30 Jun 2009) New Revision: 23916 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23916 Log: * 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(). Modified files: trunk/ChangeLog trunk/include/ruby/intern.h trunk/re.c trunk/string.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 23915) +++ include/ruby/intern.h (revision 23916) @@ -643,6 +643,7 @@ VALUE rb_str_intern(VALUE); VALUE rb_sym_to_s(VALUE); VALUE rb_str_length(VALUE); +long rb_str_offset(VALUE, long); size_t rb_str_capacity(VALUE); #if defined __GNUC__ #define rb_str_new_cstr(str) __extension__ ( \ Index: ChangeLog =================================================================== --- ChangeLog (revision 23915) +++ ChangeLog (revision 23916) @@ -1,3 +1,12 @@ +Tue Jun 30 17:44:24 2009 Yukihiro Matsumoto <matz@r...> + + * 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@r...> * tool/rbinstall.rb: renamed to get rid of collision agains Index: re.c =================================================================== --- re.c (revision 23915) +++ re.c (revision 23916) @@ -2564,7 +2564,7 @@ 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); } Index: string.c =================================================================== --- string.c (revision 23915) +++ string.c (revision 23916) @@ -1440,6 +1440,13 @@ 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 static char * str_utf8_nth(const char *p, const char *e, long nth) @@ -2563,9 +2570,8 @@ switch (TYPE(sub)) { case T_REGEXP: 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_str_sublen(str, pos); break; @@ -2680,7 +2686,6 @@ STR_ENC_GET(str), single_byte_optimizable(str)); 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_str_sublen(str, pos); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/