@@ -672,7 +672,9 @@ fn op_min_repeat_one<S: StrDrive>(
672672 ctx. count = if min_count == 0 {
673673 0
674674 } else {
675- let count = _count ( req, state, ctx, min_count) ;
675+ let mut next_ctx = * ctx;
676+ next_ctx. skip_code ( 4 ) ;
677+ let count = _count ( req, state, next_ctx, min_count) ;
676678 if count < min_count {
677679 return ctx. failure ( ) ;
678680 }
@@ -713,7 +715,9 @@ fn op_min_repeat_one<S: StrDrive>(
713715
714716 state. string_position = ctx. string_position ;
715717
716- if _count ( req, state, ctx, 1 ) == 0 {
718+ let mut next_ctx = * ctx;
719+ next_ctx. skip_code ( 4 ) ;
720+ if _count ( req, state, next_ctx, 1 ) == 0 {
717721 state. marks . pop_discard ( ) ;
718722 return ctx. failure ( ) ;
719723 }
@@ -741,7 +745,9 @@ fn op_repeat_one<S: StrDrive>(req: &Request<S>, state: &mut State<S>, ctx: &mut
741745
742746 state. string_position = ctx. string_position ;
743747
744- let count = _count ( req, state, ctx, max_count) ;
748+ let mut next_ctx = * ctx;
749+ next_ctx. skip_code ( 4 ) ;
750+ let count = _count ( req, state, next_ctx, max_count) ;
745751 ctx. skip_char ( req, count) ;
746752 if count < min_count {
747753 return ctx. failure ( ) ;
@@ -1428,26 +1434,24 @@ fn charset(set: &[u32], ch: u32) -> bool {
14281434fn _count < S : StrDrive > (
14291435 req : & Request < S > ,
14301436 state : & mut State < S > ,
1431- ctx : & MatchContext < S > ,
1437+ mut ctx : MatchContext < S > ,
14321438 max_count : usize ,
14331439) -> usize {
1434- let mut ctx = * ctx;
14351440 let max_count = std:: cmp:: min ( max_count, ctx. remaining_chars ( req) ) ;
14361441 let end = ctx. string_position + max_count;
14371442 let opcode = SreOpcode :: try_from ( ctx. peek_code ( req, 0 ) ) . unwrap ( ) ;
14381443
14391444 match opcode {
14401445 SreOpcode :: ANY => {
1441- while ! ctx. string_position < end && !ctx. at_linebreak ( req) {
1446+ while ctx. string_position < end && !ctx. at_linebreak ( req) {
14421447 ctx. skip_char ( req, 1 ) ;
14431448 }
14441449 }
14451450 SreOpcode :: ANY_ALL => {
14461451 ctx. skip_char ( req, max_count) ;
14471452 }
14481453 SreOpcode :: IN => {
1449- while !ctx. string_position < end && charset ( & ctx. pattern ( req) [ 2 ..] , ctx. peek_char ( req) )
1450- {
1454+ while ctx. string_position < end && charset ( & ctx. pattern ( req) [ 2 ..] , ctx. peek_char ( req) ) {
14511455 ctx. skip_char ( req, 1 ) ;
14521456 }
14531457 }
@@ -1483,7 +1487,6 @@ fn _count<S: StrDrive>(
14831487 /* General case */
14841488 let mut count = 0 ;
14851489
1486- ctx. skip_code ( 4 ) ;
14871490 let reset_position = ctx. code_position ;
14881491
14891492 while count < max_count {
@@ -1511,7 +1514,7 @@ fn general_count_literal<S: StrDrive, F: FnMut(u32, u32) -> bool>(
15111514 mut f : F ,
15121515) {
15131516 let ch = ctx. peek_code ( req, 1 ) ;
1514- while ! ctx. string_position < end && f ( ch, ctx. peek_char ( req) ) {
1517+ while ctx. string_position < end && f ( ch, ctx. peek_char ( req) ) {
15151518 ctx. skip_char ( req, 1 ) ;
15161519 }
15171520}
0 commit comments