Hi itchyny,

2015-7-26(Sun) 20:46:05 UTC+9 itchyny:
> Vim warns E749 on switching to a buffer which used to be checked diff.
> 
> How to reproduce.
> 1. vim -u NONE -N
> 2. :e test | diffthis
> 3. :vnew test2 | diffthis
> 4. :e test3
> 5. :buffer #
> 
> Error message
> E749: empty buffer
> 
> What I expect
> Vim opens the test2 with no error message.
...snip...
> Hope it fixed. Thanks.


I can reproduced.

Places that are output E749 is four. In this case it is output in the following 
locations.

fileio.c (in function buf_write())
 3167     if (buf->b_ml.ml_mfp == NULL)
 3168     {
 3169         /* This can happen during startup when there is a stray "w" in the
 3170          * vimrc file. */
 3171         EMSG(_(e_emptybuf));
 3172         return FAIL;
 3173     }

And It's backtrace at this time. 
(gdb) bt
#0  buf_write (buf=0x1a961b0, fname=0x1a9d3c0 "/tmp/vCVByI3/4", sfname=0x0,
    start=1, end=1, eap=0x0, append=0, forceit=0, reset_changed=0, filtering=1)
    at fileio.c:3171
#1  0x0000000000414743 in diff_write (buf=0x1a961b0,
    fname=0x1a9d3c0 "/tmp/vCVByI3/4") at diff.c:645
#2  0x0000000000414b21 in ex_diffupdate (eap=0x0) at diff.c:809
#3  0x00000000004160e3 in diff_check (wp=0x1a921b0, lnum=1) at diff.c:1520
#4  0x000000000041463b in diff_redraw (dofold=1) at diff.c:618
#5  0x0000000000413868 in diff_buf_add (buf=0x1a961b0) at diff.c:137
#6  0x0000000000405d42 in enter_buffer (buf=0x1a961b0) at buffer.c:1542
#7  0x0000000000405c7d in set_curbuf (buf=0x1a961b0, action=0) at buffer.c:1507
#8  0x0000000000405a16 in do_buffer (action=0, start=1, dir=1, count=2,
    forceit=0) at buffer.c:1403
#9  0x0000000000404bdb in goto_buffer (eap=0x7ffed7d77d30, start=1, dir=1,
    count=2) at buffer.c:775
#10 0x000000000046c2fa in ex_buffer (eap=0x7ffed7d77d30) at ex_docmd.c:5494
#11 0x000000000046795c in do_one_cmd (cmdlinep=0x7ffed7d783c8, sourcing=0,
    cstack=0x7ffed7d77f20, fgetline=0x47ce87 <getexline>, cookie=0x0)
    at ex_docmd.c:2941
#12 0x00000000004647b7 in do_cmdline (cmdline=0x0,
    fgetline=0x47ce87 <getexline>, cookie=0x0, flags=0) at ex_docmd.c:1133
#13 0x00000000004ec941 in nv_colon (cap=0x7ffed7d784f0) at normal.c:5405
#14 0x00000000004e5d8c in normal_cmd (oap=0x7ffed7d785d0, toplevel=1)


The fileio.c:3169 comments do not know well to me.. ( ゚д゚)
However, I have taken measures so as not to come here when the 'diff'.

Please check attached patch.

--
Best regards,
Hirohito Higashi (a.k.a h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/diff.c b/src/diff.c
--- a/src/diff.c
+++ b/src/diff.c
@@ -804,7 +804,7 @@
     for (idx_new = idx_orig + 1; idx_new < DB_COUNT; ++idx_new)
     {
 	buf = curtab->tp_diffbuf[idx_new];
-	if (buf == NULL)
+	if (buf == NULL || buf->b_ml.ml_mfp == NULL)
 	    continue;
 	if (diff_write(buf, tmp_new) == FAIL)
 	    continue;

Raspunde prin e-mail lui