[macruby-changes] [3787] MacRuby/trunk/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 17 14:35:19 PDT 2010
Revision: 3787
http://trac.macosforge.org/projects/ruby/changeset/3787
Author: lsansonetti at apple.com
Date: 2010-03-17 14:35:16 -0700 (Wed, 17 Mar 2010)
Log Message:
-----------
fixed a couple of bugs in #gsub
Modified Paths:
--------------
MacRuby/trunk/string.c
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2010-03-17 18:35:16 UTC (rev 3786)
+++ MacRuby/trunk/string.c 2010-03-17 21:35:16 UTC (rev 3787)
@@ -3415,6 +3415,7 @@
long offset = 0, last = 0;
bool changed = false;
const long len = str_length(RSTR(str), false);
+ VALUE match = Qnil;
while (true) {
const long pos = rb_reg_search(pat, str, offset, false);
@@ -3429,7 +3430,7 @@
break;
}
- VALUE match = rb_backref_get();
+ match = rb_backref_get();
int count = 0;
rb_match_result_t *results = rb_reg_match_results(match, &count);
assert(count > 0);
@@ -3455,9 +3456,9 @@
val = rb_reg_regsub(repl, str, pat, results, count);
}
- if (pos - offset > 0) {
+ if (pos - last > 0) {
str_concat_string(RSTR(dest),
- RSTR(rstr_substr(str, offset, pos - offset)));
+ RSTR(rstr_substr(str, last, pos - last)));
}
str_concat_string(RSTR(dest), str_need_string(val));
@@ -3470,10 +3471,10 @@
if (results[0].beg == offset) {
offset++;
}
-
- rb_backref_set(match);
}
+ rb_backref_set(match);
+
if (bang) {
rstr_modify(str);
str_replace(RSTR(str), dest);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100317/3a67233f/attachment.html>
More information about the macruby-changes
mailing list