Patch 8.2.2121
Problem: Internal error when using \ze before \zs in a pattern.
Solution: Check the end is never before the start. (closes #7442)
Files: src/regexp_bt.c, src/regexp_nfa.c,
src/testdir/test_regexp_latin.vim
*** ../vim-8.2.2120/src/regexp_bt.c 2020-09-07 18:53:18.387974569 +0200
--- src/regexp_bt.c 2020-12-09 16:26:47.386616233 +0100
***************
*** 4805,4810 ****
--- 4805,4827 ----
if (backpos.ga_maxlen > BACKPOS_INITIAL)
ga_clear(&backpos);
+ // Make sure the end is never before the start. Can happen when \zs and
+ // \ze are used.
+ if (REG_MULTI)
+ {
+ lpos_T *start = &rex.reg_mmatch->startpos[0];
+ lpos_T *end = &rex.reg_mmatch->endpos[0];
+
+ if (end->lnum < start->lnum
+ || (end->lnum == start->lnum && end->col < start->col))
+ rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
+ }
+ else
+ {
+ if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
+ rex.reg_match->endp[0] = rex.reg_match->startp[0];
+ }
+
return retval;
}
*** ../vim-8.2.2120/src/regexp_nfa.c 2020-09-07 18:53:18.387974569 +0200
--- src/regexp_nfa.c 2020-12-09 16:34:22.081015144 +0100
***************
*** 7225,7230 ****
--- 7225,7247 ----
#endif
theend:
+ // Make sure the end is never before the start. Can happen when \zs and
+ // \ze are used.
+ if (REG_MULTI)
+ {
+ lpos_T *start = &rex.reg_mmatch->startpos[0];
+ lpos_T *end = &rex.reg_mmatch->endpos[0];
+
+ if (end->lnum < start->lnum
+ || (end->lnum == start->lnum && end->col < start->col))
+ rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
+ }
+ else
+ {
+ if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
+ rex.reg_match->endp[0] = rex.reg_match->startp[0];
+ }
+
return retval;
}
*** ../vim-8.2.2120/src/testdir/test_regexp_latin.vim 2020-08-12
18:50:31.883655785 +0200
--- src/testdir/test_regexp_latin.vim 2020-12-09 16:33:42.177156325 +0100
***************
*** 911,916 ****
--- 911,923 ----
bwipe!
endfunc
+ func Test_ze_before_zs()
+ call assert_equal('', matchstr(' ', '\%#=1\ze \zs'))
+ call assert_equal('', matchstr(' ', '\%#=2\ze \zs'))
+ call assert_equal(repeat([''], 10), matchlist(' ', '\%#=1\ze \zs'))
+ call assert_equal(repeat([''], 10), matchlist(' ', '\%#=2\ze \zs'))
+ endfunc
+
" Check for detecting error
func Test_regexp_error()
call assert_fails("call matchlist('x x', '\\%#=1 \\zs*')", 'E888:')
*** ../vim-8.2.2120/src/version.c 2020-12-09 16:05:42.450846581 +0100
--- src/version.c 2020-12-09 16:28:12.922316150 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2121,
/**/
--
Dogs must have a permit signed by the mayor in order to congregate in groups
of three or more on private property.
[real standing law in Oklahoma, United States of America]
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202012091536.0B9FaWu71945109%40masaka.moolenaar.net.