зеркало из https://github.com/github/ruby.git
* string.c (rb_str_scan): String#scan should preserve last
successful match data. [ruby-dev:35106] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
363b0bddde
Коммит
768380583a
|
@ -1,3 +1,8 @@
|
|||
Thu Jun 19 17:19:14 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_scan): String#scan should preserve last
|
||||
successful match data. [ruby-dev:35106]
|
||||
|
||||
Thu Jun 19 16:49:36 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* missing/acosh.c (atanh): should set ERANGE to errno if parameter
|
||||
|
|
11
string.c
11
string.c
|
@ -5689,7 +5689,7 @@ rb_str_scan(VALUE str, VALUE pat)
|
|||
{
|
||||
VALUE result;
|
||||
long start = 0;
|
||||
VALUE match = Qnil;
|
||||
long last = -1, prev = 0;
|
||||
char *p = RSTRING_PTR(str); long len = RSTRING_LEN(str);
|
||||
|
||||
pat = get_pat(pat, 1);
|
||||
|
@ -5697,18 +5697,21 @@ rb_str_scan(VALUE str, VALUE pat)
|
|||
VALUE ary = rb_ary_new();
|
||||
|
||||
while (!NIL_P(result = scan_once(str, pat, &start))) {
|
||||
match = rb_backref_get();
|
||||
last = prev;
|
||||
prev = start;
|
||||
rb_ary_push(ary, result);
|
||||
}
|
||||
rb_backref_set(match);
|
||||
if (last >= 0) rb_reg_search(pat, str, last, 0);
|
||||
return ary;
|
||||
}
|
||||
|
||||
while (!NIL_P(result = scan_once(str, pat, &start))) {
|
||||
last = prev;
|
||||
prev = start;
|
||||
rb_yield(result);
|
||||
str_mod_check(str, p, len);
|
||||
}
|
||||
rb_backref_set(match);
|
||||
if (last >= 0) rb_reg_search(pat, str, last, 0);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче