35 |
* |
* |
36 |
*/ |
*/ |
37 |
|
|
38 |
char pot_etags_version[] = "@(#) pot revision number is 16.46"; |
char pot_etags_version[] = "@(#) pot revision number is 16.54"; |
39 |
|
|
40 |
#define TRUE 1 |
#define TRUE 1 |
41 |
#define FALSE 0 |
#define FALSE 0 |
1765 |
{ |
{ |
1766 |
fdesc *badfdp = *fdpp; |
fdesc *badfdp = *fdpp; |
1767 |
|
|
1768 |
if (DEBUG) |
/* Delete the tags referring to badfdp->taggedfname |
1769 |
fprintf (stderr, |
that were obtained from badfdp->infname. */ |
|
"Removing references to \"%s\" obtained from \"%s\"\n", |
|
|
badfdp->taggedfname, badfdp->infname); |
|
|
|
|
|
/* Delete the tags referring to badfdp. */ |
|
1770 |
invalidate_nodes (badfdp, &nodehead); |
invalidate_nodes (badfdp, &nodehead); |
1771 |
|
|
1772 |
*fdpp = badfdp->next; /* remove the bad description from the list */ |
*fdpp = badfdp->next; /* remove the bad description from the list */ |
2564 |
*/ |
*/ |
2565 |
static struct tok |
static struct tok |
2566 |
{ |
{ |
2567 |
bool valid; |
char *line; /* string containing the token */ |
2568 |
bool named; |
int offset; /* where the token starts in LINE */ |
2569 |
int offset; |
int length; /* token length */ |
2570 |
int length; |
/* |
2571 |
int lineno; |
The previous members can be used to pass strings around for generic |
2572 |
long linepos; |
purposes. The following ones specifically refer to creating tags. In this |
2573 |
char *line; |
case the token contained here is the pattern that will be used to create a |
2574 |
|
tag. |
2575 |
|
*/ |
2576 |
|
bool valid; /* do not create a tag; the token should be |
2577 |
|
invalidated whenever a state machine is |
2578 |
|
reset prematurely */ |
2579 |
|
bool named; /* create a named tag */ |
2580 |
|
int lineno; /* source line number of tag */ |
2581 |
|
long linepos; /* source char number of tag */ |
2582 |
} token; /* latest token read */ |
} token; /* latest token read */ |
2583 |
|
|
2584 |
/* |
/* |
2815 |
return FALSE; |
return FALSE; |
2816 |
case st_C_template: |
case st_C_template: |
2817 |
case st_C_class: |
case st_C_class: |
2818 |
if (cblev == 0 |
if ((*c_extp & C_AUTO) /* automatic detection of C++ language */ |
2819 |
&& (*c_extp & C_AUTO) /* automatic detection of C++ language */ |
&& cblev == 0 |
2820 |
&& definedef == dnone && structdef == snone |
&& definedef == dnone && structdef == snone |
2821 |
&& typdef == tnone && fvdef == fvnone) |
&& typdef == tnone && fvdef == fvnone) |
2822 |
*c_extp = (*c_extp | C_PLPL) & ~C_AUTO; |
*c_extp = (*c_extp | C_PLPL) & ~C_AUTO; |
2921 |
fvextern = TRUE; |
fvextern = TRUE; |
2922 |
/* FALLTHRU */ |
/* FALLTHRU */ |
2923 |
case st_C_typespec: |
case st_C_typespec: |
2924 |
if (fvdef != finlist && fvdef != fignore && fvdef != vignore) |
switch (fvdef) |
2925 |
fvdef = fvnone; /* should be useless */ |
{ |
2926 |
|
case finlist: |
2927 |
|
case flistseen: |
2928 |
|
case fignore: |
2929 |
|
case vignore: |
2930 |
|
break; |
2931 |
|
default: |
2932 |
|
fvdef = fvnone; |
2933 |
|
} |
2934 |
return FALSE; |
return FALSE; |
2935 |
case st_C_ignore: |
case st_C_ignore: |
2936 |
fvextern = FALSE; |
fvextern = FALSE; |
2960 |
fvdef = vignore; |
fvdef = vignore; |
2961 |
return FALSE; |
return FALSE; |
2962 |
} |
} |
2963 |
if ((*c_extp & C_PLPL) && strneq (str+len-10, "::operator", 10)) |
if (strneq (str+len-10, "::operator", 10)) |
2964 |
{ |
{ |
2965 |
|
if (*c_extp & C_AUTO) /* automatic detection of C++ */ |
2966 |
|
*c_extp = (*c_extp | C_PLPL) & ~C_AUTO; |
2967 |
fvdef = foperator; |
fvdef = foperator; |
2968 |
*is_func_or_var = TRUE; |
*is_func_or_var = TRUE; |
2969 |
return TRUE; |
return TRUE; |
3000 |
#define curlinepos (lbs[curndx].linepos) |
#define curlinepos (lbs[curndx].linepos) |
3001 |
#define newlinepos (lbs[newndx].linepos) |
#define newlinepos (lbs[newndx].linepos) |
3002 |
|
|
3003 |
#define cplpl ((c_ext & C_PLPL) == C_PLPL) |
#define plainc ((c_ext & C_EXT) == C_PLAIN) |
3004 |
|
#define cplpl (c_ext & C_PLPL) |
3005 |
#define cjava ((c_ext & C_JAVA) == C_JAVA) |
#define cjava ((c_ext & C_JAVA) == C_JAVA) |
3006 |
|
|
3007 |
#define CNL_SAVE_DEFINEDEF() \ |
#define CNL_SAVE_DEFINEDEF() \ |
3034 |
if (!DEBUG && !token.valid) |
if (!DEBUG && !token.valid) |
3035 |
return; |
return; |
3036 |
|
|
3037 |
if (!token.valid) /* this case is optimised away if !DEBUG */ |
if (token.valid) |
|
make_tag (concat (token_name.buffer, "##invalid token##", ""), |
|
|
token_name.len + 17, isfun, token.line, |
|
|
token.offset+token.length+1, token.lineno, token.linepos); |
|
|
else |
|
3038 |
make_tag (token_name.buffer, token_name.len, isfun, token.line, |
make_tag (token_name.buffer, token_name.len, isfun, token.line, |
3039 |
token.offset+token.length+1, token.lineno, token.linepos); |
token.offset+token.length+1, token.lineno, token.linepos); |
3040 |
|
else /* this case is optimised away if !DEBUG */ |
3041 |
|
make_tag (concat ("INVALID TOKEN:-->", token_name.buffer, ""), |
3042 |
|
token_name.len + 17, isfun, token.line, |
3043 |
|
token.offset+token.length+1, token.lineno, token.linepos); |
3044 |
|
|
3045 |
token.valid = FALSE; |
token.valid = FALSE; |
3046 |
} |
} |
3259 |
{ |
{ |
3260 |
if (endtoken (c)) |
if (endtoken (c)) |
3261 |
{ |
{ |
3262 |
if (c == ':' && cplpl && *lp == ':' && begtoken (lp[1])) |
if (c == ':' && *lp == ':' && begtoken (lp[1])) |
3263 |
|
/* This handles :: in the middle, |
3264 |
|
but not at the beginning of an identifier. |
3265 |
|
Also, space-separated :: is not recognised. */ |
3266 |
{ |
{ |
3267 |
/* |
if (c_ext & C_AUTO) /* automatic detection of C++ */ |
3268 |
* This handles :: in the middle, but not at the |
c_ext = (c_ext | C_PLPL) & ~C_AUTO; |
|
* beginning of an identifier. Also, space-separated |
|
|
* :: is not recognised. |
|
|
*/ |
|
3269 |
lp += 2; |
lp += 2; |
3270 |
toklen += 2; |
toklen += 2; |
3271 |
c = lp[-1]; |
c = lp[-1]; |
3292 |
toklen += lp - oldlp; |
toklen += lp - oldlp; |
3293 |
} |
} |
3294 |
token.named = FALSE; |
token.named = FALSE; |
3295 |
if ((c_ext & C_EXT) /* not pure C */ |
if (!plainc |
3296 |
&& nestlev > 0 && definedef == dnone) |
&& nestlev > 0 && definedef == dnone) |
3297 |
/* in struct body */ |
/* in struct body */ |
3298 |
{ |
{ |
3408 |
fvdef = finlist; |
fvdef = finlist; |
3409 |
continue; |
continue; |
3410 |
case flistseen: |
case flistseen: |
3411 |
#if 0 |
if (plainc || declarations) |
3412 |
if (!instruct || members) |
{ |
3413 |
#endif |
make_C_tag (TRUE); /* a function */ |
3414 |
make_C_tag (TRUE); /* a function */ |
fvdef = fignore; |
3415 |
fvdef = fignore; |
} |
3416 |
break; |
break; |
3417 |
case fvnameseen: |
case fvnameseen: |
3418 |
fvdef = fvnone; |
fvdef = fvnone; |
3469 |
structdef = scolonseen; |
structdef = scolonseen; |
3470 |
break; |
break; |
3471 |
} |
} |
3472 |
#if 0 |
/* Should be useless, but may be work as a safety net. */ |
3473 |
if (cplpl && fvdef == flistseen) |
if (cplpl && fvdef == flistseen) |
3474 |
{ |
{ |
3475 |
make_C_tag (TRUE); /* a function */ |
make_C_tag (TRUE); /* a function */ |
3476 |
fvdef = fignore; |
fvdef = fignore; |
3477 |
break; |
break; |
3478 |
} |
} |
|
#endif |
|
3479 |
break; |
break; |
3480 |
case ';': |
case ';': |
3481 |
if (definedef != dnone) |
if (definedef != dnone) |
3506 |
token.valid = FALSE; |
token.valid = FALSE; |
3507 |
break; |
break; |
3508 |
case flistseen: |
case flistseen: |
3509 |
if ((declarations && typdef == tnone && !instruct) |
if (declarations |
3510 |
|| (members && typdef != tignore && instruct)) |
&& (typdef == tnone || (typdef != tignore && instruct))) |
3511 |
make_C_tag (TRUE); /* a function declaration */ |
make_C_tag (TRUE); /* a function declaration */ |
3512 |
/* FALLTHRU */ |
/* FALLTHRU */ |
3513 |
default: |
default: |
3514 |
fvextern = FALSE; |
fvextern = FALSE; |
3515 |
fvdef = fvnone; |
fvdef = fvnone; |
3516 |
if (declarations |
if (declarations |
3517 |
&& structdef == stagseen && (c_ext & C_PLPL)) |
&& cplpl && structdef == stagseen) |
3518 |
make_C_tag (FALSE); /* forward declaration */ |
make_C_tag (FALSE); /* forward declaration */ |
3519 |
else |
else |
|
/* The following instruction invalidates the token. |
|
|
Probably the token should be invalidated in all other |
|
|
cases where some state machine is reset prematurely. */ |
|
3520 |
token.valid = FALSE; |
token.valid = FALSE; |
3521 |
} /* switch (fvdef) */ |
} /* switch (fvdef) */ |
3522 |
/* FALLTHRU */ |
/* FALLTHRU */ |
3719 |
if (definedef != dnone) |
if (definedef != dnone) |
3720 |
break; |
break; |
3721 |
if (fvdef == fstartlist) |
if (fvdef == fstartlist) |
3722 |
fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */ |
{ |
3723 |
|
fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */ |
3724 |
|
token.valid = FALSE; |
3725 |
|
} |
3726 |
break; |
break; |
3727 |
case '}': |
case '}': |
3728 |
if (definedef != dnone) |
if (definedef != dnone) |
3729 |
break; |
break; |
3730 |
if (!ignoreindent && lp == newlb.buffer + 1) |
if (!ignoreindent && lp == newlb.buffer + 1) |
3731 |
{ |
{ |
3732 |
|
if (cblev != 0) |
3733 |
|
token.valid = FALSE; |
3734 |
cblev = 0; /* reset curly brace level if first column */ |
cblev = 0; /* reset curly brace level if first column */ |
3735 |
parlev = 0; /* also reset paren level, just in case... */ |
parlev = 0; /* also reset paren level, just in case... */ |
3736 |
} |
} |
3737 |
else if (cblev > 0) |
else if (cblev > 0) |
3738 |
cblev--; |
cblev--; |
3739 |
|
else |
3740 |
|
token.valid = FALSE; /* something gone amiss, token unreliable */ |
3741 |
popclass_above (cblev); |
popclass_above (cblev); |
3742 |
structdef = snone; |
structdef = snone; |
3743 |
/* Only if typdef == tinbody is typdefcblev significant. */ |
/* Only if typdef == tinbody is typdefcblev significant. */ |