etags should optionally tag all macros
Dave Brennan
brennan at rtp.dg.com
Thu May 31 10:16:23 AEST 1990
I've been writing some code that uses a lot macros to hide structure
information from modules that need to know about specific data structures,
and often need to find the macro definitions to make additions or changes.
But, alas, etags only generates tags for macros with paramaters.
I just couldn't live with this behavior, so I had to make some changes
to etags to make this work. I putting the patch here in the hope other
people will find it useful. To make etags generate tag entries for all
macros just use the "-d" flag when running it.
I'd also be interested in any other etags enhancements. It'd be easy
to make etags recognize other tags (like struct, union and enum tags) but
macro tags are the only ones I feel like I have time to change right now.
I just use typedefs for my structs, unions, and enums - a case which is
already handled.
Anyhow, here's the patch:
*** etags.c.dist Wed May 30 18:16:23 1990
--- etags.c Wed May 30 19:51:12 1990
***************
*** 185,188 ****
--- 185,189 ----
int file_num = 0; /* current file number */
int aflag = 0; /* -a: append to tags */
+ int dflag = 0; /* -d: create tags for #define macros */
int tflag = 0; /* -t: create tags for typedefs */
int uflag = 0; /* -u: update tags */
***************
*** 291,294 ****
--- 292,298 ----
aflag++;
break;
+ case 'd':
+ dflag++;
+ break;
case 'e':
eflag++;
***************
*** 346,350 ****
fprintf (stderr, "Usage: %s [-aetwvx] [-f outfile] file ...\n", progname);
#else
! fprintf (stderr, "Usage: %s [-BFaetuwvx] [-f outfile] file ...\n", progname);
#endif
exit(BAD);
--- 350,354 ----
fprintf (stderr, "Usage: %s [-aetwvx] [-f outfile] file ...\n", progname);
#else
! fprintf (stderr, "Usage: %s [-BFadetuwvx] [-f outfile] file ...\n", progname);
#endif
exit(BAD);
***************
*** 861,865 ****
continue;
case '#':
! if (lp == lb.buffer + 1)
number = 1;
continue;
--- 865,869 ----
continue;
case '#':
! if (lp == lb.buffer + 1) /* remember if the # is in column 1 */
number = 1;
continue;
***************
*** 950,954 ****
reg char *lp = *lpp;
reg char c;
! static logical next_token_is_func;
logical firsttok; /* T if have seen first token in ()'s */
int bad, win = 0;
--- 954,958 ----
reg char *lp = *lpp;
reg char c;
! static logical next_token_is_func = 0, next_token_is_define = 0;
logical firsttok; /* T if have seen first token in ()'s */
int bad, win = 0;
***************
*** 970,974 ****
}
/* the following tries to make it so that a #define a b(c) */
! /* doesn't count as a define of b. */
}
else
--- 974,982 ----
}
/* the following tries to make it so that a #define a b(c) */
! /* doesn't count as a define of b. The token is bad if it */
! /* is `define' and the first one after the #, or if it is */
! /* not the second token on the line. However, if dflag is */
! /* set, then the macro is valid no matter what. */
!
}
else
***************
*** 975,978 ****
--- 983,998 ----
{
number++;
+ if (number==2 && !strncmp (token, "define", 6) && dflag)
+ {
+ next_token_is_define = 1;
+ goto badone;
+ }
+ if (next_token_is_define)
+ {
+ next_token_is_define = 0;
+ *f = 0;
+ win = 1;
+ goto ret;
+ }
if (number >= 4 || (number==2 && strncmp (token, "define", 6)))
{
***************
*** 1017,1021 ****
/* Detect GNUmacs's function-defining macros. */
if (!number && !strncmp (token, "DEF", 3))
-
{
next_token_is_func = 1;
--- 1037,1040 ----
|\
Dave Brennan | \____oo_ brennan at rtp.dg.com
=========================================((__| /___> ...rti!dg-rtp!brennan
User Interfaces, Data General | // daveb at rpitsmts.bitnet
Research Triangle Park, NC |// Phone: (919) 248-6330
More information about the Comp.lang.c
mailing list