From 31513a6f2df7cce9a7ae19fcd7c0e9c2404ea1e9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 18 Sep 2020 21:46:40 -0400 Subject: [PATCH 1/5] vim-patch:8.1.1972: no proper test for getchar() Problem: No proper test for getchar(). Solution: Add a test with special characters. https://github.com/vim/vim/commit/5d712e4672c6c8cf7f35cfb7d8eb7e8aa24062ac N/A patches for version.c: vim-patch:8.1.0285: compiler warning for conversion Problem: Compiler warning for conversion. Solution: Add a type cast. (Mike Williams) https://github.com/vim/vim/commit/d7cc16357083c4fc4271e25fb36c4fbaee99e0f1 vim-patch:8.1.1782: MS-Windows: system() has temp file error with 'noshelltemp' Problem: MS-Windows: system() has temp file error with 'noshelltemp'. Solution: Check s_dont_use_vimrun. (Ken Takata, closes vim/vim#4754) https://github.com/vim/vim/commit/0e6bfb9b2eb108d96a49ac4f8dc638c2eefeda2b vim-patch:8.2.0240: using memory after it was freed Problem: Using memory after it was freed. (Dominique Pelle) Solution: Do not mix converion buffer with other buffer. https://github.com/vim/vim/commit/408030e8d053fe1c871b2fc366363a30ed98c889 vim-patch:8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used Problem: The "r" command fails for keys with modifiers if 'esckeys' is off and modifyOtherKeys is used. (Lauri Tirkkonen) Solution: Temporarily disable bracketed paste and modifyOtherKeys if 'esckeys' is off. (closes vim/vim#6809) https://github.com/vim/vim/commit/ca774f67534e6d1843fda9d1dc9a899972d27577 vim-patch:8.2.1676: compiler warnings for function typecast Problem: Compiler warnings for function typecast. Solution: Add an intermediate cast to "void *". https://github.com/vim/vim/commit/a4224860a498eb870280130e00fe6f376b7a2e6b vim-patch:8.2.1696: unused (duplicate) macros Problem: Unused (duplicate) macros. Solution: Remove the macros. https://github.com/vim/vim/commit/2c12f890551bbdf5605472a4d711d48a273685d7 --- src/nvim/testdir/test_functions.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 6b45ac61d1..9a05db1188 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1221,6 +1221,24 @@ func Test_reg_executing_and_recording() unlet s:reg_stat endfunc +func Test_getchar() + throw 'skipped: Nvim does not support test_setmouse()' + call feedkeys('a', '') + call assert_equal(char2nr('a'), getchar()) + + call test_setmouse(1, 3) + let v:mouse_win = 9 + let v:mouse_winid = 9 + let v:mouse_lnum = 9 + let v:mouse_col = 9 + call feedkeys("\", '') + call assert_equal("\", getchar()) + call assert_equal(1, v:mouse_win) + call assert_equal(win_getid(1), v:mouse_winid) + call assert_equal(1, v:mouse_lnum) + call assert_equal(3, v:mouse_col) +endfunc + func Test_libcall_libcallnr() if !has('libcall') return From ccfb69ab3676bca927744bae2f7462a6464fe4ce Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 18 Sep 2020 21:05:08 -0400 Subject: [PATCH 2/5] vim-patch:8.2.0817: not enough memory allocated when converting string Problem: Not enough memory allocated when converting string with special character. Solution: Reserve space for modifier code. (closes vim/vim#6130) https://github.com/vim/vim/commit/f7271e831614d15d173c7f562cc26f48c2554ce9 Cherry-pick Test_eval(), Test_nr2char() from patch 8.2.0448. --- src/nvim/eval.c | 19 ++++++++++++------- src/nvim/testdir/test_functions.vim | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b395d7bb8a..f3b6818464 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4518,7 +4518,6 @@ int get_option_tv(const char **const arg, typval_T *const rettv, static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) { char_u *p; - char_u *name; unsigned int extra = 0; /* @@ -4526,11 +4525,13 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) */ for (p = *arg + 1; *p != NUL && *p != '"'; MB_PTR_ADV(p)) { if (*p == '\\' && p[1] != NUL) { - ++p; - /* A "\" form occupies at least 4 characters, and produces up - * to 6 characters: reserve space for 2 extra */ - if (*p == '<') - extra += 2; + p++; + // A "\" form occupies at least 4 characters, and produces up + // to 9 characters (6 for the char and 3 for a modifier): reserve + // space for 5 extra. + if (*p == '<') { + extra += 5; + } } } @@ -4549,7 +4550,8 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) * Copy the string into allocated memory, handling backslashed * characters. */ - name = xmalloc(p - *arg + extra); + const int len = (int)(p - *arg + extra); + char_u *name = xmalloc(len); rettv->v_type = VAR_STRING; rettv->vval.v_string = name; @@ -4616,6 +4618,9 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) extra = trans_special((const char_u **)&p, STRLEN(p), name, true, true); if (extra != 0) { name += extra; + if (name >= rettv->vval.v_string + len) { + iemsg("get_string_tv() used more space than allocated"); + } break; } FALLTHROUGH; diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 9a05db1188..c8140d1c52 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1359,3 +1359,21 @@ func Test_readdir() call delete('Xdir', 'rf') endfunc + +" Test for the eval() function +func Test_eval() + call assert_fails("call eval('5 a')", 'E488:') +endfunc + +" Test for the nr2char() function +func Test_nr2char() + " set encoding=latin1 + call assert_equal('@', nr2char(64)) + set encoding=utf8 + call assert_equal('a', nr2char(97, 1)) + call assert_equal('a', nr2char(97, 0)) + + call assert_equal("\x80\xfc\b\xf4\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\"')) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab From d3e0d299192b7db07445db2fcdcbe089e1cf08f1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 18 Sep 2020 21:38:51 -0400 Subject: [PATCH 3/5] vim-patch:8.2.0824: still not enough memory allocated when converting string Problem: Still not enough memory allocated when converting string with special character. Solution: Reserve space for expanding K_SPECIAL. (closes vim/vim#6130) https://github.com/vim/vim/commit/1919371b2b9ddb1a645f40b59adbd89317530882 --- src/nvim/eval.c | 7 ++++--- src/nvim/testdir/test_functions.vim | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f3b6818464..00542e3766 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4527,10 +4527,11 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) if (*p == '\\' && p[1] != NUL) { p++; // A "\" form occupies at least 4 characters, and produces up - // to 9 characters (6 for the char and 3 for a modifier): reserve - // space for 5 extra. + // to 21 characters (3 * 6 for the char and 3 for a modifier): + // reserve space for 18 extra. + // Each byte in the char could be encoded as K_SPECIAL K_EXTRA x. if (*p == '<') { - extra += 5; + extra += 18; } } } diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index c8140d1c52..c29e0410a9 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1374,6 +1374,7 @@ func Test_nr2char() call assert_equal('a', nr2char(97, 0)) call assert_equal("\x80\xfc\b\xf4\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\"')) + call assert_equal("\x80\xfc\b\xfd\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\"')) endfunc " vim: shiftwidth=2 sts=2 expandtab From 17106b96e9c61ba8710b84c3fdd718e85f8a8365 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 19 Sep 2020 10:45:01 -0400 Subject: [PATCH 4/5] vim-patch:8.1.2261: with modifyOtherKeys set 'noesckeys' doesn't work Problem: With modifyOtherKeys set 'noesckeys' doesn't work. (James McCoy) Solution: Disable modifyOtherKeys while in Insert mode when 'noesckeys' is set. (closes vim/vim#5180) https://github.com/vim/vim/commit/177c9f2f06b048f4c1e154d29423edf65b128f8c --- src/nvim/testdir/test_edit.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 12d5d9790e..a863a254b6 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1514,3 +1514,22 @@ func Test_edit_startinsert() set backspace& bwipe! endfunc + +func Test_edit_noesckeys() + new + + " moves cursor when 'esckeys' is set + exe "set t_kl=\OD" + " set esckeys + call feedkeys("axyz\ODX", "xt") + " call assert_equal("xyXz", getline(1)) + + " exits Insert mode when 'esckeys' is off + " set noesckeys + call setline(1, '') + call feedkeys("axyz\ODX", "xt") + call assert_equal(["DX", "xyz"], getline(1, 2)) + + bwipe! + " set esckeys +endfunc From df46f9197764b92e596ad6a5a8c297edc51dd6f6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 19 Sep 2020 10:51:10 -0400 Subject: [PATCH 5/5] vim-patch:8.1.2263: 'noesckeys' test fails in GUI Problem: 'noesckeys' test fails in GUI. Solution: Skip the test in the GUI. https://github.com/vim/vim/commit/215ba3b63698f3755b2c4de66fc728cc14a8a590 Cherry-pick "CheckNotGui" command from patch 8.1.1826. --- src/nvim/testdir/check.vim | 8 ++++++++ src/nvim/testdir/test_edit.vim | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim index 073873bcb0..e0ebe8fd49 100644 --- a/src/nvim/testdir/check.vim +++ b/src/nvim/testdir/check.vim @@ -65,3 +65,11 @@ func CheckCanRunGui() throw 'Skipped: cannot start the GUI' endif endfunc + +" Command to check that not currently using the GUI +command CheckNotGui call CheckNotGui() +func CheckNotGui() + if has('gui_running') + throw 'Skipped: only works in the terminal' + endif +endfunc diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index a863a254b6..dbe12fc8fc 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1,9 +1,11 @@ " Test for edit functions -" + if exists("+t_kD") let &t_kD="[3;*~" endif +source check.vim + " Needed for testing basic rightleft: Test_edit_rightleft source view_util.vim @@ -1516,6 +1518,7 @@ func Test_edit_startinsert() endfunc func Test_edit_noesckeys() + CheckNotGui new " moves cursor when 'esckeys' is set