home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.096 < prev    next >
Encoding:
Internet Message Format  |  2001-12-11  |  4.3 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.096
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.096
  11. Problem:    When ":saveas fname" fails because the file already exists, the
  12.         file name is changed anyway and a following ":w" will overwrite
  13.         the file. (Eric Carlier)
  14. Solution:   Don't change the file name if the file already exists.
  15. Files:        src/ex_cmds.c
  16.  
  17.  
  18. *** ../vim60.95/src/ex_cmds.c    Mon Nov  5 21:24:46 2001
  19. --- src/ex_cmds.c    Wed Dec 12 21:32:55 2001
  20. ***************
  21. *** 2140,2191 ****
  22.       }
  23.       }
  24.   
  25. !     if (eap->cmdidx == CMD_saveas && alt_buf != NULL)
  26.       {
  27.   #ifdef FEAT_AUTOCMD
  28. !     buf_T    *was_curbuf = curbuf;
  29.   
  30. !     apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
  31. !     if (curbuf != was_curbuf)
  32. !     {
  33. !         /* buffer changed, don't change name now */
  34. !         retval = FAIL;
  35. !         goto theend;
  36. !     }
  37.   #endif
  38. !     /* Exchange the file names for the current and the alternate buffer.
  39. !      * This makes it look like we are now editing the buffer under the new
  40. !      * name.  Must be done before buf_write(), because if there is no file
  41. !      * name and 'cpo' contains 'F', it will set the file name. */
  42. !     fname = alt_buf->b_fname;
  43. !     alt_buf->b_fname = curbuf->b_fname;
  44. !     curbuf->b_fname = fname;
  45. !     fname = alt_buf->b_ffname;
  46. !     alt_buf->b_ffname = curbuf->b_ffname;
  47. !     curbuf->b_ffname = fname;
  48. !     fname = alt_buf->b_sfname;
  49. !     alt_buf->b_sfname = curbuf->b_sfname;
  50. !     curbuf->b_sfname = fname;
  51. !     buf_name_changed();
  52.   #ifdef FEAT_AUTOCMD
  53. !     apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
  54. !     if (!alt_buf->b_p_bl)
  55. !     {
  56. !         alt_buf->b_p_bl = TRUE;
  57. !         apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, alt_buf);
  58. !     }
  59. !     if (curbuf != was_curbuf)
  60. !     {
  61. !         /* buffer changed, don't write the file */
  62. !         retval = FAIL;
  63. !         goto theend;
  64. !     }
  65.   #endif
  66. !     }
  67.   
  68. -     if (check_overwrite(eap, curbuf, fname, ffname, other) == OK)
  69.       retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
  70.                    eap, eap->append, eap->forceit, TRUE, FALSE);
  71.   
  72.   theend:
  73.   #ifdef FEAT_BROWSE
  74. --- 2140,2194 ----
  75.       }
  76.       }
  77.   
  78. !     if (check_overwrite(eap, curbuf, fname, ffname, other) == OK)
  79.       {
  80. +     if (eap->cmdidx == CMD_saveas && alt_buf != NULL)
  81. +     {
  82.   #ifdef FEAT_AUTOCMD
  83. !         buf_T    *was_curbuf = curbuf;
  84.   
  85. !         apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
  86. !         if (curbuf != was_curbuf)
  87. !         {
  88. !         /* buffer changed, don't change name now */
  89. !         retval = FAIL;
  90. !         goto theend;
  91. !         }
  92.   #endif
  93. !         /* Exchange the file names for the current and the alternate
  94. !          * buffer.  This makes it look like we are now editing the buffer
  95. !          * under the new name.  Must be done before buf_write(), because
  96. !          * if there is no file name and 'cpo' contains 'F', it will set
  97. !          * the file name. */
  98. !         fname = alt_buf->b_fname;
  99. !         alt_buf->b_fname = curbuf->b_fname;
  100. !         curbuf->b_fname = fname;
  101. !         fname = alt_buf->b_ffname;
  102. !         alt_buf->b_ffname = curbuf->b_ffname;
  103. !         curbuf->b_ffname = fname;
  104. !         fname = alt_buf->b_sfname;
  105. !         alt_buf->b_sfname = curbuf->b_sfname;
  106. !         curbuf->b_sfname = fname;
  107. !         buf_name_changed();
  108.   #ifdef FEAT_AUTOCMD
  109. !         apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
  110. !         if (!alt_buf->b_p_bl)
  111. !         {
  112. !         alt_buf->b_p_bl = TRUE;
  113. !         apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, alt_buf);
  114. !         }
  115. !         if (curbuf != was_curbuf)
  116. !         {
  117. !         /* buffer changed, don't write the file */
  118. !         retval = FAIL;
  119. !         goto theend;
  120. !         }
  121.   #endif
  122. !     }
  123.   
  124.       retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
  125.                    eap, eap->append, eap->forceit, TRUE, FALSE);
  126. +     }
  127.   
  128.   theend:
  129.   #ifdef FEAT_BROWSE
  130. *** ../vim60.95/src/version.c    Wed Dec 12 21:05:43 2001
  131. --- src/version.c    Wed Dec 12 21:37:50 2001
  132. ***************
  133. *** 608,609 ****
  134. --- 608,611 ----
  135.   {   /* Add new patch number below this line */
  136. + /**/
  137. +     96,
  138.   /**/
  139.  
  140. -- 
  141. hundred-and-one symptoms of being an internet addict:
  142. 51. You put a pillow case over your laptop so your lover doesn't see it while
  143.     you are pretending to catch your breath.
  144.  
  145.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  146. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  147.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  148.