Subject: bin/6204: ctags gets confused by typedef int (*f_t) ...
To: None <gnats-bugs@gnats.netbsd.org>
From: None <root@RVC1.Informatik.BA-Stuttgart.DE>
List: netbsd-bugs
Date: 09/26/1998 18:44:18
>Number:         6204
>Category:       bin
>Synopsis:       ctags gets confused by typedef int (*f_t) ...
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 26 09:50:01 1998
>Last-Modified:
>Originator:     Wolfgang Helbig
>Organization:
	
>Release:        NetBSD 1.3.2
>Environment:
	
System: NetBSD RVC1 1.3.2 NetBSD 1.3.2 (RVC1) #12: Mon Sep 21 01:52:18 CEST 1998 helbig@RVC1:/usr/src/sys/arch/i386/compile/RVC1 i386


>Description:
	if ctags(1) is working on a typedef whose declarator contains
	parenthesis, it won't recognize the typedef'd symbol and won't
	recognize the definition following the typedef statement.
>How-To-Repeat:
Run "ctags -t file.c" with file.c containing:

	typedef a (*b) _P((c *));
	struct s {
		int	i;
	};

This will give you the following tags file:

	a	test.h	/^typedef a (*b) _P((c *));$/
	^ Should be "b", because "b" is typedef'd not "a".
	i	test.h	/^};$/
	^ This entry shouldn't be there, instead the "s" should be listed.

>Fix:

Here is a patch that partially fixes the problem: The "struct b" will
be listed properly but the typedef'd symbol is still wrong, i. e.
you'll get from file.c the tags file:

	c	test.h	/^typedef a (*b) _P((c *));$/
	^ Still wrong.
	s	test.h	/^struct s {$/
	^ now correct.

--- /usr/src/usr.bin/ctags/C.c.orig	Sat Sep 26 17:57:37 1998
+++ usr.bin/ctags/C.c	Sat Sep 26 17:58:13 1998
@@ -146,7 +146,7 @@
 		 * level zero indicates a function.
 		 */
 		case '(':
-			if (!level && token) {
+			if (!level && token && !t_def) {
 				int	curline;
 
 				if (sp != tok)
>Audit-Trail:
>Unformatted: