[vim/vim] Quickfix: Problem if first pattern is an ignored multiline pattern (#1126)

46 views
Skip to first unread message

Gerd Wachsmuth

unread,
Sep 27, 2016, 4:51:49 PM9/27/16
to vim/vim

Let us consider the errorfile errors.err

info bla 3
more info
error 2

with the errorformat setting

set efm=%+Eerror\ %l,%-Winfo\ %m\ %l,%Zmore\ info

In the above errorfile, the first line is an information and is ignored (%-W), and the second line is a continuation of the first one. At the end, we expect that opening vim and calling :cg || copen shows us the error from the third line.

Instead, the quickfix window is empty.

If we replace %-W by %+W, we see the information and the error (as expected).

Similarly, if we add another error in front of the ignored information, we see both errors.

I suspect that the reason is that qfprev is not properly initalized in quickfix.c, but I am not sure.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Yegappan Lakshmanan

unread,
Oct 7, 2016, 12:50:14 AM10/7/16
to vim_dev, reply+00b1d198325b35f36b809a93a5eaedbc830e4b0...@reply.github.com, vim/vim
Hi,

On Tue, Sep 27, 2016 at 1:51 PM, Gerd Wachsmuth
<vim-dev...@256bit.org> wrote:
> Let us consider the errorfile errors.err
>
> info bla 3
> more info
> error 2
>
> with the errorformat setting
>
> set efm=%+Eerror\ %l,%-Winfo\ %m\ %l,%Zmore\ info
>
> In the above errorfile, the first line is an information and is ignored
> (%-W), and the second line is a continuation of the first one. At the end,
> we expect that opening vim and calling :cg || copen shows us the error from
> the third line.
>
> Instead, the quickfix window is empty.
>
> If we replace %-W by %+W, we see the information and the error (as
> expected).
>
> Similarly, if we add another error in front of the ignored information, we
> see both errors.
>
> I suspect that the reason is that qfprev is not properly initalized in
> quickfix.c, but I am not sure.
>

I can reproduce the problem and is reproducible even with older versions
of Vim (7.3). The issue is that the multiline error is started by %W and
ends with %Z without adding any errors. The quickfix list is also empty.
This results in an error processing the %Z line and the error entries after
that are skipped. If there is a valid error before %W or if %+W is used,
then the last error entry is set and it works as expected.

- Yegappan

vim-dev ML

unread,
Oct 7, 2016, 12:50:41 AM10/7/16
to vim/vim, vim-dev ML, Your activity
Hi,

On Tue, Sep 27, 2016 at 1:51 PM, Gerd Wachsmuth
<vim-dev...@256bit.org> wrote:
> Let us consider the errorfile errors.err
>
> info bla 3
> more info
> error 2
>
> with the errorformat setting
>
> set efm=%+Eerror\ %l,%-Winfo\ %m\ %l,%Zmore\ info
>
> In the above errorfile, the first line is an information and is ignored
> (%-W), and the second line is a continuation of the first one. At the end,
> we expect that opening vim and calling :cg || copen shows us the error from
> the third line.
>
> Instead, the quickfix window is empty.
>
> If we replace %-W by %+W, we see the information and the error (as
> expected).
>
> Similarly, if we add another error in front of the ignored information, we
> see both errors.
>
> I suspect that the reason is that qfprev is not properly initalized in
> quickfix.c, but I am not sure.
>

I can reproduce the problem and is reproducible even with older versions
of Vim (7.3). The issue is that the multiline error is started by %W and
ends with %Z without adding any errors. The quickfix list is also empty.
This results in an error processing the %Z line and the error entries after
that are skipped. If there is a valid error before %W or if %+W is used,
then the last error entry is set and it works as expected.

- Yegappan

Gerd Wachsmuth

unread,
Oct 7, 2016, 3:05:09 AM10/7/16
to vim/vim, vim-dev ML, Comment

The issue is that the multiline error is started by %W and ends with %Z without adding any errors.

In my opinion, it is not the issue that no %C is present:
With

set efm=%+Eerror\ %l,%-Winfo\ %m\ %l,%+Ceven\ more\ %m,%Zmore\ info

(note the %C line)
and the errorfile

info bla 3
even more info
more info
error 2

we do not see error 2 in the quickfix window.


You are receiving this because you commented.

LCD 47

unread,
Oct 7, 2016, 8:37:53 AM10/7/16
to reply+00b1d19870347f9e581f80204f39703016e9259...@reply.github.com, vim...@googlegroups.com
On 7 October 2016, Gerd Wachsmuth <vim-dev...@256bit.org> wrote:
> > The issue is that the multiline error is started by %W and ends with %Z without adding any errors.
> In my opinion, it is not the issue that no `%C` is present:
> With
>
> set efm=%+Eerror\ %l,%-Winfo\ %m\ %l,%+Ceven\ more\ %m,%Zmore\ info
> (note the `%C` line)
> and the errorfile
> ````
> info bla 3
> even more info
> more info
> error 2
> ````
> we do not see `error 2` in the quickfix window.

What seems to be going on here is that the first line gets matched
as `%-W` and `qf_parse_line()` returns `QF_IGNORE_LINE`. Then the
second line gets matched as `%+C`, it sets `%m`, but then it can't
find a previous line to continue since the previous line was ignored.
Consequently `qf_parse_line()` returns `QF_FAIL`, and `qf_init_ext()`
bails out at that point, silently ignoring any remaining input.

Possible solution:

```diff
diff --git a/src/quickfix.c b/src/quickfix.c
index 52abbeb..9139663 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -1010,6 +1010,8 @@ restofline:
}
else if (vim_strchr((char_u *)"CZ", idx) != NULL)
{ /* continuation of multi-line msg */
+ if (!qi->qf_multiignore)
+ {
qfline_T *qfprev = qi->qf_lists[qi->qf_curlist].qf_last;

if (qfprev == NULL)
@@ -1043,6 +1045,7 @@ restofline:
? fields->namebuf
: qi->qf_currfile != NULL && fields->valid
? qi->qf_currfile : 0);
+ }
if (idx == 'Z')
qi->qf_multiline = qi->qf_multiignore = FALSE;
line_breakcheck();
```

/lcd

vim-dev ML

unread,
Oct 7, 2016, 8:38:38 AM10/7/16
to vim/vim, vim-dev ML, Your activity

Bram Moolenaar

unread,
Oct 8, 2016, 10:44:20 AM10/8/16
to LCD 47, reply+00b1d19870347f9e581f80204f39703016e9259...@reply.github.com, vim...@googlegroups.com
Could you write a test that covers this?

--
There can't be a crisis today, my schedule is already full.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

vim-dev ML

unread,
Oct 8, 2016, 10:44:48 AM10/8/16
to vim/vim, vim-dev ML, Your activity

> Lcd wrote:
>
> On 7 October 2016, Gerd Wachsmuth <vim-dev...@256bit.org> wrote:
> > > The issue is that the multiline error is started by %W and ends with %Z without adding any errors.
> > In my opinion, it is not the issue that no `%C` is present:
> > With
> >
> > set efm=%+Eerror\ %l,%-Winfo\ %m\ %l,%+Ceven\ more\ %m,%Zmore\ info
> > (note the `%C` line)
> > and the errorfile
> > ````
> > info bla 3
> > even more info
> > more info
> > error 2
> > ````
> > we do not see `error 2` in the quickfix window.
>
> What seems to be going on here is that the first line gets matched
> as `%-W` and `qf_parse_line()` returns `QF_IGNORE_LINE`. Then the
> second line gets matched as `%+C`, it sets `%m`, but then it can't
> find a previous line to continue since the previous line was ignored..

LCD 47

unread,
Oct 9, 2016, 2:07:15 AM10/9/16
to Bram Moolenaar, reply+00b1d19870347f9e581f80204f39703016e9259...@reply.github.com, vim...@googlegroups.com
Done:

https://gist.github.com/lcd047/4d4adb7e77fe29d9a8313c27fd42db25

(the diff is a lot bigger because of re-indentation).

/lcd

vim-dev ML

unread,
Oct 9, 2016, 2:07:45 AM10/9/16
to vim/vim, vim-dev ML, Your activity

Bram Moolenaar

unread,
Oct 9, 2016, 10:10:28 AM10/9/16
to LCD 47, reply+00b1d19870347f9e581f80204f39703016e9259...@reply.github.com, vim...@googlegroups.com
Thanks. I find it a bit hard to describe the problem and the fix.
Well, let's just keep it high level.

--
TALL KNIGHT: When you have found the shrubbery, then you must cut down the
mightiest tree in the forest ... with a herring.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

vim-dev ML

unread,
Oct 9, 2016, 10:11:14 AM10/9/16
to vim/vim, vim-dev ML, Your activity

Bram Moolenaar

unread,
Oct 9, 2016, 10:22:57 AM10/9/16
to vim/vim, vim-dev ML, Comment

Fixed by patch 8.0.0026


You are receiving this because you commented.

Bram Moolenaar

unread,
Oct 9, 2016, 10:23:14 AM10/9/16
to vim/vim, vim-dev ML, Comment

Closed #1126.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages