Deal with the gnu __attribute__ keyword, which is in an odd place and

breaks the ctags function-recognition algorithm.
This commit is contained in:
ross 1998-07-24 07:30:08 +00:00
parent 1c2f0a15fd
commit 3c35d73f31
1 changed files with 33 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: C.c,v 1.4 1997/10/18 13:18:15 lukem Exp $ */ /* $NetBSD: C.c,v 1.5 1998/07/24 07:30:08 ross Exp $ */
/* /*
* Copyright (c) 1987, 1993, 1994 * Copyright (c) 1987, 1993, 1994
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)C.c 8.4 (Berkeley) 4/2/94"; static char sccsid[] = "@(#)C.c 8.4 (Berkeley) 4/2/94";
#else #else
__RCSID("$NetBSD: C.c,v 1.4 1997/10/18 13:18:15 lukem Exp $"); __RCSID("$NetBSD: C.c,v 1.5 1998/07/24 07:30:08 ross Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -251,6 +251,9 @@ func_entry()
{ {
int c; /* current character */ int c; /* current character */
int level = 0; /* for matching '()' */ int level = 0; /* for matching '()' */
static char attribute[] = "__attribute__";
char maybe_attribute[sizeof attribute + 1],
*anext;
/* /*
* Find the end of the assumed function declaration. * Find the end of the assumed function declaration.
@ -288,10 +291,37 @@ fnd:
* is a token character if it's a function and a non-token * is a token character if it's a function and a non-token
* character if it's a declaration. Comments don't count... * character if it's a declaration. Comments don't count...
*/ */
for (;;) { for (anext = maybe_attribute;;) {
while (GETC(!=, EOF) && iswhite(c)) while (GETC(!=, EOF) && iswhite(c))
if (c == '\n') if (c == '\n')
SETLINE; SETLINE;
if (c == EOF)
return NO;
/*
* Recognize the gnu __attribute__ extension, which would
* otherwise make the heuristic test DTWT
*/
if (anext == maybe_attribute) {
if (intoken(c)) {
*anext++ = c;
continue;
}
} else {
if (intoken(c)) {
if (anext - maybe_attribute
< sizeof attribute - 1)
*anext++ = c;
else break;
continue;
} else {
*anext++ = '\0';
if (strcmp(maybe_attribute, attribute) == 0) {
(void)ungetc(c, inf);
return NO;
}
break;
}
}
if (intoken(c) || c == '{') if (intoken(c) || c == '{')
break; break;
if (c == '/' && GETC(==, '*')) if (c == '/' && GETC(==, '*'))