summaryrefslogtreecommitdiffstats
path: root/src/diff.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2009-07-22 14:23:13 +0000
committerBram Moolenaar <Bram@vim.org>2009-07-22 14:23:13 +0000
commit6ec0a6c43da9b5241baa852968e8d76a9366905e (patch)
tree6ced5bc272f7ae9af005c8bc439c227291445393 /src/diff.c
parent363cb67afa006f902f0a4c9a6669be03db2d1871 (diff)
updated for version 7.2-239v7.2.239
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/diff.c b/src/diff.c
index 9537a65d79..f5ea0c6928 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -893,6 +893,7 @@ ex_diffpatch(eap)
char_u *browseFile = NULL;
int browse_flag = cmdmod.browse;
#endif
+ struct stat st;
#ifdef FEAT_BROWSE
if (cmdmod.browse)
@@ -999,44 +1000,51 @@ ex_diffpatch(eap)
STRCAT(buf, ".rej");
mch_remove(buf);
- if (curbuf->b_fname != NULL)
+ /* Only continue if the output file was created. */
+ if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
+ EMSG(_("E816: Cannot read patch output"));
+ else
{
- newname = vim_strnsave(curbuf->b_fname,
+ if (curbuf->b_fname != NULL)
+ {
+ newname = vim_strnsave(curbuf->b_fname,
(int)(STRLEN(curbuf->b_fname) + 4));
- if (newname != NULL)
- STRCAT(newname, ".new");
- }
+ if (newname != NULL)
+ STRCAT(newname, ".new");
+ }
#ifdef FEAT_GUI
- need_mouse_correct = TRUE;
+ need_mouse_correct = TRUE;
#endif
- /* don't use a new tab page, each tab page has its own diffs */
- cmdmod.tab = 0;
-
- if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
- {
- /* Pretend it was a ":split fname" command */
- eap->cmdidx = CMD_split;
- eap->arg = tmp_new;
- do_exedit(eap, old_curwin);
+ /* don't use a new tab page, each tab page has its own diffs */
+ cmdmod.tab = 0;
- if (curwin != old_curwin) /* split must have worked */
+ if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
{
- /* Set 'diff', 'scrollbind' on and 'wrap' off. */
- diff_win_options(curwin, TRUE);
- diff_win_options(old_curwin, TRUE);
+ /* Pretend it was a ":split fname" command */
+ eap->cmdidx = CMD_split;
+ eap->arg = tmp_new;
+ do_exedit(eap, old_curwin);
- if (newname != NULL)
+ /* check that split worked and editing tmp_new */
+ if (curwin != old_curwin && win_valid(old_curwin))
{
- /* do a ":file filename.new" on the patched buffer */
- eap->arg = newname;
- ex_file(eap);
+ /* Set 'diff', 'scrollbind' on and 'wrap' off. */
+ diff_win_options(curwin, TRUE);
+ diff_win_options(old_curwin, TRUE);
+
+ if (newname != NULL)
+ {
+ /* do a ":file filename.new" on the patched buffer */
+ eap->arg = newname;
+ ex_file(eap);
#ifdef FEAT_AUTOCMD
- /* Do filetype detection with the new name. */
- if (au_has_group((char_u *)"filetypedetect"))
- do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
+ /* Do filetype detection with the new name. */
+ if (au_has_group((char_u *)"filetypedetect"))
+ do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
#endif
+ }
}
}
}