From e93a8766e520e01b5a00d7863bd6427f87c2ce66 Mon Sep 17 00:00:00 2001 From: penguindark <57967770+penguindark@users.noreply.github.com> Date: Thu, 12 May 2022 10:49:57 +0200 Subject: [PATCH] regex: fix #14370, last IST not managed in advance tests (#14372) --- vlib/regex/regex.v | 8 ++++---- vlib/regex/regex_test.v | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index 53683165ae..bd63736c8e 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -1313,7 +1313,7 @@ fn (mut re RE) impl_compile(in_txt string) (int, int) { pc1++ } - // println("last_bsls_char_pc: $last_bsls_char_pc") + // println('last_bsls_char_pc: $last_bsls_char_pc') if last_bsls_char_pc >= 0 { pc1 = last_bsls_char_pc + 1 mut is_last_bsls := true @@ -2063,7 +2063,7 @@ pub fn (mut re RE) match_base(in_txt &u8, in_txt_len int) (int, int) { continue } - if re.prog[state.pc].dot_check_pc >= 0 + if re.prog[state.pc].last_dot_flag == false && re.prog[state.pc].dot_check_pc >= 0 && re.prog[state.pc].rep >= re.prog[state.pc].rep_min { // load the char // ch_t, _ := re.get_charb(in_txt, state.i+char_len) @@ -2183,7 +2183,7 @@ pub fn (mut re RE) match_base(in_txt &u8, in_txt_len int) (int, int) { continue } - if re.prog[state.pc].bsls_check_pc >= 0 + if re.prog[state.pc].last_dot_flag == false && re.prog[state.pc].bsls_check_pc >= 0 && re.prog[state.pc].rep >= re.prog[state.pc].rep_min { // load the char // ch_t, _ := re.get_charb(in_txt, state.i+char_len) @@ -2232,7 +2232,7 @@ pub fn (mut re RE) match_base(in_txt &u8, in_txt_len int) (int, int) { char_len: char_len last_dot_pc: state.pc } - // if we are mananging a .* stay on the same char on return + // if we are managing a \[something]* stay on the same char on return if re.prog[state.pc].rep_min == 0 { dot_state.i -= char_len } diff --git a/vlib/regex/regex_test.v b/vlib/regex/regex_test.v index 400362e796..bc38ffad67 100644 --- a/vlib/regex/regex_test.v +++ b/vlib/regex/regex_test.v @@ -165,6 +165,12 @@ match_test_suite = [ TestItem{"aba", r"a*(b*)*a",0,3}, TestItem{"/*x*/", r"/\**(.*)\**/",0,5}, TestItem{"/*x*/", r"/*(.*)*/",0,5}, + + // test last IST check + TestItem{"refs/remotes/origin/mastep", r"refs/remotes/origin/(.*)",0,26}, + TestItem{"refs/remotes/origin/master", r"refs/remotes/origin/(.*)",0,26}, + TestItem{"refs/remotes/origin/mastep", r"refs/remotes/origin/(\w*)",0,26}, + TestItem{"refs/remotes/origin/master", r"refs/remotes/origin/(\w*)",0,26}, ] )