On 21 February 2014, Bram Moolenaar <[email protected]> wrote:
> 
> lcd wrote:
> 
> >     Copied to vim_dev, now with 100% more content. :)
> > 
> >     /lcd
> > 
> > ----- Forwarded message from LCD 47 <[email protected]> -----
> > 
> > From: LCD 47 <[email protected]>
> > Date: Thu, 20 Feb 2014 15:06:53 +0200
> > To: [email protected]
> > Subject: Re: errorformat/cexpr bug?
> > 
> > On 19 February 2014, Aaron Bohannon <[email protected]> wrote:
> > > Over the years, I have wasted many hours of my life on trying to
> > > write errorformat patterns -- and many times having to give up in
> > > defeat.  Now, finally, I've managed to trace down a behavior that
> > > could explain all those hours of frustration.
> > >
> > > The meaning of the errorformat option is so arcane, though,
> > > that I cannot know for sure whether this is actually a bug in
> > > the implementation or simply the intended behavior.  If it's
> > > intentional, can someone *please* explain to me why it works like
> > > this?
> > > 
> > > :echo string(&efm)
> > > 
> > >     '%+CXXX,%+EERROR,%+IINFO,%-GYYY'
> > > 
> > > :cgetexpr ['INFO', 'ERROR', 'XXX']
> > > :echomsg string(getqflist()[0].text) string(getqflist()[1].text)
> > > 
> > >     'INFO' 'ERROR^@XXX'
> > > 
> > > :cgetexpr ['INFO', 'YYY', 'ERROR', 'XXX']
> > > :echomsg string(getqflist()[0].text) string(getqflist()[1].text)
> > > 
> > >    'INFO' 'ERROR'
> > 
> >     Yeah, this one looks like a bug.  What seems o be going on here
> > is that 'YYY' matches '%-GYYY', which sets the multiignore flag,
> > which doesn't get reset until 'XXX' is seen.  Which basically means
> > 'XXX' is matched as '%-CXXX', thus ignored.
> > 
> > > :cgetexpr ['INFO', 'YYY', 'ZZZ', 'ERROR', 'XXX']
> > > :echomsg string(getqflist()[0].text) string(getqflist()[1].text) 
> > > string(getqflist()[2].text)
> > > 
> > >    'INFO' 'ZZZ' 'ERROR^@XXX'
> > 
> >     In this case multiignore gets set at 'YYY', but then gets reset
> > when 'ZZZ' is seen.  Thus the subsequent 'XXX' is correctly matched
> > as '%+CXXX'.
> >
> >     The patch below seems to fix the problem for this particular
> > case, but the context is pretty involved.  F.i. what about O/P/Q?
> > It would be a good idea to have more pairs of eyes look at it.
>
> It would also be good to have tests. test 10 already does some, but
> not much.

    I already wrote a small test for the particular problem described
above, without really looking for "prior art".  It's from a pretty
different mindset than test 10 though, I'm not sure they should be
merged.

    /lcd


diff -r 7ea91c82839f src/quickfix.c
--- a/src/quickfix.c    Sat Feb 15 19:47:51 2014 +0100
+++ b/src/quickfix.c    Thu Feb 20 18:47:22 2014 +0200
@@ -751,7 +751,10 @@
                fmt_start = fmt_ptr;
 
            if (vim_strchr((char_u *)"AEWI", idx) != NULL)
