Mercurial > emacs
changeset 16607:16b8d910795f
* etags.c (C_entries): Test tok.valid. This handles some
particular cases involving function declarations that failed.
* etags.c (pfnote, fatal, error): Callers using a NULL pointer
must cast it to (char *) because we have no prototypes.
(make_C_tag): Macro deleted, new function.
(C_entries): Calls to make_C_tag macro changed to call function.
author | Francesco Potortì <pot@gnu.org> |
---|---|
date | Wed, 04 Dec 1996 10:57:01 +0000 |
parents | 1f77335980ba |
children | e2858bcbed43 |
files | lib-src/etags.c |
diffstat | 1 files changed, 50 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/lib-src/etags.c Thu Nov 21 22:20:09 1996 +0000 +++ b/lib-src/etags.c Wed Dec 04 10:57:01 1996 +0000 @@ -31,7 +31,7 @@ * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. */ -char pot_etags_version[] = "@(#) pot revision number is 11.77"; +char pot_etags_version[] = "@(#) pot revision number is 11.80"; #define TRUE 1 #define FALSE 0 @@ -970,7 +970,7 @@ "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS", tagfile, argbuffer[i].what, tagfile); if (system (cmd) != GOOD) - fatal ("failed to execute shell command", NULL); + fatal ("failed to execute shell command", (char *)NULL); } append_to_tagfile = TRUE; } @@ -1342,7 +1342,7 @@ { /* Etags Mode */ if (last_node == NULL) - fatal ("internal error in add_node", NULL); + fatal ("internal error in add_node", (char *)NULL); last_node->right = node; last_node = node; } @@ -1408,7 +1408,7 @@ else { if (node->name == NULL) - error ("internal error: NULL name in ctags mode.", NULL); + error ("internal error: NULL name in ctags mode.", (char *)NULL); if (cxref_style) { @@ -1850,7 +1850,7 @@ case dignorerest: return FALSE; default: - error ("internal error: definedef value.", NULL); + error ("internal error: definedef value.", (char *)NULL); } /* @@ -2100,16 +2100,28 @@ definedef = dnone; \ } while (0) -/* This macro should never be called when tok.valid is FALSE, but - we must protect about both invalid input and internal errors. */ -#define make_C_tag(isfun) do \ -if (tok.valid) { \ - char *name = NULL; \ - if (CTAGS || tok.named) \ - name = savestr (token_name.buffer); \ - pfnote (name, isfun, tok.buffer, tok.linelen, tok.lineno, tok.linepos); \ - tok.valid = FALSE; \ -} /* else if (DEBUG) abort (); */ while (0) + +void +make_C_tag (isfun, tokp) + logical isfun; + TOKEN *tokp; +{ + char *name = NULL; + + /* This function should never be called when tok.valid is FALSE, but + we must protect against invalid input or internal errors. */ + if (tokp->valid) + { + if (CTAGS || tokp->named) + name = savestr (token_name.buffer); + pfnote (name, isfun, + tokp->buffer, tokp->linelen, tokp->lineno, tokp->linepos); + tokp->valid = FALSE; + } + else if (DEBUG) + abort (); +} + void C_entries (c_ext, inf) @@ -2370,7 +2382,7 @@ switch_line_buffers (); } else - make_C_tag (is_func); + make_C_tag (is_func, &tok); } midtoken = FALSE; } @@ -2392,7 +2404,7 @@ funcdef = finlist; continue; case flistseen: - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); funcdef = fignore; break; case ftagseen: @@ -2427,7 +2439,7 @@ { case otagseen: objdef = oignore; - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); break; case omethodtag: case omethodparm: @@ -2445,7 +2457,7 @@ case ftagseen: if (yacc_rules) { - make_C_tag (FALSE); + make_C_tag (FALSE, &tok); funcdef = fignore; } break; @@ -2461,7 +2473,7 @@ switch (typdef) { case tend: - make_C_tag (FALSE); + make_C_tag (FALSE, &tok); /* FALLTHRU */ default: typdef = tnone; @@ -2484,7 +2496,7 @@ { case omethodtag: case omethodparm: - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); objdef = oinbody; break; } @@ -2499,7 +2511,7 @@ if (cblev == 0 && typdef == tend) { typdef = tignore; - make_C_tag (FALSE); + make_C_tag (FALSE, &tok); break; } if (funcdef != finlist && funcdef != fignore) @@ -2522,10 +2534,10 @@ /* Make sure that the next char is not a '*'. This handles constructs like: typedef void OperatorFun (int fun); */ - if (*lp != '*') + if (tok.valid && *lp != '*') { typdef = tignore; - make_C_tag (FALSE); + make_C_tag (FALSE, &tok); } break; } /* switch (typdef) */ @@ -2544,7 +2556,7 @@ break; if (objdef == ocatseen && parlev == 1) { - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); objdef = oignore; } if (--parlev == 0) @@ -2559,7 +2571,7 @@ if (cblev == 0 && typdef == tend) { typdef = tignore; - make_C_tag (FALSE); + make_C_tag (FALSE, &tok); } } else if (parlev < 0) /* can happen due to ill-conceived #if's. */ @@ -2579,13 +2591,13 @@ case stagseen: case scolonseen: /* named struct */ structdef = sinbody; - make_C_tag (FALSE); + make_C_tag (FALSE, &tok); break; } switch (funcdef) { case flistseen: - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); /* FALLTHRU */ case fignore: funcdef = fnone; @@ -2594,12 +2606,12 @@ switch (objdef) { case otagseen: - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); objdef = oignore; break; case omethodtag: case omethodparm: - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); objdef = oinbody; break; default: @@ -2661,7 +2673,7 @@ case '\0': if (objdef == otagseen) { - make_C_tag (TRUE); + make_C_tag (TRUE, &tok); objdef = oignore; } /* If a macro spans multiple lines don't reset its state. */ @@ -3364,7 +3376,7 @@ i = TEX_Token (lasthit); if (0 <= i) { - pfnote (NULL, TRUE, + pfnote ((char *)NULL, TRUE, lb.buffer, strlen (lb.buffer), lineno, linecharno); #if TeX_named_tokens TEX_getit (lasthit, TEX_toktab[i].len); @@ -3542,7 +3554,7 @@ else if (len = prolog_pred (dbp, last)) { /* Predicate. Store the function name so that we only - * generates a tag for the first clause. */ + generate a tag for the first clause. */ if (last == NULL) last = xnew(len + 1, char); else if (len + 1 > allocated) @@ -3971,7 +3983,7 @@ if (regexp_pattern[0] == '\0') { - error ("missing regexp", NULL); + error ("missing regexp", (char *)NULL); return; } if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0]) @@ -3982,7 +3994,7 @@ name = scan_separators (regexp_pattern); if (regexp_pattern[0] == '\0') { - error ("null regexp", NULL); + error ("null regexp", (char *)NULL); return; } (void) scan_separators (name); @@ -4191,7 +4203,7 @@ else { /* Make an unnamed tag. */ - pfnote (NULL, TRUE, + pfnote ((char *)NULL, TRUE, linebuffer->buffer, match, lineno, linecharno); } break; @@ -4547,7 +4559,7 @@ { long *result = (long *) malloc (size); if (result == NULL) - fatal ("virtual memory exhausted", NULL); + fatal ("virtual memory exhausted", (char *)NULL); return result; } @@ -4558,6 +4570,6 @@ { long *result = (long *) realloc (ptr, size); if (result == NULL) - fatal ("virtual memory exhausted", NULL); + fatal ("virtual memory exhausted", (char *)NULL); return result; }