ruby-changes:5918
From: matz <ko1@a...>
Date: Thu, 19 Jun 2008 17:26:05 +0900 (JST)
Subject: [ruby-changes:5918] Ruby:r17426 (trunk): * string.c (rb_str_scan): String#scan should preserve last
matz 2008-06-19 17:25:50 +0900 (Thu, 19 Jun 2008) New Revision: 17426 Modified files: trunk/ChangeLog trunk/string.c Log: * string.c (rb_str_scan): String#scan should preserve last successful match data. [ruby-dev:35106] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=17426&r2=17425&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17426&r2=17425&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 17425) +++ ChangeLog (revision 17426) @@ -1,3 +1,8 @@ +Thu Jun 19 17:19:14 2008 Yukihiro Matsumoto <matz@r...> + + * 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@r...> * missing/acosh.c (atanh): should set ERANGE to errno if parameter Index: string.c =================================================================== --- string.c (revision 17425) +++ string.c (revision 17426) @@ -5689,7 +5689,7 @@ { 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 @@ 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/