File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -358,6 +358,8 @@ static char_u *regprop(char_u *);
358358static int re_mult_next (char * what );
359359
360360static char_u e_missingbracket [] = N_ ("E769: Missing ] after %s[" );
361+ static char_u e_reverse_range [] = N_ ("E944: Reverse range in character class" );
362+ static char_u e_large_class [] = N_ ("E945: Range too large in character class" );
361363static char_u e_unmatchedpp [] = N_ ("E53: Unmatched %s%%(" );
362364static char_u e_unmatchedp [] = N_ ("E54: Unmatched %s(" );
363365static char_u e_unmatchedpar [] = N_ ("E55: Unmatched %s)" );
@@ -2426,14 +2428,14 @@ regatom(int *flagp)
24262428 endc = coll_get_char ();
24272429
24282430 if (startc > endc )
2429- EMSG_RET_NULL (_ (e_invrange ));
2431+ EMSG_RET_NULL (_ (e_reverse_range ));
24302432#ifdef FEAT_MBYTE
24312433 if (has_mbyte && ((* mb_char2len )(startc ) > 1
24322434 || (* mb_char2len )(endc ) > 1 ))
24332435 {
2434- /* Limit to a range of 256 chars */
2436+ /* Limit to a range of 256 chars. */
24352437 if (endc > startc + 256 )
2436- EMSG_RET_NULL (_ (e_invrange ));
2438+ EMSG_RET_NULL (_ (e_large_class ));
24372439 while (++ startc <= endc )
24382440 regmbc (startc );
24392441 }
Original file line number Diff line number Diff line change @@ -1853,7 +1853,7 @@ nfa_regatom(void)
18531853 endc = startc ;
18541854 startc = oldstartc ;
18551855 if (startc > endc )
1856- EMSG_RET_FAIL (_ (e_invrange ));
1856+ EMSG_RET_FAIL (_ (e_reverse_range ));
18571857
18581858 if (endc > startc + 2 )
18591859 {
Original file line number Diff line number Diff line change @@ -137,3 +137,20 @@ func Test_classes_re2()
137137 call s: classes_test ()
138138 set re = 0
139139endfunc
140+
141+ func Test_reversed_range ()
142+ for re in range (0 , 2 )
143+ exe ' set re=' . re
144+ call assert_fails (' call match("abc def", "[c-a]")' , ' E944:' )
145+ endfor
146+ set re = 0
147+ endfunc
148+
149+ func Test_large_class ()
150+ set re = 1
151+ call assert_fails (' call match("abc def", "[\u3000-\u4000]")' , ' E945:' )
152+ set re = 2
153+ call assert_equal (0 , ' abc def' = ~# ' [\u3000-\u4000]' )
154+ call assert_equal (1 , " \u3042 " = ~# ' [\u3000-\u4000]' )
155+ set re = 0
156+ endfunc
Original file line number Diff line number Diff line change @@ -764,6 +764,8 @@ static char *(features[]) =
764764
765765static int included_patches [] =
766766{ /* Add new patch number below this line */
767+ /**/
768+ 623 ,
767769/**/
768770 622 ,
769771/**/
You can’t perform that action at this time.
0 commit comments