[macruby-changes] [3656] MacRuby/branches/icu/string.c

source_changes at macosforge.org source_changes at macosforge.org
Sat Feb 27 22:33:43 PST 2010


Revision: 3656
          http://trac.macosforge.org/projects/ruby/changeset/3656
Author:   lsansonetti at apple.com
Date:     2010-02-27 22:33:40 -0800 (Sat, 27 Feb 2010)
Log Message:
-----------
fixing a couple of bugs in #gsub and #scan

Modified Paths:
--------------
    MacRuby/branches/icu/string.c

Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c	2010-02-28 06:06:58 UTC (rev 3655)
+++ MacRuby/branches/icu/string.c	2010-02-28 06:33:40 UTC (rev 3656)
@@ -2278,8 +2278,14 @@
 	int count = 0;
 	rb_match_result_t *results = rb_reg_match_results(match, &count);
 	assert(count > 0);
-	start = results[0].end;
 
+	if (results[0].beg == results[0].end) {
+	    start = results[0].end + 1;
+	}
+	else {
+	    start = results[0].end;
+	}
+
 	VALUE scan_result;
 	if (count == 1) {
 	    scan_result = rb_reg_nth_match(0, match);
@@ -2825,8 +2831,10 @@
 	    if (!changed) {
 		return bang ? Qnil : rstr_dup(str, 0);
 	    }
-	    str_concat_string(RSTR(dest),
-		    RSTR(rstr_substr(str, offset, len - offset)));
+	    if (offset < len) {
+		str_concat_string(RSTR(dest),
+			RSTR(rstr_substr(str, offset, len - offset)));
+	    }
 	    break;
 	}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100227/af472beb/attachment.html>


More information about the macruby-changes mailing list