1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

regex: fix #14370, last IST not managed in advance tests (#14372)

This commit is contained in:
penguindark 2022-05-12 10:49:57 +02:00 committed by GitHub
parent b7ca4c1668
commit e93a8766e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -1313,7 +1313,7 @@ fn (mut re RE) impl_compile(in_txt string) (int, int) {
pc1++ 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 { if last_bsls_char_pc >= 0 {
pc1 = last_bsls_char_pc + 1 pc1 = last_bsls_char_pc + 1
mut is_last_bsls := true 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 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 { && re.prog[state.pc].rep >= re.prog[state.pc].rep_min {
// load the char // load the char
// ch_t, _ := re.get_charb(in_txt, state.i+char_len) // 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 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 { && re.prog[state.pc].rep >= re.prog[state.pc].rep_min {
// load the char // load the char
// ch_t, _ := re.get_charb(in_txt, state.i+char_len) // 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 char_len: char_len
last_dot_pc: state.pc 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 { if re.prog[state.pc].rep_min == 0 {
dot_state.i -= char_len dot_state.i -= char_len
} }

View File

@ -165,6 +165,12 @@ match_test_suite = [
TestItem{"aba", r"a*(b*)*a",0,3}, TestItem{"aba", r"a*(b*)*a",0,3},
TestItem{"/*x*/", r"/\**(.*)\**/",0,5}, TestItem{"/*x*/", r"/\**(.*)\**/",0,5},
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},
] ]
) )