static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
#endif
-static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
static int check_readonly __ARGS((int *forceit, buf_T *buf));
#ifdef FEAT_AUTOCMD
static void delbuf_msg __ARGS((char_u *name));
* May set eap->forceit if a dialog says it's OK to overwrite.
* Return OK if it's OK, FAIL if it is not.
*/
- static int
+ int
check_overwrite(eap, buf, fname, ffname, other)
exarg_T *eap;
buf_T *buf;
char_u buff[DIALOG_MSG_SIZE];
int ret;
buf_T *buf2;
+ exarg_T ea;
dialog_msg(buff, _("Save changes to \"%s\"?"),
(buf->b_fname != NULL) ?
else
ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
+ /* Init ea pseudo-structure, this is needed for the check_overwrite()
+ * function. */
+ ea.append = ea.forceit = FALSE;
+
if (ret == VIM_YES)
{
#ifdef FEAT_BROWSE
/* May get file name, when there is none */
browse_save_fname(buf);
#endif
- if (buf->b_fname != NULL) /* didn't hit Cancel */
+ if (buf->b_fname != NULL && check_overwrite(&ea, buf,
+ buf->b_fname, buf->b_ffname, FALSE) == OK)
+ /* didn't hit Cancel */
(void)buf_write_all(buf, FALSE);
}
else if (ret == VIM_NO)
/* May get file name, when there is none */
browse_save_fname(buf2);
#endif
- if (buf2->b_fname != NULL) /* didn't hit Cancel */
+ if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
+ buf2->b_fname, buf2->b_ffname, FALSE) == OK)
+ /* didn't hit Cancel */
(void)buf_write_all(buf2, FALSE);
#ifdef FEAT_AUTOCMD
/* an autocommand may have deleted the buffer */
void ex_update __ARGS((exarg_T *eap));
void ex_write __ARGS((exarg_T *eap));
int do_write __ARGS((exarg_T *eap));
+int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
void ex_wnext __ARGS((exarg_T *eap));
void do_wqall __ARGS((exarg_T *eap));
int not_writing __ARGS((void));