[macruby-changes] [4962] MacRuby/trunk/re.c

source_changes at macosforge.org source_changes at macosforge.org
Tue Nov 30 21:56:01 PST 2010


Revision: 4962
          http://trac.macosforge.org/projects/ruby/changeset/4962
Author:   watson1978 at gmail.com
Date:     2010-11-30 21:55:58 -0800 (Tue, 30 Nov 2010)
Log Message:
-----------
fixed the bug of Kernel$$+. see #1012.

Modified Paths:
--------------
    MacRuby/trunk/re.c

Modified: MacRuby/trunk/re.c
===================================================================
--- MacRuby/trunk/re.c	2010-12-01 04:02:59 UTC (rev 4961)
+++ MacRuby/trunk/re.c	2010-12-01 05:55:58 UTC (rev 4962)
@@ -1829,7 +1829,18 @@
 	return Qnil;
     }
     assert(RMATCH(rcv)->results_count > 0);
-    return rb_reg_nth_match(RMATCH(rcv)->results_count - 1, rcv);
+
+    int nth = RMATCH(rcv)->results_count - 1;
+    while(nth > 0) {
+	if (RMATCH(rcv)->results[nth].beg != -1) {
+	    break;
+	}
+	nth--;
+    }
+    if (nth == 0) {
+	return Qnil;
+    }
+    return rb_reg_nth_match(nth, rcv);
 }
 
 /*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101130/836dd6af/attachment.html>


More information about the macruby-changes mailing list