@@ -537,7 +537,11 @@ sub print_matches_in_resource {
537537 while ( $contents =~ / $opt_regex /og ) {
538538 my $match_start = $- [0];
539539 my $match_end = $+ [0];
540- next if $match_start == $match_end ;
540+ next if $match_start == $match_end ; # continue to the next line
541+ # if we match nothing, since
542+ # some regexes allow this
543+ # and would throw us into
544+ # an infinite loop
541545
542546 pos ($contents ) = $prev_match_end ;
543547 $prev_match_end = $match_end ;
@@ -641,7 +645,9 @@ sub print_line_with_options {
641645 my $offset = 0; # additional offset for when we add stuff
642646 my $previous_match_end = 0;
643647
644- last if $- [0] == $+ [0];
648+ last if $- [0] == $+ [0]; # stop highlighting if we've hit an
649+ # empty match, since continuing would
650+ # result in an infinite loop
645651
646652 for ( my $i = 1; $i < @+; $i ++ ) {
647653 my ( $match_start , $match_end ) = ( $- [$i ], $+ [$i ] );
@@ -672,7 +678,9 @@ sub print_line_with_options {
672678 $matched = 1;
673679 my ( $match_start , $match_end ) = ($- [0], $+ [0]);
674680 next unless defined ($match_start );
675- last if $match_start == $match_end ;
681+ last if $match_start == $match_end ; # stop highlighting if we've hit an
682+ # empty match, since continuing would
683+ # result in an infinite loop
676684
677685 my $substring = substr ( $line , $match_start ,
678686 $match_end - $match_start );
0 commit comments