diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-04 08:40:54 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-04 08:44:19 -0400 |
commit | 21aa4bc428e439e7132474aee646552c9b0d6b63 (patch) | |
tree | a2632436414a1b32396155c8cf96365e641d0021 | |
parent | fe5c891fe05b7974c9a7c9048b81e788f1143eb1 (diff) | |
download | rneovim-21aa4bc428e439e7132474aee646552c9b0d6b63.tar.gz rneovim-21aa4bc428e439e7132474aee646552c9b0d6b63.tar.bz2 rneovim-21aa4bc428e439e7132474aee646552c9b0d6b63.zip |
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
-rw-r--r-- | src/nvim/regexp.c | 6 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_regexp_utf8.vim | 17 |
3 files changed, 22 insertions, 3 deletions
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 |