[comp.unix.questions] tag files for preprocessor macros?

brian@dip.eecs.umich.edu (Brian Holtz) (02/02/90)

Is there a tool like ctags or etags that also generates tags for
preprocessor-#define'd symbols and macros?

dan@charyb.COM (Dan Mick) (02/17/90)

In article <1345@zipeecs.umich.edu> brian@dip.eecs.umich.edu (Brian Holtz) writes:
>Is there a tool like ctags or etags that also generates tags for
>preprocessor-#define'd symbols and macros?

Eh?  My ctags does.  As a matter of fact, the third paragraph of the man
page states that explicitly.  Have you R'ed TFM?

maart@cs.vu.nl (Maarten Litmaath) (02/17/90)

In article <1345@zipeecs.umich.edu>,
	brian@dip.eecs.umich.edu (Brian Holtz) writes:
)Is there a tool like ctags or etags that also generates tags for
)preprocessor-#define'd symbols and macros?

--------------------cut here--------------------
#!/bin/sh
# @(#)cpptags 1.3 90/01/05 Maarten Litmaath

tags=tags

case $1 in
-f)
	tags=$2
	shift 2
esac

case $# in
0)
	exit
esac

tab="	"
expr="^[ $tab]*#[ $tab]*define[ $tab]*\\([A-Za-z_][A-Za-z_0-9]*\\).*"
AWK='
	$1 == tag {
		print "Duplicate entry in files " $2 " and " file ": " $1
	}
	{
		tag = $1
		file = $2
	}
'

for i
do
	sed -e "/$expr/!d" -e 's-[\\/]-\\&-g' \
		-e "s|$expr|\\1$tab$i$tab/^&\$/|" $i
done | sort | tee $tags | awk "$AWK" >&2
--------------------cut here--------------------
--
  The meek get the earth, Henry the moon, the rest of us have other plans.  |
  Maarten Litmaath @ VU Amsterdam:  maart@cs.vu.nl,  uunet!mcsun!botter!maart

holtz@zurich.csmil.umich.edu (Brian Holtz) (02/19/90)

In article <369@charyb.COM> dan@charyb.UUCP (Dan Mick) writes:
>In article <1345@zipeecs.umich.edu> brian@dip.eecs.umich.edu (Brian Holtz) writes:
>>Is there a tool like ctags or etags that also generates tags for
>>preprocessor-#define'd symbols and macros?
>
>Eh?  My ctags does.  As a matter of fact, the third paragraph of the man
>page states that explicitly.  Have you R'ed TFM?


Yep, and the etags source, too.  Neither ctags nor etags generates tags
for simple preprocessor definitions or even argument-less preprocessor
macros.  Also, neither generates tags for macros defined when any
curly braces are open, which is a lot of places in, say, the X11
include files, with their ifdef'd-out support for C++:

#ifdef __cplusplus
extern "C" {
#endif

/* ... file-full of stuff ... */

#ifdef __cplusplus
}
#endif

In etags, at least, the reason for this is that macros are tagged
only when they occur in places that a regular function could.
Now, I can understand ifdef'd braces fooling you about functions,
since you don't want to preprocess the file just to get tags out,
but preprocessor definitions are a separate matter altogether.

Anyone with a higher tolerance for rats' nests of goto's than I have
is welcome to modify gnu etags and fix the problem.