]> granicus.if.org Git - vim/commitdiff
patch 8.1.0945: internal error when using pattern with NL in the range v8.1.0945
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Feb 2019 19:17:02 +0000 (20:17 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Feb 2019 19:17:02 +0000 (20:17 +0100)
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)

src/regexp_nfa.c
src/testdir/test_regexp_latin.vim
src/version.c

index b83e309f7cb864a794e3db5c3874e59fc322084d..9633791bcf4f8c3003e4d9797ced0b02ea58b4ef 100644 (file)
@@ -245,7 +245,7 @@ static int nfa_classcodes[] = {
 
 static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely");
 static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
-static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %ld");
+static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d");
 
 // Variables only used in nfa_regcomp() and descendants.
 static int nfa_re_flags; // re_flags passed to nfa_regcomp()
@@ -1785,7 +1785,8 @@ collection:
                        MB_PTR_ADV(regparse);
 
                        if (*regparse == 'n')
-                           startc = reg_string ? NL : NFA_NEWL;
+                           startc = (reg_string || emit_range
+                                       || regparse[1] == '-') ? NL : NFA_NEWL;
                        else
                            if  (*regparse == 'd'
                                    || *regparse == 'o'
index d30312a11e2580477c232db87a3404f59502d770..d603acdbcef7d2838abf2607219bf8ce6c28b069 100644 (file)
@@ -122,3 +122,11 @@ func Test_rex_init()
   bwipe!
   set re=0
 endfunc
+
+func Test_range_with_newline()
+  new
+  call setline(1, "a")
+  call assert_equal(0, search("[ -*\\n- ]"))
+  call assert_equal(0, search("[ -*\\t-\\n]"))
+  bwipe!
+endfunc
index b3244c168b40c4aa20d7e8e122d438a9c789a611..0d44663a2e7eda1a3567505442e17f0e0350e1b7 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    945,
 /**/
     944,
 /**/