Merge #8479 from janlazo/vim-8.0.0529

This commit is contained in:
Justin M. Keyes 2018-06-05 08:43:01 +02:00 committed by GitHub
commit ae927a49f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 12 deletions

View File

@ -479,6 +479,8 @@ static char_u *regprop(char_u *);
#endif #endif
static char_u e_missingbracket[] = N_("E769: Missing ] after %s["); static char_u e_missingbracket[] = N_("E769: Missing ] after %s[");
static char_u e_reverse_range[] = N_("E944: Reverse range in character class");
static char_u e_large_class[] = N_("E945: Range too large in character class");
static char_u e_unmatchedpp[] = N_("E53: Unmatched %s%%("); static char_u e_unmatchedpp[] = N_("E53: Unmatched %s%%(");
static char_u e_unmatchedp[] = N_("E54: Unmatched %s("); static char_u e_unmatchedp[] = N_("E54: Unmatched %s(");
static char_u e_unmatchedpar[] = N_("E55: Unmatched %s)"); static char_u e_unmatchedpar[] = N_("E55: Unmatched %s)");
@ -2232,15 +2234,18 @@ collection:
if (endc == '\\' && !reg_cpo_lit) if (endc == '\\' && !reg_cpo_lit)
endc = coll_get_char(); endc = coll_get_char();
if (startc > endc) if (startc > endc) {
EMSG_RET_NULL(_(e_invrange)); EMSG_RET_NULL(_(e_reverse_range));
}
if (has_mbyte && ((*mb_char2len)(startc) > 1 if (has_mbyte && ((*mb_char2len)(startc) > 1
|| (*mb_char2len)(endc) > 1)) { || (*mb_char2len)(endc) > 1)) {
/* Limit to a range of 256 chars */ // Limit to a range of 256 chars
if (endc > startc + 256) if (endc > startc + 256) {
EMSG_RET_NULL(_(e_invrange)); EMSG_RET_NULL(_(e_large_class));
while (++startc <= endc) }
while (++startc <= endc) {
regmbc(startc); regmbc(startc);
}
} else { } else {
while (++startc <= endc) while (++startc <= endc)
regc(startc); regc(startc);

View File

@ -1711,8 +1711,9 @@ collection:
if (emit_range) { if (emit_range) {
endc = startc; endc = startc;
startc = oldstartc; startc = oldstartc;
if (startc > endc) if (startc > endc) {
EMSG_RET_FAIL(_(e_invrange)); EMSG_RET_FAIL(_(e_reverse_range));
}
if (endc > startc + 2) { if (endc > startc + 2) {
/* Emit a range instead of the sequence of /* Emit a range instead of the sequence of

View File

@ -109,12 +109,10 @@ func s:classes_test()
call assert_equal('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alnumchars) call assert_equal('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alnumchars)
call assert_equal("\b", backspacechar) call assert_equal("\b", backspacechar)
call assert_equal("\t ", blankchars) call assert_equal("\t ", blankchars)
" Commented out: it succeeds on Linux and Windows, but fails on macOs in Travis. call assert_equal("\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f\x7f", cntrlchars)
" call assert_equal("\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f\x7f", cntrlchars)
call assert_equal("0123456789", digitchars) call assert_equal("0123456789", digitchars)
call assert_equal("\<Esc>", escapechar) call assert_equal("\<Esc>", escapechar)
" Commented out: it succeeds on Linux and Windows, but fails on macOs in Travis. call assert_equal('!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~', graphchars)
" call assert_equal('!"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~', graphchars)
call assert_equal('abcdefghijklmnopqrstuvwxyzµßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ', lowerchars) call assert_equal('abcdefghijklmnopqrstuvwxyzµßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ', lowerchars)
call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', printchars) call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', printchars)
call assert_equal('!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~', punctchars) call assert_equal('!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~', punctchars)
@ -168,3 +166,20 @@ func Test_eow_with_optional()
call assert_equal(expected, actual) call assert_equal(expected, actual)
endfor endfor
endfunc endfunc
func Test_reversed_range()
for re in range(0, 2)
exe 'set re=' . re
call assert_fails('call match("abc def", "[c-a]")', 'E944:')
endfor
set re=0
endfunc
func Test_large_class()
set re=1
call assert_fails('call match("abc def", "[\u3000-\u4000]")', 'E945:')
set re=2
call assert_equal(0, 'abc def' =~# '[\u3000-\u4000]')
call assert_equal(1, "\u3042" =~# '[\u3000-\u4000]')
set re=0
endfunc