I'm resubmitting this, clarifying a few points and fixing a typo in
the process, because I've seen no responses.  Sorry if this
is premature: I know it could be due to people being busy.
Hopefully the parts I've rephrased will be clearer than my 
earlier post.

I have been trying to improve the quickfix facilities 
obtainable from gcc.   The file I have in vim7 is quoted
here for completeness, in case I should be using a later
version:

<quote>
" Vim compiler file
" Compiler:         GNU C Compiler
" Maintainer:       Nikolai Weibull <[EMAIL PROTECTED]>
" Latest Revision:  2006-04-19

if exists("current_compiler")
  finish
endif
let current_compiler = "gcc"

let s:cpo_save = &cpo
set cpo-=C

setlocal errorformat=
      \%*[^\"]\"%f\"%*\\D%l:\ %m,
      \\"%f\"%*\\D%l:\ %m,
      \%-G%f:%l:\ %trror:\ (Each\ undeclared\ identifier\ is\ reported\ only\ 
once,
      \%-G%f:%l:\ %trror:\ for\ each\ function\ it\ appears\ in.),
      \%f:%l:\ %m,
      \\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,
      \%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',
      \%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',
      \%DMaking\ %*\\a\ in\ %f

let &cpo = s:cpo_save
unlet s:cpo_save
</quote>

and I have modified it thusly:

--- /usr/local/share/vim/vim70/compiler/gcc.vim 2006-07-19 18:11:22.117752000 
+0100
+++ /home/hgs/.vim/compiler/gcc.vim     2006-11-22 18:33:39.269332000 +0000
@@ -16,6 +16,8 @@
       \\"%f\"%*\\D%l:\ %m,
       \%-G%f:%l:\ %trror:\ (Each\ undeclared\ identifier\ is\ reported\ only\ 
once,
       \%-G%f:%l:\ %trror:\ for\ each\ function\ it\ appears\ in.),
+      \%E%f:%l:\ multiple\ definitions\ of\ %m,
+      \%Z%*\\s:%f:%l:\ first\ defined\ here,
       \%f:%l:\ %m,
       \\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,
       \%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',

This is being picked up correctly (I know because of introducing bugs
in it, which I have fixed).  But when I get results like:

/home/hgs/fsv/rawimage.c:97: multiple definition of `image_check_is_png'
image.o:/home/hgs/fsv/image.c:97: first defined here

vim tries to pickup a file called image.o:/home/hgs/fsv/image.c 
for the second line (:cn) which clearly doesn't exist.

I have tried the following forms of this line in order to modify
what is detected before the %f (which seems to be greedy to its
left[!]):

      \%Z%*\\s:%f:%l:\ first\ defined\ here,
      \%Z%.%#:%f:%l:\ first\ defined\ here,
      \%Z%*[^:]:%f:%l:\ first\ defined\ here,
      \%Z%m:%f:%l:\ first\ defined\ here,
      \%Z%*f:%f:%l:\ first\ defined\ here,

The latter of which complains about 2 %f symbols in the line, despite the
first having a * in it.

        %*{conv}        any scanf non-assignable conversion

would seem to suggest I could do that.  I suspect now that this
only applies to the \\ based conversions, having looked at the 
C source, which I don't fully understand.

Also I can find no examples in the supplied help or supplied compiler files,
or on the web, how to use 
<quote>
        %s              search text (finds a string)
  [...]
The "%s" conversion specifies the text to search for to locate the error line.
The text is used as a literal string.  The anchors "^" and "$" are added to
the text to locate the error line exactly matching the search text and the
text is prefixed with the "\V" atom to make it "very nomagic".  The "%s"
conversion can be used to locate lines without a line number in the error
output.  Like the output of the "grep" shell command.
When the pattern is present the line number will not be used.
</quote>

Does the string come after the %s?  Does Vim, or the author of the
errorformat add the "^" and "$", and if the latter, are they compulsory
delimiters of the string?  The C source suggests to me that this 
isn't fully implemented yet, and it may just mean one character for 
now, but I don't fully understand the intentions behind that code
from reading it.

Is there any way to get vim to log what happens when errrorformats are 
matched, so one can debug this stuff more easily?

How should I be tackling the access of just the source file I want?

I'd like to understand this better, because I can then contribute
my amended compiler file, and possibly other later.

        Thank you
        Hugh

Reply via email to