Patch 8.2.2856

7 views
Skip to first unread message

Bram Moolenaar

unread,
May 15, 2021, 5:22:12 PM5/15/21
to vim...@googlegroups.com

Patch 8.2.2856
Problem: Get readonly error for device that can't be written to.
Solution: Check for being able to write first. (closes #8205)
Files: src/ex_cmds.c, src/testdir/test_writefile.vim


*** ../vim-8.2.2855/src/ex_cmds.c 2021-04-26 21:14:12.709924759 +0200
--- src/ex_cmds.c 2021-05-15 23:11:16.334412804 +0200
***************
*** 1856,1861 ****
--- 1856,1874 ----
(void)do_write(eap);
}

+ #ifdef UNIX
+ static int
+ check_writable(char_u *fname)
+ {
+ if (mch_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
***************
*** 1942,1948 ****
#ifdef FEAT_QUICKFIX
bt_dontwrite_msg(curbuf) ||
#endif
! check_fname() == FAIL || check_readonly(&eap->forceit, curbuf)))
goto theend;

if (!other)
--- 1955,1965 ----
#ifdef FEAT_QUICKFIX
bt_dontwrite_msg(curbuf) ||
#endif
! check_fname() == FAIL
! #ifdef UNIX
! || check_writable(curbuf->b_ffname) == FAIL
! #endif
! || check_readonly(&eap->forceit, curbuf)))
goto theend;

if (!other)
*** ../vim-8.2.2855/src/testdir/test_writefile.vim 2021-05-13 18:32:46.443394721 +0200
--- src/testdir/test_writefile.vim 2021-05-15 23:11:57.478238596 +0200
***************
*** 285,291 ****
\ && getftype('/dev/loop0') == 'bdev' && !IsRoot()
new
edit /dev/loop0
! call assert_fails('write', 'E505: ')
call assert_fails('write!', 'E503: ')
close!
endif
--- 285,291 ----
\ && getftype('/dev/loop0') == 'bdev' && !IsRoot()
new
edit /dev/loop0
! call assert_fails('write', 'E503: ')
call assert_fails('write!', 'E503: ')
close!
endif
*** ../vim-8.2.2855/src/version.c 2021-05-15 20:06:52.885646125 +0200
--- src/version.c 2021-05-15 23:06:33.335606854 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2856,
/**/

--
Life would be so much easier if we could just look at the source code.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages