[MacRuby] #1012: Inconsistent Regex behaviour

MacRuby ruby-noreply at macosforge.org
Tue Nov 30 20:46:59 PST 2010


#1012: Inconsistent Regex behaviour
-------------------------------------------+--------------------------------
 Reporter:  harry@…                        |        Owner:  lsansonetti@…        
     Type:  defect                         |       Status:  reopened             
 Priority:  minor                          |    Milestone:                       
Component:  MacRuby                        |   Resolution:                       
 Keywords:                                 |  
-------------------------------------------+--------------------------------

Comment(by watson1978@…):

 I attach a patch:
 {{{
 #!diff

 diff --git a/re.c b/re.c
 index 22514a2..3ff54c7 100644
 --- a/re.c
 +++ b/re.c
 @@ -1829,7 +1829,18 @@ rb_reg_match_last(VALUE rcv)
         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);
  }

  /*
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1012#comment:14>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list