To: vim-dev@vim.org Subject: Patch 6.0.211 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.211 Problem: When reading a file fails, the buffer is empty, but it might still be possible to write it with ":w" later. The original file is lost then. (Steve Amerige) Solution: Set the 'readonly' option for the buffer. Files: src/fileio.c *** ../vim60.210/src/fileio.c Mon Feb 11 13:54:40 2002 --- src/fileio.c Mon Feb 11 13:46:55 2002 *************** *** 492,498 **** --- 496,505 ---- isdir_f = (mch_isdir(fname)); perm = mch_getperm(fname); /* check if the file exists */ if (isdir_f) + { filemess(curbuf, sfname, (char_u *)_("is a directory"), 0); + curbuf->b_p_ro = TRUE; /* must use "w!" now */ + } else #endif if (newfile) *************** *** 528,535 **** return OK; /* a new file is not an error */ } else filemess(curbuf, sfname, ! (char_u *)_("[Permission Denied]"), 0); } return FAIL; --- 535,545 ---- return OK; /* a new file is not an error */ } else + { filemess(curbuf, sfname, ! (char_u *)_("[Permission Denied]"), 0); ! curbuf->b_p_ro = TRUE; /* must use "w!" now */ ! } } return FAIL; *************** *** 624,629 **** --- 634,640 ---- EMSG(_("E200: *ReadPre autocommands made the file unreadable")); else EMSG(_("E201: *ReadPre autocommands must not change current buffer")); + curbuf->b_p_ro = TRUE; /* must use "w!" now */ return FAIL; } } *************** *** 1717,1723 **** --- 1732,1741 ---- if (got_int) { if (!(flags & READ_DUMMY)) + { filemess(curbuf, sfname, (char_u *)_(e_interr), 0); + curbuf->b_p_ro = TRUE; /* must use "w!" now */ + } msg_scroll = msg_save; #ifdef FEAT_VIMINFO check_marks_read(); *** ../vim60.210/src/version.c Mon Feb 11 13:54:40 2002 --- src/version.c Mon Feb 11 13:59:45 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 211, /**/ -- ARTHUR: I did say sorry about the `old woman,' but from the behind you looked-- DENNIS: What I object to is you automatically treat me like an inferior! ARTHUR: Well, I AM king... The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///