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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202105152122.14FLM3IE3417239%40masaka.moolenaar.net.

Raspunde prin e-mail lui