From fe5c891fe05b7974c9a7c9048b81e788f1143eb1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 4 Jun 2018 08:36:50 -0400 Subject: vim-patch:8.0.0529: line in test commented out Problem: Line in test commented out. Solution: Uncomment the lines for character classes that were failing before 8.0.0519. (Dominique Pelle, closes vim/vim#1599) https://github.com/vim/vim/commit/13489b9c41922b9ecb16fa47564ec76641515c08 --- src/nvim/testdir/test_regexp_utf8.vim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index ecd686743e..0e4a9f647a 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -109,12 +109,10 @@ func s:classes_test() call assert_equal('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alnumchars) call assert_equal("\b", backspacechar) 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("\", 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(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', printchars) call assert_equal('!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~', punctchars) -- cgit From 21aa4bc428e439e7132474aee646552c9b0d6b63 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 4 Jun 2018 08:40:54 -0400 Subject: vim-patch:8.0.0623: error for invalid regexp is not very informative Problem: The message "Invalid range" is used for multiple errors. Solution: Add two more specific error messages. (Itchyny, Ken Hamada) https://github.com/vim/vim/commit/966e58e413ffa88af8d748e697aa2999571fcd7b --- src/nvim/regexp.c | 6 ++++-- src/nvim/regexp_nfa.c | 2 +- src/nvim/testdir/test_regexp_utf8.vim | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index ee7d6d8500..94c324c0e7 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -479,6 +479,8 @@ static char_u *regprop(char_u *); #endif 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_unmatchedp[] = N_("E54: Unmatched %s("); static char_u e_unmatchedpar[] = N_("E55: Unmatched %s)"); @@ -2233,12 +2235,12 @@ collection: endc = coll_get_char(); if (startc > endc) - EMSG_RET_NULL(_(e_invrange)); + EMSG_RET_NULL(_(e_reverse_range)); if (has_mbyte && ((*mb_char2len)(startc) > 1 || (*mb_char2len)(endc) > 1)) { /* Limit to a range of 256 chars */ if (endc > startc + 256) - EMSG_RET_NULL(_(e_invrange)); + EMSG_RET_NULL(_(e_large_class)); while (++startc <= endc) regmbc(startc); } else { diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 0b8e979ca2..3e4a32b178 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1712,7 +1712,7 @@ collection: endc = startc; startc = oldstartc; if (startc > endc) - EMSG_RET_FAIL(_(e_invrange)); + EMSG_RET_FAIL(_(e_reverse_range)); if (endc > startc + 2) { /* Emit a range instead of the sequence of diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 0e4a9f647a..97638e9aac 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -166,3 +166,20 @@ func Test_eow_with_optional() call assert_equal(expected, actual) endfor 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 -- cgit From 2ab7165214e82fb6f509663929243b13d0ef163a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 4 Jun 2018 11:13:05 -0400 Subject: lint --- src/nvim/regexp.c | 11 +++++++---- src/nvim/regexp_nfa.c | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 94c324c0e7..c4af7d9e4a 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2234,15 +2234,18 @@ collection: if (endc == '\\' && !reg_cpo_lit) endc = coll_get_char(); - if (startc > endc) + if (startc > endc) { EMSG_RET_NULL(_(e_reverse_range)); + } if (has_mbyte && ((*mb_char2len)(startc) > 1 || (*mb_char2len)(endc) > 1)) { - /* Limit to a range of 256 chars */ - if (endc > startc + 256) + // Limit to a range of 256 chars + if (endc > startc + 256) { EMSG_RET_NULL(_(e_large_class)); - while (++startc <= endc) + } + while (++startc <= endc) { regmbc(startc); + } } else { while (++startc <= endc) regc(startc); diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 3e4a32b178..334539b228 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1711,8 +1711,9 @@ collection: if (emit_range) { endc = startc; startc = oldstartc; - if (startc > endc) + if (startc > endc) { EMSG_RET_FAIL(_(e_reverse_range)); + } if (endc > startc + 2) { /* Emit a range instead of the sequence of -- cgit