From 208cdb84a6991bb3652db70b7ac6aea7ab36dcb7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 3 Sep 2018 10:40:28 -0400 Subject: vim-patch:8.1.0340: no test for :spellinfo Problem: No test for :spellinfo. Solution: Add a test. (Dominique Pelle, closes vim/vim#3394) https://github.com/vim/vim/commit/9049b686121367941bf534c041975938135c7e20 --- src/nvim/testdir/test_spell.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index a2828b21d2..3dbbce83fc 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -85,6 +85,35 @@ func Test_spellreall() bwipe! endfunc +func Test_spellinfo() + new + + set enc=latin1 spell spelllang=en + call assert_match("^\nfile: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo')) + + set enc=cp1250 spell spelllang=en + call assert_match("^\nfile: .*/runtime/spell/en.ascii.spl\n$", execute('spellinfo')) + + if has('multi_byte') + set enc=utf-8 spell spelllang=en + call assert_match("^\nfile: .*/runtime/spell/en.utf-8.spl\n$", execute('spellinfo')) + endif + + set enc=latin1 spell spelllang=en_us,en_nz + call assert_match("^\n" . + \ "file: .*/runtime/spell/en.latin1.spl\n" . + \ "file: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo')) + + set spell spelllang= + call assert_fails('spellinfo', 'E756:') + + set nospell spelllang=en + call assert_fails('spellinfo', 'E756:') + + set enc& spell& spelllang& + bwipe +endfunc + func Test_zz_basic() call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1) call RunGoodBad("wrong OK puts. Test the end", -- cgit From e5046822c96ecfd7c774bf3ab025caf5aebd06d8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 3 Sep 2018 13:11:07 -0400 Subject: oldtests: skip Test_spellinfo() nvim supports only `set encoding=utf8`. --- src/nvim/testdir/test_spell.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index 3dbbce83fc..b3438cc649 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -86,6 +86,7 @@ func Test_spellreall() endfunc func Test_spellinfo() + throw 'skipped: Nvim does not support enc=latin1' new set enc=latin1 spell spelllang=en -- cgit From 42419e5a735332e075d3db599df5fd1b74a92868 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 19 Sep 2018 21:21:45 -0400 Subject: vim-patch:8.0.1620: reading spell file has no good EOF detection Problem: Reading spell file has no good EOF detection. Solution: Check for EOF at every character read for a length field. https://github.com/vim/vim/commit/e26e0d2b83c2875b9829b884c2ababf8ca771f7e --- src/nvim/fileio.c | 71 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d0e30ddbd3..21cb76e220 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -4531,48 +4531,83 @@ bool vim_fgets(char_u *buf, int size, FILE *fp) FUNC_ATTR_NONNULL_ALL } /// Read 2 bytes from "fd" and turn them into an int, MSB first. +/// Returns -1 when encountering EOF. int get2c(FILE *fd) { - int n; - - n = getc(fd); - n = (n << 8) + getc(fd); - return n; + const int n = getc(fd); + if (n == EOF) { + return -1; + } + const int c = getc(fd); + if (c == EOF) { + return -1; + } + return (n << 8) + c; } /// Read 3 bytes from "fd" and turn them into an int, MSB first. +/// Returns -1 when encountering EOF. int get3c(FILE *fd) { - int n; - - n = getc(fd); - n = (n << 8) + getc(fd); - n = (n << 8) + getc(fd); - return n; + int n = getc(fd); + if (n == EOF) { + return -1; + } + int c = getc(fd); + if (c == EOF) { + return -1; + } + n = (n << 8) + c; + c = getc(fd); + if (c == EOF) { + return -1; + } + return (n << 8) + c; } /// Read 4 bytes from "fd" and turn them into an int, MSB first. +/// Returns -1 when encountering EOF. int get4c(FILE *fd) { // Use unsigned rather than int otherwise result is undefined // when left-shift sets the MSB. unsigned n; - n = (unsigned)getc(fd); - n = (n << 8) + (unsigned)getc(fd); - n = (n << 8) + (unsigned)getc(fd); - n = (n << 8) + (unsigned)getc(fd); + int c = getc(fd); + if (c == EOF) { + return -1; + } + n = (unsigned)c; + c = getc(fd); + if (c == EOF) { + return -1; + } + n = (n << 8) + (unsigned)c; + c = getc(fd); + if (c == EOF) { + return -1; + } + n = (n << 8) + (unsigned)c; + c = getc(fd); + if (c == EOF) { + return -1; + } + n = (n << 8) + (unsigned)c; return (int)n; } /// Read 8 bytes from `fd` and turn them into a time_t, MSB first. +/// Returns -1 when encountering EOF. time_t get8ctime(FILE *fd) { time_t n = 0; - int i; - for (i = 0; i < 8; i++) { - n = (n << 8) + getc(fd); + for (int i = 0; i < 8; i++) { + const int c = getc(fd); + if (c == EOF) { + return -1; + } + n = (n << 8) + c; } return n; } -- cgit From 8fa7b6c8af127b90fa54aa7ac70735ca0149643a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 12 Nov 2018 11:05:27 -0500 Subject: vim-patch:8.1.0096: inconsistent use of the word autocommands Problem: Inconsistent use of the word autocommands. Solution: Don't use auto-commands or "auto commands". https://github.com/vim/vim/commit/8c55533c6f109db2a0fff69651887f9474eb09c6 --- src/nvim/fileio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 21cb76e220..857e69a001 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -5967,19 +5967,19 @@ void au_event_restore(char_u *old_ei) * will be automatically executed for * when editing a file matching , in * the current group. - * :autocmd Show the auto-commands associated with + * :autocmd Show the autocommands associated with * and . - * :autocmd Show the auto-commands associated with + * :autocmd Show the autocommands associated with * . - * :autocmd Show all auto-commands. - * :autocmd! Remove all auto-commands associated with + * :autocmd Show all autocommands. + * :autocmd! Remove all autocommands associated with * and , and add the command * , for the current group. - * :autocmd! Remove all auto-commands associated with + * :autocmd! Remove all autocommands associated with * and for the current group. - * :autocmd! Remove all auto-commands associated with + * :autocmd! Remove all autocommands associated with * for the current group. - * :autocmd! Remove ALL auto-commands for the current + * :autocmd! Remove ALL autocommands for the current * group. * * Multiple events and patterns may be given separated by commas. Here are @@ -6073,7 +6073,7 @@ void do_autocmd(char_u *arg_in, int forceit) */ if (!forceit && *cmd == NUL) { /* Highlight title */ - MSG_PUTS_TITLE(_("\n--- Auto-Commands ---")); + MSG_PUTS_TITLE(_("\n--- Autocommands ---")); } /* @@ -6942,7 +6942,7 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, autocmd_match = fname; - /* Don't redraw while doing auto commands. */ + // Don't redraw while doing autocommands. ++RedrawingDisabled; save_sourcing_name = sourcing_name; sourcing_name = NULL; /* don't free this one */ @@ -7154,7 +7154,7 @@ auto_next_pat ( apc->tail, ap->allow_dirs) : ap->buflocal_nr == apc->arg_bufnr) { const char *const name = event_nr2name(apc->event); - s = _("%s Auto commands for \"%s\""); + s = _("%s Autocommands for \"%s\""); const size_t sourcing_name_len = (STRLEN(s) + strlen(name) + ap->patlen + 1); sourcing_name = xmalloc(sourcing_name_len); -- cgit From 21824df3c6e0e73bb90482899560648fa04d55e5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 12 Nov 2018 11:12:44 -0500 Subject: lint --- src/nvim/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 857e69a001..7e8a7d1a35 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -6072,7 +6072,7 @@ void do_autocmd(char_u *arg_in, int forceit) * Print header when showing autocommands. */ if (!forceit && *cmd == NUL) { - /* Highlight title */ + // Highlight title MSG_PUTS_TITLE(_("\n--- Autocommands ---")); } @@ -6943,7 +6943,7 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, // Don't redraw while doing autocommands. - ++RedrawingDisabled; + RedrawingDisabled++; save_sourcing_name = sourcing_name; sourcing_name = NULL; /* don't free this one */ save_sourcing_lnum = sourcing_lnum; -- cgit