Skip to content

Commit a548344

Browse files
committed
patch 8.1.0945: internal error when using pattern with NL in the range
Problem: Internal error when using pattern with NL in the range. Solution: Use an actual newline for the range. (closes #3989) Also fix error message. (Dominique Pelle)
1 parent c85c8fc commit a548344

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/regexp_nfa.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static int nfa_classcodes[] = {
245245

246246
static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely");
247247
static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
248-
static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %ld");
248+
static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d");
249249

250250
// Variables only used in nfa_regcomp() and descendants.
251251
static int nfa_re_flags; // re_flags passed to nfa_regcomp()
@@ -1785,7 +1785,8 @@ nfa_regatom(void)
17851785
MB_PTR_ADV(regparse);
17861786

17871787
if (*regparse == 'n')
1788-
startc = reg_string ? NL : NFA_NEWL;
1788+
startc = (reg_string || emit_range
1789+
|| regparse[1] == '-') ? NL : NFA_NEWL;
17891790
else
17901791
if (*regparse == 'd'
17911792
|| *regparse == 'o'

src/testdir/test_regexp_latin.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,11 @@ func Test_rex_init()
122122
bwipe!
123123
set re=0
124124
endfunc
125+
126+
func Test_range_with_newline()
127+
new
128+
call setline(1, "a")
129+
call assert_equal(0, search("[ -*\\n- ]"))
130+
call assert_equal(0, search("[ -*\\t-\\n]"))
131+
bwipe!
132+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
945,
782784
/**/
783785
944,
784786
/**/

0 commit comments

Comments
 (0)