+           {
                multiline = TRUE;       /* start of a multi-line message */
+               multiignore = FALSE;    /* reset continuation */
+           }
            else if (vim_strchr((char_u *)"CZ", idx) != NULL)
            {                           /* continuation of multi-line msg */
                if (qfprev == NULL)
diff -r 7ea91c82839f src/testdir/Make_amiga.mak
--- a/src/testdir/Make_amiga.mak        Sat Feb 15 19:47:51 2014 +0100
+++ b/src/testdir/Make_amiga.mak        Thu Feb 20 18:47:22 2014 +0200
@@ -35,7 +35,7 @@
                test89.out test90.out test91.out test92.out test93.out \
                test94.out test95.out test96.out test97.out test98.out \
                test99.out test100.out test101.out test102.out test103.out \
-               test104.out
+               test104.out test105.out
 
 .SUFFIXES: .in .out
 
@@ -156,3 +156,4 @@
 test102.out: test102.in
 test103.out: test103.in
 test104.out: test104.in
+test105.out: test105.in
diff -r 7ea91c82839f src/testdir/Make_dos.mak
--- a/src/testdir/Make_dos.mak  Sat Feb 15 19:47:51 2014 +0100
+++ b/src/testdir/Make_dos.mak  Thu Feb 20 18:47:22 2014 +0200
@@ -33,7 +33,8 @@
                test84.out test85.out test86.out test87.out test88.out \
                test89.out test90.out test91.out test92.out test93.out \
                test94.out test95.out test96.out test98.out test99.out \
-               test100.out test101.out test102.out test103.out test104.out
+               test100.out test101.out test102.out test103.out \
+               test104.out test105.out
 
 SCRIPTS32 =    test50.out test70.out
 
diff -r 7ea91c82839f src/testdir/Make_ming.mak
--- a/src/testdir/Make_ming.mak Sat Feb 15 19:47:51 2014 +0100
+++ b/src/testdir/Make_ming.mak Thu Feb 20 18:47:22 2014 +0200
@@ -53,7 +53,8 @@
                test84.out test85.out test86.out test87.out test88.out \
                test89.out test90.out test91.out test92.out test93.out \
                test94.out test95.out test96.out test98.out test99.out \
-               test100.out test101.out test102.out test103.out test104.out
+               test100.out test101.out test102.out test103.out \
+               test104.out test105.out
 
 SCRIPTS32 =    test50.out test70.out
 
diff -r 7ea91c82839f src/testdir/Make_os2.mak
--- a/src/testdir/Make_os2.mak  Sat Feb 15 19:47:51 2014 +0100
+++ b/src/testdir/Make_os2.mak  Thu Feb 20 18:47:22 2014 +0200
@@ -35,7 +35,8 @@
                test81.out test82.out test83.out test84.out test88.out \
                test89.out test90.out test91.out test92.out test93.out \
                test94.out test95.out test96.out test98.out test99.out \
-               test100.out test101.out test102.out test103.out test104.out
+               test100.out test101.out test102.out test103.out \
+               test104.out test105.out
 
 .SUFFIXES: .in .out
 
diff -r 7ea91c82839f src/testdir/Make_vms.mms
--- a/src/testdir/Make_vms.mms  Sat Feb 15 19:47:51 2014 +0100
+++ b/src/testdir/Make_vms.mms  Thu Feb 20 18:47:22 2014 +0200
@@ -79,7 +79,8 @@
         test82.out test83.out test84.out test88.out test89.out \
         test90.out test91.out test92.out test93.out test94.out \
         test95.out test96.out test97.out test98.out test99.out \
-        test100.out test101.out test102.out test103.out test104.out
+        test100.out test101.out test102.out test103.out \
+        test104.out test105.out
 
 # Known problems:
 # Test 30: a problem around mac format - unknown reason
diff -r 7ea91c82839f src/testdir/Makefile
--- a/src/testdir/Makefile      Sat Feb 15 19:47:51 2014 +0100
+++ b/src/testdir/Makefile      Thu Feb 20 18:47:22 2014 +0200
@@ -31,7 +31,7 @@
                test89.out test90.out test91.out test92.out test93.out \
                test94.out test95.out test96.out test97.out test98.out \
                test99.out test100.out test101.out test102.out test103.out \
-               test104.out
+               test104.out test105.out
 
 SCRIPTS_GUI = test16.out
 
diff -r 7ea91c82839f src/testdir/test105.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test105.in    Thu Feb 20 18:47:22 2014 +0200
@@ -0,0 +1,16 @@
+Tests for errorformat.  vim: set ft=vim ts=8 :
+
+STARTTEST
+:so small.vim
+:if !has('quickfix') | e! test.ok | wq! test.out | endif
+:set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%#
+:cgetexpr ['WWWW', 'EEEE', 'CCCC']
+:$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
+:cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC']
+:$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
+:cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY']
+:$put =strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]')))
+:/^Results/,$wq! test.out
+ENDTEST
+
+Results of test105:
diff -r 7ea91c82839f src/testdir/test105.ok
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test105.ok    Thu Feb 20 18:47:22 2014 +0200
@@ -0,0 +1,4 @@
+Results of test105:
+[['W', 1], ['E^@CCCC', 1]]
+[['W', 1], ['E^@CCCC', 1]]
+[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]

-- 
-- 
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/groups/opt_out.

Raspunde prin e-mail lui