@@ -46,7 +46,7 @@ use std::fmt;
46
46
use std:: mem;
47
47
48
48
use exec:: Search ;
49
- use prog:: Program ;
49
+ use prog:: { Inst , Program } ;
50
50
use sparse:: SparseSet ;
51
51
52
52
/// The cache limit specifies approximately how much space we're willing to
@@ -465,7 +465,6 @@ impl<'a, 'b, 'c, 'm> Dfa<'a, 'b, 'c, 'm> {
465
465
}
466
466
self . at += 1 ;
467
467
}
468
- // println!("exiting loop at input {:?}", self.at);
469
468
// Run the DFA once more on the special EOF senitnel value.
470
469
si = match self . next_state ( qcur, qnext, si, Byte :: eof ( ) ) {
471
470
None => return DfaResult :: Quit ,
@@ -482,6 +481,13 @@ impl<'a, 'b, 'c, 'm> Dfa<'a, 'b, 'c, 'm> {
482
481
result = DfaResult :: Match ;
483
482
self . search . set_end ( Some ( text. len ( ) ) ) ;
484
483
}
484
+ if result. is_match ( ) && !self . search . find_one_match ( ) {
485
+ for & ip in & self . states [ si as usize ] . insts {
486
+ if let Inst :: Match ( slot) = self . prog [ ip as usize ] {
487
+ self . search . set_match ( slot) ;
488
+ }
489
+ }
490
+ }
485
491
result
486
492
}
487
493
@@ -622,16 +628,16 @@ impl<'a, 'b, 'c, 'm> Dfa<'a, 'b, 'c, 'm> {
622
628
Char ( _) | Ranges ( _) => unreachable ! ( ) ,
623
629
// These states are handled when following epsilon transitions.
624
630
Save ( _) | Split ( _) | EmptyLook ( _) => { }
625
- Match ( slot ) => {
631
+ Match ( _ ) => {
626
632
is_match = true ;
627
633
if !self . continue_past_first_match ( ) {
628
634
break ;
629
- } else if !self . search . find_one_match ( )
630
- && !self . search . has_match ( slot)
631
- && !qnext. contains_ip ( ip as usize ) {
635
+ } else if !self . search . find_one_match ( ) {
632
636
// If we are continuing on to find other matches,
633
637
// then keep a record of the match states we've seen.
634
- qnext. add ( ip) ;
638
+ if !qnext. contains_ip ( ip as usize ) {
639
+ qnext. add ( ip) ;
640
+ }
635
641
}
636
642
}
637
643
Bytes ( ref inst) => {
@@ -870,9 +876,8 @@ impl<'a, 'b, 'c, 'm> Dfa<'a, 'b, 'c, 'm> {
870
876
| NotWordBoundaryAscii => unreachable ! ( ) ,
871
877
}
872
878
}
873
- Match ( slot ) => {
879
+ Match ( _ ) => {
874
880
insts. push ( ip) ;
875
- self . search . set_match ( slot) ;
876
881
if !self . continue_past_first_match ( ) {
877
882
break ;
878
883
}
0 commit comments