mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1397: pattern with \& following nothing gives an error
Problem: Pattern with \& following nothing gives an error.
Solution: Emit an empty node when needed.
890dd05492
This commit is contained in:
parent
3fd2efdb26
commit
cfb2383c26
@ -2131,7 +2131,6 @@ static int nfa_regconcat(void)
|
|||||||
*/
|
*/
|
||||||
static int nfa_regbranch(void)
|
static int nfa_regbranch(void)
|
||||||
{
|
{
|
||||||
int ch;
|
|
||||||
int old_post_pos;
|
int old_post_pos;
|
||||||
|
|
||||||
old_post_pos = (int)(post_ptr - post_start);
|
old_post_pos = (int)(post_ptr - post_start);
|
||||||
@ -2140,10 +2139,13 @@ static int nfa_regbranch(void)
|
|||||||
if (nfa_regconcat() == FAIL)
|
if (nfa_regconcat() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
ch = peekchr();
|
|
||||||
/* Try next concats */
|
/* Try next concats */
|
||||||
while (ch == Magic('&')) {
|
while (peekchr() == Magic('&')) {
|
||||||
skipchr();
|
skipchr();
|
||||||
|
// if concat is empty do emit a node
|
||||||
|
if (old_post_pos == (int)(post_ptr - post_start)) {
|
||||||
|
EMIT(NFA_EMPTY);
|
||||||
|
}
|
||||||
EMIT(NFA_NOPEN);
|
EMIT(NFA_NOPEN);
|
||||||
EMIT(NFA_PREV_ATOM_NO_WIDTH);
|
EMIT(NFA_PREV_ATOM_NO_WIDTH);
|
||||||
old_post_pos = (int)(post_ptr - post_start);
|
old_post_pos = (int)(post_ptr - post_start);
|
||||||
@ -2153,7 +2155,6 @@ static int nfa_regbranch(void)
|
|||||||
if (old_post_pos == (int)(post_ptr - post_start))
|
if (old_post_pos == (int)(post_ptr - post_start))
|
||||||
EMIT(NFA_EMPTY);
|
EMIT(NFA_EMPTY);
|
||||||
EMIT(NFA_CONCAT);
|
EMIT(NFA_CONCAT);
|
||||||
ch = peekchr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if a branch is empty, emit one node for it */
|
/* if a branch is empty, emit one node for it */
|
||||||
|
@ -472,3 +472,11 @@ endfunc
|
|||||||
func Test_search_undefined_behaviour2()
|
func Test_search_undefined_behaviour2()
|
||||||
call search("\%UC0000000")
|
call search("\%UC0000000")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was causing E874. Also causes an invalid read?
|
||||||
|
func Test_look_behind()
|
||||||
|
new
|
||||||
|
call setline(1, '0\|\&\n\@<=')
|
||||||
|
call search(getline("."))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user