To: vim-dev@vim.org Subject: Patch 6.0.226 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.226 Problem: When doing ":recover file" get the ATTENTION prompt. After recovering the same file five times get a read error or a crash. (Alex Davis) Solution: Set the recoverymode flag before setting the file name. Correct the amount of used memory for the size of block zero. Files: src/ex_docmd.c, src/memfile.c, src/memline.c, src/proto/memfile.pro *** ../vim60.225/src/ex_docmd.c Mon Feb 4 22:30:34 2002 --- src/ex_docmd.c Sun Feb 17 12:49:44 2002 *************** *** 5474,5482 **** --- 5474,5485 ---- ex_recover(eap) exarg_T *eap; { + /* Set recoverymode right away to avoid the ATTENTION prompt. */ + recoverymode = TRUE; if (!check_changed(curbuf, p_awa, TRUE, eap->forceit, FALSE) && (*eap->arg == NUL || setfname(eap->arg, NULL, TRUE) == OK)) ml_recover(); + recoverymode = FALSE; } /* *** ../vim60.225/src/memfile.c Sun Sep 9 20:45:20 2001 --- src/memfile.c Sun Feb 17 13:46:35 2002 *************** *** 301,306 **** --- 301,321 ---- } /* + * Set new size for a memfile. Used when block 0 of a swapfile has been read + * and the size it indicates differs from what was guessed. + */ + void + mf_new_page_size(mfp, new_size) + memfile_T *mfp; + unsigned new_size; + { + /* Correct the memory used for block 0 to the new size, because it will be + * freed with that size later on. */ + total_mem_used += new_size - mfp->mf_page_size; + mfp->mf_page_size = new_size; + } + + /* * get a new block * * negative: TRUE if negative block number desired (data block) *** ../vim60.225/src/memline.c Sun Sep 9 18:12:48 2001 --- src/memline.c Sun Feb 17 13:45:43 2002 *************** *** 881,887 **** */ if (mfp->mf_page_size != (unsigned)char_to_long(b0p->b0_page_size)) { ! mfp->mf_page_size = (unsigned)char_to_long(b0p->b0_page_size); if ((size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0) mfp->mf_blocknr_max = 0; /* no file or empty file */ else --- 881,887 ---- */ if (mfp->mf_page_size != (unsigned)char_to_long(b0p->b0_page_size)) { ! mf_new_page_size(mfp, (unsigned)char_to_long(b0p->b0_page_size)); if ((size = lseek(mfp->mf_fd, (off_t)0L, SEEK_END)) <= 0) mfp->mf_blocknr_max = 0; /* no file or empty file */ else *** ../vim60.225/src/proto/memfile.pro Tue Sep 25 21:49:18 2001 --- src/proto/memfile.pro Sun Feb 17 13:44:40 2002 *************** *** 3,8 **** --- 3,9 ---- int mf_open_file __ARGS((memfile_T *mfp, char_u *fname)); void mf_close __ARGS((memfile_T *mfp, int del_file)); void mf_close_file __ARGS((buf_T *buf, int getlines)); + void mf_new_page_size __ARGS((memfile_T *mfp, unsigned new_size)); bhdr_T *mf_new __ARGS((memfile_T *mfp, int negative, int page_count)); bhdr_T *mf_get __ARGS((memfile_T *mfp, blocknr_T nr, int page_count)); void mf_put __ARGS((memfile_T *mfp, bhdr_T *hp, int dirty, int infile)); *** ../vim60.225/src/version.c Sat Feb 16 22:55:56 2002 --- src/version.c Sun Feb 17 13:52:02 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 226, /**/ -- Another bucket of what can only be described as human ordure hits ARTHUR. ARTHUR: ... Right! (to the KNIGHTS) That settles it! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///