diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-02-18 10:37:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-18 10:37:56 +0100 |
commit | 9cf600e702872ddae83c222d0a389f809879a212 (patch) | |
tree | d0913718fedb02a64bb88c1c9db90895631a53f5 | |
parent | 6b827bb6646c213b8ad5ee6c1c87dcfd84f4bc29 (diff) | |
parent | 486234ab3db56621767bea18a1783d289b660764 (diff) | |
download | rneovim-9cf600e702872ddae83c222d0a389f809879a212.tar.gz rneovim-9cf600e702872ddae83c222d0a389f809879a212.tar.bz2 rneovim-9cf600e702872ddae83c222d0a389f809879a212.zip |
Merge #9625 from janlazo/vim-8.1.0945
-rw-r--r-- | src/nvim/regexp.c | 4 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 19 | ||||
-rw-r--r-- | src/nvim/testdir/test_regexp_latin.vim | 17 |
3 files changed, 29 insertions, 11 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index a70b150e9b..53479294de 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -772,7 +772,7 @@ static int get_equi_class(char_u **pp) int l = 1; char_u *p = *pp; - if (p[1] == '=') { + if (p[1] == '=' && p[2] != NUL) { l = (*mb_ptr2len)(p + 2); if (p[l + 2] == '=' && p[l + 3] == ']') { c = utf_ptr2char(p + 2); @@ -1103,7 +1103,7 @@ static int get_coll_element(char_u **pp) int l = 1; char_u *p = *pp; - if (p[0] != NUL && p[1] == '.') { + if (p[0] != NUL && p[1] == '.' && p[2] != NUL) { l = utfc_ptr2len(p + 2); if (p[l + 2] == '.' && p[l + 3] == ']') { c = utf_ptr2char(p + 2); diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 08ef7da9c1..d34e653058 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1691,15 +1691,16 @@ collection: ) { MB_PTR_ADV(regparse); - if (*regparse == 'n') - startc = reg_string ? NL : NFA_NEWL; - else if (*regparse == 'd' - || *regparse == 'o' - || *regparse == 'x' - || *regparse == 'u' - || *regparse == 'U' - ) { - /* TODO(RE) This needs more testing */ + if (*regparse == 'n') { + startc = (reg_string || emit_range || regparse[1] == '-') + ? NL : NFA_NEWL; + } else if (*regparse == 'd' + || *regparse == 'o' + || *regparse == 'x' + || *regparse == 'u' + || *regparse == 'U' + ) { + // TODO(RE): This needs more testing startc = coll_get_char(); got_coll_char = true; MB_PTR_BACK(old_regparse, regparse); diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index 8528412806..eb8f69ef15 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -30,3 +30,20 @@ func Test_equivalence_re2() set re=2 call s:equivalence_test() 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 + +func Test_get_equi_class() + new + " Incomplete equivalence class caused invalid memory access + s/^/[[= + call assert_equal(1, search(getline(1))) + s/.*/[[. + call assert_equal(1, search(getline(1))) +endfunc |