35 |
* |
* |
36 |
*/ |
*/ |
37 |
|
|
38 |
char pot_etags_version[] = "@(#) pot revision number is 16.42"; |
char pot_etags_version[] = "@(#) pot revision number is 16.46"; |
39 |
|
|
40 |
#define TRUE 1 |
#define TRUE 1 |
41 |
#define FALSE 0 |
#define FALSE 0 |
459 |
static bool no_warnings; /* -w: suppress warnings */ |
static bool no_warnings; /* -w: suppress warnings */ |
460 |
static bool cxref_style; /* -x: create cxref style output */ |
static bool cxref_style; /* -x: create cxref style output */ |
461 |
static bool cplusplus; /* .[hc] means C++, not C */ |
static bool cplusplus; /* .[hc] means C++, not C */ |
462 |
static bool noindentypedefs; /* -I: ignore indentation in C */ |
static bool ignoreindent; /* -I: ignore indentation in C */ |
463 |
static bool packages_only; /* --packages-only: in Ada, only tag packages*/ |
static bool packages_only; /* --packages-only: in Ada, only tag packages*/ |
464 |
|
|
465 |
#define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */ |
#define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */ |
775 |
Do not create tag entries for global variables in some\n\ |
Do not create tag entries for global variables in some\n\ |
776 |
languages. This makes the tags file smaller."); |
languages. This makes the tags file smaller."); |
777 |
puts ("--members\n\ |
puts ("--members\n\ |
778 |
Create tag entries for member variables in C and derived languages."); |
Create tag entries for member variables in some languages."); |
779 |
|
|
780 |
#ifdef ETAGS_REGEXPS |
#ifdef ETAGS_REGEXPS |
781 |
puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ |
puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ |
782 |
Make a tag for each line matching the regular expression pattern\n\ |
Make a tag for each line matching a regular expression pattern\n\ |
783 |
in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\ |
in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\ |
784 |
files only. REGEXFILE is a file containing one REGEXP per line.\n\ |
files only. REGEXFILE is a file containing one REGEXP per line.\n\ |
785 |
REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\ |
REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\ |
789 |
--regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\".\n\ |
--regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\".\n\ |
790 |
MODS are optional one-letter modifiers: `i' means to ignore case,\n\ |
MODS are optional one-letter modifiers: `i' means to ignore case,\n\ |
791 |
`m' means to allow multi-line matches, `s' implies `m' and\n\ |
`m' means to allow multi-line matches, `s' implies `m' and\n\ |
792 |
causes dot to match the newline character as well."); |
causes dot to match any character, including newline."); |
793 |
puts ("-R, --no-regex\n\ |
puts ("-R, --no-regex\n\ |
794 |
Don't create tags from regexps for the following files."); |
Don't create tags from regexps for the following files."); |
795 |
#endif /* ETAGS_REGEXPS */ |
#endif /* ETAGS_REGEXPS */ |
796 |
puts ("-I, --ignore-indentation\n\ |
puts ("-I, --ignore-indentation\n\ |
797 |
Don't rely on indentation quite as much as normal. Currently,\n\ |
In C and C++ do not assume that a closing brace in the first\n\ |
798 |
this means not to assume that a closing brace in the first\n\ |
column is the final brace of a function or structure definition."); |
|
column is the final brace of a function or structure\n\ |
|
|
definition in C and C++."); |
|
799 |
puts ("-o FILE, --output=FILE\n\ |
puts ("-o FILE, --output=FILE\n\ |
800 |
Write the tags to FILE."); |
Write the tags to FILE."); |
801 |
puts ("--parse-stdin=NAME\n\ |
puts ("--parse-stdin=NAME\n\ |
1068 |
break; |
break; |
1069 |
case 'I': |
case 'I': |
1070 |
case 'S': /* for backward compatibility */ |
case 'S': /* for backward compatibility */ |
1071 |
noindentypedefs = TRUE; |
ignoreindent = TRUE; |
1072 |
break; |
break; |
1073 |
case 'l': |
case 'l': |
1074 |
{ |
{ |
2593 |
} cstack; /* stack for nested declaration tags */ |
} cstack; /* stack for nested declaration tags */ |
2594 |
/* Current struct nesting depth (namespace, class, struct, union, enum). */ |
/* Current struct nesting depth (namespace, class, struct, union, enum). */ |
2595 |
#define nestlev (cstack.nl) |
#define nestlev (cstack.nl) |
2596 |
/* After struct keyword or in struct body, not inside an nested function. */ |
/* After struct keyword or in struct body, not inside a nested function. */ |
2597 |
#define instruct (structdef == snone && nestlev > 0 \ |
#define instruct (structdef == snone && nestlev > 0 \ |
2598 |
&& cblev == cstack.cblev[nestlev-1] + 1) |
&& cblev == cstack.cblev[nestlev-1] + 1) |
2599 |
|
|
2986 |
#define curlinepos (lbs[curndx].linepos) |
#define curlinepos (lbs[curndx].linepos) |
2987 |
#define newlinepos (lbs[newndx].linepos) |
#define newlinepos (lbs[newndx].linepos) |
2988 |
|
|
2989 |
|
#define cplpl ((c_ext & C_PLPL) == C_PLPL) |
2990 |
|
#define cjava ((c_ext & C_JAVA) == C_JAVA) |
2991 |
|
|
2992 |
#define CNL_SAVE_DEFINEDEF() \ |
#define CNL_SAVE_DEFINEDEF() \ |
2993 |
do { \ |
do { \ |
2994 |
curlinepos = charno; \ |
curlinepos = charno; \ |
3053 |
int parlev; /* current parenthesis level */ |
int parlev; /* current parenthesis level */ |
3054 |
int typdefcblev; /* cblev where a typedef struct body begun */ |
int typdefcblev; /* cblev where a typedef struct body begun */ |
3055 |
bool incomm, inquote, inchar, quotednl, midtoken; |
bool incomm, inquote, inchar, quotednl, midtoken; |
|
bool cplpl, cjava; |
|
3056 |
bool yacc_rules; /* in the rules part of a yacc file */ |
bool yacc_rules; /* in the rules part of a yacc file */ |
3057 |
struct tok savetoken; /* token saved during preprocessor handling */ |
struct tok savetoken; /* token saved during preprocessor handling */ |
3058 |
|
|
3079 |
token.valid = savetoken.valid = FALSE; |
token.valid = savetoken.valid = FALSE; |
3080 |
cblev = 0; |
cblev = 0; |
3081 |
parlev = 0; |
parlev = 0; |
|
cplpl = (c_ext & C_PLPL) == C_PLPL; |
|
|
cjava = (c_ext & C_JAVA) == C_JAVA; |
|
3082 |
if (cjava) |
if (cjava) |
3083 |
{ qualifier = "."; qlen = 1; } |
{ qualifier = "."; qlen = 1; } |
3084 |
else |
else |
3393 |
fvdef = finlist; |
fvdef = finlist; |
3394 |
continue; |
continue; |
3395 |
case flistseen: |
case flistseen: |
3396 |
make_C_tag (TRUE); /* a function */ |
#if 0 |
3397 |
|
if (!instruct || members) |
3398 |
|
#endif |
3399 |
|
make_C_tag (TRUE); /* a function */ |
3400 |
fvdef = fignore; |
fvdef = fignore; |
3401 |
break; |
break; |
3402 |
case fvnameseen: |
case fvnameseen: |
3450 |
break; |
break; |
3451 |
} |
} |
3452 |
if (structdef == stagseen) |
if (structdef == stagseen) |
3453 |
structdef = scolonseen; |
{ |
3454 |
|
structdef = scolonseen; |
3455 |
|
break; |
3456 |
|
} |
3457 |
|
#if 0 |
3458 |
|
if (cplpl && fvdef == flistseen) |
3459 |
|
{ |
3460 |
|
make_C_tag (TRUE); /* a function */ |
3461 |
|
fvdef = fignore; |
3462 |
|
break; |
3463 |
|
} |
3464 |
|
#endif |
3465 |
break; |
break; |
3466 |
case ';': |
case ';': |
3467 |
if (definedef != dnone) |
if (definedef != dnone) |
3480 |
switch (fvdef) |
switch (fvdef) |
3481 |
{ |
{ |
3482 |
case fignore: |
case fignore: |
3483 |
if (typdef == tignore) |
if (typdef == tignore || cplpl) |
3484 |
fvdef = fvnone; |
fvdef = fvnone; |
3485 |
break; |
break; |
3486 |
case fvnameseen: |
case fvnameseen: |
3713 |
case '}': |
case '}': |
3714 |
if (definedef != dnone) |
if (definedef != dnone) |
3715 |
break; |
break; |
3716 |
if (!noindentypedefs && lp == newlb.buffer + 1) |
if (!ignoreindent && lp == newlb.buffer + 1) |
3717 |
{ |
{ |
3718 |
cblev = 0; /* reset curly brace level if first column */ |
cblev = 0; /* reset curly brace level if first column */ |
3719 |
parlev = 0; /* also reset paren level, just in case... */ |
parlev = 0; /* also reset paren level, just in case... */ |
4998 |
FILE * inf; |
FILE * inf; |
4999 |
{ |
{ |
5000 |
bool getnext = FALSE; /* next text outside of HTML tags is a tag */ |
bool getnext = FALSE; /* next text outside of HTML tags is a tag */ |
5001 |
bool ignoretag = FALSE; /* skip to the end of the current HTML tag */ |
bool skiptag = FALSE; /* skip to the end of the current HTML tag */ |
5002 |
bool inanchor = FALSE; /* inside an A HTML tag, looking for NAME= */ |
bool intag = FALSE; /* inside an html tag, looking for ID= */ |
5003 |
|
bool inanchor = FALSE; /* when INTAG, is an anchor, look for NAME= */ |
5004 |
char *end; |
char *end; |
5005 |
|
|
5006 |
|
|
5007 |
linebuffer_setlen (&token_name, 0); /* no name in buffer */ |
linebuffer_setlen (&token_name, 0); /* no name in buffer */ |
5008 |
|
|
5009 |
LOOP_ON_INPUT_LINES (inf, lb, dbp) |
LOOP_ON_INPUT_LINES (inf, lb, dbp) |
5010 |
{ |
for (;;) /* loop on the same line */ |
5011 |
for (;;) /* loop on the same line */ |
{ |
5012 |
|
if (skiptag) /* skip HTML tag */ |
|
if (ignoretag) /* skip HTML tag */ |
|
5013 |
{ |
{ |
5014 |
while (*dbp != '\0' && *dbp != '>') |
while (*dbp != '\0' && *dbp != '>') |
5015 |
dbp++; |
dbp++; |
5016 |
if (*dbp == '>') |
if (*dbp == '>') |
5017 |
{ |
{ |
5018 |
dbp += 1; |
dbp += 1; |
5019 |
ignoretag = FALSE; |
skiptag = FALSE; |
5020 |
continue; /* look on the same line */ |
continue; /* look on the same line */ |
5021 |
} |
} |
5022 |
break; /* go to next line */ |
break; /* go to next line */ |
5023 |
} |
} |
5024 |
|
|
5025 |
else if (inanchor) /* look for "name=" */ |
else if (intag) /* look for "name=" or "id=" */ |
5026 |
{ |
{ |
5027 |
while (*dbp != '\0' && *dbp != '>' && lowcase (*dbp) != 'n') |
while (*dbp != '\0' && *dbp != '>' |
5028 |
|
&& lowcase (*dbp) != 'n' && lowcase (*dbp) != 'i') |
5029 |
dbp++; |
dbp++; |
5030 |
if (*dbp == '\0') |
if (*dbp == '\0') |
5031 |
break; /* go to next line */ |
break; /* go to next line */ |
5032 |
if (*dbp == '>') |
if (*dbp == '>') |
5033 |
{ |
{ |
5034 |
dbp += 1; |
dbp += 1; |
5035 |
inanchor = FALSE; |
intag = FALSE; |
5036 |
continue; /* look on the same line */ |
continue; /* look on the same line */ |
5037 |
} |
} |
5038 |
dbp += 1; |
if ((inanchor && LOOKING_AT_NOCASE (dbp, "name=")) |
5039 |
if (LOOKING_AT_NOCASE (dbp, "ame=")) |
|| LOOKING_AT_NOCASE (dbp, "id=")) |
5040 |
{ |
{ |
5041 |
bool quoted = (dbp[0] == '"'); |
bool quoted = (dbp[0] == '"'); |
5042 |
|
|
5051 |
token_name.buffer[end - dbp] = '\0'; |
token_name.buffer[end - dbp] = '\0'; |
5052 |
|
|
5053 |
dbp = end; |
dbp = end; |
5054 |
inanchor = FALSE; /* we found what we looked for */ |
intag = FALSE; /* we found what we looked for */ |
5055 |
ignoretag = TRUE; /* skip to the end of the anchor */ |
skiptag = TRUE; /* skip to the end of the tag */ |
5056 |
getnext = TRUE; /* then grab the text */ |
getnext = TRUE; /* then grab the text */ |
5057 |
continue; /* look on the same line */ |
continue; /* look on the same line */ |
5058 |
} |
} |
5059 |
|
dbp += 1; |
5060 |
} |
} |
5061 |
|
|
5062 |
else if (getnext) /* grab next tokens and tag them */ |
else if (getnext) /* grab next tokens and tag them */ |
5066 |
break; /* go to next line */ |
break; /* go to next line */ |
5067 |
if (*dbp == '<') |
if (*dbp == '<') |
5068 |
{ |
{ |
5069 |
if (lowcase (dbp[1]) == 'a' && !intoken (dbp[2])) |
intag = TRUE; |
5070 |
inanchor = TRUE; |
inanchor = (lowcase (dbp[1]) == 'a' && !intoken (dbp[2])); |
|
else |
|
|
ignoretag = TRUE; |
|
5071 |
continue; /* look on the same line */ |
continue; /* look on the same line */ |
5072 |
} |
} |
5073 |
|
|
5086 |
dbp++; |
dbp++; |
5087 |
if (*dbp == '\0') |
if (*dbp == '\0') |
5088 |
break; /* go to next line */ |
break; /* go to next line */ |
5089 |
dbp += 1; |
intag = TRUE; |
5090 |
if (lowcase (dbp[0]) == 'a' && !intoken (dbp[1])) |
if (lowcase (dbp[1]) == 'a' && !intoken (dbp[2])) |
|
inanchor = TRUE; |
|
|
else if (LOOKING_AT_NOCASE (dbp, "title>") |
|
|
|| LOOKING_AT_NOCASE (dbp, "h1>") |
|
|
|| LOOKING_AT_NOCASE (dbp, "h2>") |
|
|
|| LOOKING_AT_NOCASE (dbp, "h3>")) |
|
5091 |
{ |
{ |
5092 |
|
inanchor = TRUE; |
5093 |
|
continue; /* look on the same line */ |
5094 |
|
} |
5095 |
|
else if (LOOKING_AT_NOCASE (dbp, "<title>") |
5096 |
|
|| LOOKING_AT_NOCASE (dbp, "<h1>") |
5097 |
|
|| LOOKING_AT_NOCASE (dbp, "<h2>") |
5098 |
|
|| LOOKING_AT_NOCASE (dbp, "<h3>")) |
5099 |
|
{ |
5100 |
|
intag = FALSE; |
5101 |
getnext = TRUE; |
getnext = TRUE; |
5102 |
continue; /* look on the same line */ |
continue; /* look on the same line */ |
5103 |
} |
} |
5104 |
|
dbp += 1; |
5105 |
} |
} |
5106 |
} |
} |
5107 |
} |
} |
5108 |
|
|
5109 |
|
|