diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-07 07:58:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 07:58:37 +0800 |
commit | 9b9f84bc62a01ed76b9f53119781816bd3375267 (patch) | |
tree | c1c6e5463d515ddc174ca71554d1203f29983c28 /src/nvim/ex_cmds.c | |
parent | 3b3611a3d0f1e13e277360d6bacf97a0fb7eb6de (diff) | |
parent | 7e1d9c560b09cacb78b2fc8f9428a77d6fca66e1 (diff) | |
download | rneovim-9b9f84bc62a01ed76b9f53119781816bd3375267.tar.gz rneovim-9b9f84bc62a01ed76b9f53119781816bd3375267.tar.bz2 rneovim-9b9f84bc62a01ed76b9f53119781816bd3375267.zip |
Merge pull request #20982 from zeertzjq/vim-8.2.2849
vim-patch:8.2.{2849,2856,2873}: buffer writing tests
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 89e6d47950..d3a4b6c282 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1772,6 +1772,17 @@ void ex_write(exarg_T *eap) } } +#ifdef UNIX +static int check_writable(const char *fname) +{ + if (os_nodetype(fname) == NODE_OTHER) { + semsg(_("E503: \"%s\" is not a file or writable device"), fname); + return FAIL; + } + return OK; +} +#endif + /// write current buffer to file 'eap->arg' /// if 'eap->append' is true, append to the file /// @@ -1829,7 +1840,11 @@ int do_write(exarg_T *eap) // Writing to the current file is not allowed in readonly mode // and a file name is required. // "nofile" and "nowrite" buffers cannot be written implicitly either. - if (!other && (bt_dontwrite_msg(curbuf) || check_fname() == FAIL + if (!other && (bt_dontwrite_msg(curbuf) + || check_fname() == FAIL +#ifdef UNIX + || check_writable(curbuf->b_ffname) == FAIL +#endif || check_readonly(&eap->forceit, curbuf))) { goto theend; } |