Re: [Ctags] Exuberant Ctags problem with extern ... INIT
Brought to you by:
dhiebert
From: James A P. <Jam...@ae...> - 2001-11-28 23:46:45
|
> On Wed, 14 Nov 2001, James A Paget wrote: > > > ...in the application I am working on, Exuberant Ctags fails to > > find a few of the tags. The problem occurs in files such as > > include.h, listed below: > > > > #ifdef ALLOCATE > > #define extern > > #define INIT(A) = (A) > > #else > > #define INIT(A) > > #endif > > > > extern int unfound INIT(0); > > > > I have tried to get ctags to include unfound, but to no avail. Here are > > two approaches I tried, neither of which resulted in a tag for "unfound": > > > > ctags -f - -I INIT== include.h > This works for me. I do not know why this does not work for you. > I put the above text exactly into a file and ran it exactly as you > indicated. I've tried this using Exuberant Ctags 5.1 on Windows 2000 and it still does not work. I'm attaching a zip file with include.h, tags1.bat ("ctags -f output1 -I INIT== include.h"), and output1 so you can reproduce the situation exactly. There are 3 tags, but none for "unfound". (See attached file: tags.zip) > There are 3 other possible ways to make this work: > > 1. Tags for external variable declarations are not included in the > output by default. You can change this default by adding the > option "--c++-types=+x" > > 2. Make ctags ignore the "extern" by adding the option "-I extern". These are no help; I want a tag only if "extern" appears with "INIT". > 3. The "INIT(0);" call throws off the parser. To make the parser > ignore it, use the option "-I INIT+". Still no tag for "unfound"; see tags2.bat and output2, included in the zip file above. > > > ctags -f - -n "--regex-C++=/extern\(.*\)INIT\(.*\)/\1 = \2/" include.h > > This does not work because the regular expressions that ctags uses > are POSIX "extended regular expressions", which already treat "(" > and ")" as metacharacters; by escaping them, you were indicating > they should be treated as literals. Removing these causes the line > to be matched: > > > ctags -f - -n "--regex-C++=/extern(.*)INIT(.*)/\1 = \2/" include.h Where can I find documentation for the precise syntax for POSIX "extended regular expressions"? Running "man -s 5 regex" on Solaris 2.6 led me to believe that "(" is a normal character and "\(" is the metacharacter. This is also true for regular expressions in vim. > However, this uncovered a bug in the regex handling in ctags, where > the \2 contained the terminating newline and messed up the tag file. > I have fixed this for the next minor release. This seems to work fine for me in Windows 2000 with ctags 5.1. See tags3.bat and output3 in the zip file. -- Jim Paget |