aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì1996-12-04 10:57:01 +0000
committerFrancesco Potortì1996-12-04 10:57:01 +0000
commit086eac130a00b5568be191a67a22bec65e89be94 (patch)
tree163f7a031b3e9f7075fc4f5b5a3654d4c083eb1b /lib-src
parentaab72f0761de41b0c851c2fae08a10bcc4dc19e2 (diff)
downloademacs-086eac130a00b5568be191a67a22bec65e89be94.tar.gz
emacs-086eac130a00b5568be191a67a22bec65e89be94.zip
* 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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c88
1 files changed, 50 insertions, 38 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index d44494f931f..1415e0f7d3d 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -31,7 +31,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. 31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
32 */ 32 */
33 33
34char pot_etags_version[] = "@(#) pot revision number is 11.77"; 34char pot_etags_version[] = "@(#) pot revision number is 11.80";
35 35
36#define TRUE 1 36#define TRUE 1
37#define FALSE 0 37#define FALSE 0
@@ -970,7 +970,7 @@ main (argc, argv)
970 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS", 970 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
971 tagfile, argbuffer[i].what, tagfile); 971 tagfile, argbuffer[i].what, tagfile);
972 if (system (cmd) != GOOD) 972 if (system (cmd) != GOOD)
973 fatal ("failed to execute shell command", NULL); 973 fatal ("failed to execute shell command", (char *)NULL);
974 } 974 }
975 append_to_tagfile = TRUE; 975 append_to_tagfile = TRUE;
976 } 976 }
@@ -1342,7 +1342,7 @@ add_node (node, cur_node_p)
1342 { 1342 {
1343 /* Etags Mode */ 1343 /* Etags Mode */
1344 if (last_node == NULL) 1344 if (last_node == NULL)
1345 fatal ("internal error in add_node", NULL); 1345 fatal ("internal error in add_node", (char *)NULL);
1346 last_node->right = node; 1346 last_node->right = node;
1347 last_node = node; 1347 last_node = node;
1348 } 1348 }
@@ -1408,7 +1408,7 @@ put_entries (node)
1408 else 1408 else
1409 { 1409 {
1410 if (node->name == NULL) 1410 if (node->name == NULL)
1411 error ("internal error: NULL name in ctags mode.", NULL); 1411 error ("internal error: NULL name in ctags mode.", (char *)NULL);
1412 1412
1413 if (cxref_style) 1413 if (cxref_style)
1414 { 1414 {
@@ -1850,7 +1850,7 @@ consider_token (str, len, c, c_ext, cblev, parlev, is_func)
1850 case dignorerest: 1850 case dignorerest:
1851 return FALSE; 1851 return FALSE;
1852 default: 1852 default:
1853 error ("internal error: definedef value.", NULL); 1853 error ("internal error: definedef value.", (char *)NULL);
1854 } 1854 }
1855 1855
1856 /* 1856 /*
@@ -2100,16 +2100,28 @@ do { \
2100 definedef = dnone; \ 2100 definedef = dnone; \
2101} while (0) 2101} while (0)
2102 2102
2103/* This macro should never be called when tok.valid is FALSE, but 2103
2104 we must protect about both invalid input and internal errors. */ 2104void
2105#define make_C_tag(isfun) do \ 2105make_C_tag (isfun, tokp)
2106if (tok.valid) { \ 2106 logical isfun;
2107 char *name = NULL; \ 2107 TOKEN *tokp;
2108 if (CTAGS || tok.named) \ 2108{
2109 name = savestr (token_name.buffer); \ 2109 char *name = NULL;
2110 pfnote (name, isfun, tok.buffer, tok.linelen, tok.lineno, tok.linepos); \ 2110
2111 tok.valid = FALSE; \ 2111 /* This function should never be called when tok.valid is FALSE, but
2112} /* else if (DEBUG) abort (); */ while (0) 2112 we must protect against invalid input or internal errors. */
2113 if (tokp->valid)
2114 {
2115 if (CTAGS || tokp->named)
2116 name = savestr (token_name.buffer);
2117 pfnote (name, isfun,
2118 tokp->buffer, tokp->linelen, tokp->lineno, tokp->linepos);
2119 tokp->valid = FALSE;
2120 }
2121 else if (DEBUG)
2122 abort ();
2123}
2124
2113 2125
2114void 2126void
2115C_entries (c_ext, inf) 2127C_entries (c_ext, inf)
@@ -2370,7 +2382,7 @@ C_entries (c_ext, inf)
2370 switch_line_buffers (); 2382 switch_line_buffers ();
2371 } 2383 }
2372 else 2384 else
2373 make_C_tag (is_func); 2385 make_C_tag (is_func, &tok);
2374 } 2386 }
2375 midtoken = FALSE; 2387 midtoken = FALSE;
2376 } 2388 }
@@ -2392,7 +2404,7 @@ C_entries (c_ext, inf)
2392 funcdef = finlist; 2404 funcdef = finlist;
2393 continue; 2405 continue;
2394 case flistseen: 2406 case flistseen:
2395 make_C_tag (TRUE); 2407 make_C_tag (TRUE, &tok);
2396 funcdef = fignore; 2408 funcdef = fignore;
2397 break; 2409 break;
2398 case ftagseen: 2410 case ftagseen:
@@ -2427,7 +2439,7 @@ C_entries (c_ext, inf)
2427 { 2439 {
2428 case otagseen: 2440 case otagseen:
2429 objdef = oignore; 2441 objdef = oignore;
2430 make_C_tag (TRUE); 2442 make_C_tag (TRUE, &tok);
2431 break; 2443 break;
2432 case omethodtag: 2444 case omethodtag:
2433 case omethodparm: 2445 case omethodparm:
@@ -2445,7 +2457,7 @@ C_entries (c_ext, inf)
2445 case ftagseen: 2457 case ftagseen:
2446 if (yacc_rules) 2458 if (yacc_rules)
2447 { 2459 {
2448 make_C_tag (FALSE); 2460 make_C_tag (FALSE, &tok);
2449 funcdef = fignore; 2461 funcdef = fignore;
2450 } 2462 }
2451 break; 2463 break;
@@ -2461,7 +2473,7 @@ C_entries (c_ext, inf)
2461 switch (typdef) 2473 switch (typdef)
2462 { 2474 {
2463 case tend: 2475 case tend:
2464 make_C_tag (FALSE); 2476 make_C_tag (FALSE, &tok);
2465 /* FALLTHRU */ 2477 /* FALLTHRU */
2466 default: 2478 default:
2467 typdef = tnone; 2479 typdef = tnone;
@@ -2484,7 +2496,7 @@ C_entries (c_ext, inf)
2484 { 2496 {
2485 case omethodtag: 2497 case omethodtag:
2486 case omethodparm: 2498 case omethodparm:
2487 make_C_tag (TRUE); 2499 make_C_tag (TRUE, &tok);
2488 objdef = oinbody; 2500 objdef = oinbody;
2489 break; 2501 break;
2490 } 2502 }
@@ -2499,7 +2511,7 @@ C_entries (c_ext, inf)
2499 if (cblev == 0 && typdef == tend) 2511 if (cblev == 0 && typdef == tend)
2500 { 2512 {
2501 typdef = tignore; 2513 typdef = tignore;
2502 make_C_tag (FALSE); 2514 make_C_tag (FALSE, &tok);
2503 break; 2515 break;
2504 } 2516 }
2505 if (funcdef != finlist && funcdef != fignore) 2517 if (funcdef != finlist && funcdef != fignore)
@@ -2522,10 +2534,10 @@ C_entries (c_ext, inf)
2522 /* Make sure that the next char is not a '*'. 2534 /* Make sure that the next char is not a '*'.
2523 This handles constructs like: 2535 This handles constructs like:
2524 typedef void OperatorFun (int fun); */ 2536 typedef void OperatorFun (int fun); */
2525 if (*lp != '*') 2537 if (tok.valid && *lp != '*')
2526 { 2538 {
2527 typdef = tignore; 2539 typdef = tignore;
2528 make_C_tag (FALSE); 2540 make_C_tag (FALSE, &tok);
2529 } 2541 }
2530 break; 2542 break;
2531 } /* switch (typdef) */ 2543 } /* switch (typdef) */
@@ -2544,7 +2556,7 @@ C_entries (c_ext, inf)
2544 break; 2556 break;
2545 if (objdef == ocatseen && parlev == 1) 2557 if (objdef == ocatseen && parlev == 1)
2546 { 2558 {
2547 make_C_tag (TRUE); 2559 make_C_tag (TRUE, &tok);
2548 objdef = oignore; 2560 objdef = oignore;
2549 } 2561 }
2550 if (--parlev == 0) 2562 if (--parlev == 0)
@@ -2559,7 +2571,7 @@ C_entries (c_ext, inf)
2559 if (cblev == 0 && typdef == tend) 2571 if (cblev == 0 && typdef == tend)
2560 { 2572 {
2561 typdef = tignore; 2573 typdef = tignore;
2562 make_C_tag (FALSE); 2574 make_C_tag (FALSE, &tok);
2563 } 2575 }
2564 } 2576 }
2565 else if (parlev < 0) /* can happen due to ill-conceived #if's. */ 2577 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
@@ -2579,13 +2591,13 @@ C_entries (c_ext, inf)
2579 case stagseen: 2591 case stagseen:
2580 case scolonseen: /* named struct */ 2592 case scolonseen: /* named struct */
2581 structdef = sinbody; 2593 structdef = sinbody;
2582 make_C_tag (FALSE); 2594 make_C_tag (FALSE, &tok);
2583 break; 2595 break;
2584 } 2596 }
2585 switch (funcdef) 2597 switch (funcdef)
2586 { 2598 {
2587 case flistseen: 2599 case flistseen:
2588 make_C_tag (TRUE); 2600 make_C_tag (TRUE, &tok);
2589 /* FALLTHRU */ 2601 /* FALLTHRU */
2590 case fignore: 2602 case fignore:
2591 funcdef = fnone; 2603 funcdef = fnone;
@@ -2594,12 +2606,12 @@ C_entries (c_ext, inf)
2594 switch (objdef) 2606 switch (objdef)
2595 { 2607 {
2596 case otagseen: 2608 case otagseen:
2597 make_C_tag (TRUE); 2609 make_C_tag (TRUE, &tok);
2598 objdef = oignore; 2610 objdef = oignore;
2599 break; 2611 break;
2600 case omethodtag: 2612 case omethodtag:
2601 case omethodparm: 2613 case omethodparm:
2602 make_C_tag (TRUE); 2614 make_C_tag (TRUE, &tok);
2603 objdef = oinbody; 2615 objdef = oinbody;
2604 break; 2616 break;
2605 default: 2617 default:
@@ -2661,7 +2673,7 @@ C_entries (c_ext, inf)
2661 case '\0': 2673 case '\0':
2662 if (objdef == otagseen) 2674 if (objdef == otagseen)
2663 { 2675 {
2664 make_C_tag (TRUE); 2676 make_C_tag (TRUE, &tok);
2665 objdef = oignore; 2677 objdef = oignore;
2666 } 2678 }
2667 /* If a macro spans multiple lines don't reset its state. */ 2679 /* If a macro spans multiple lines don't reset its state. */
@@ -3364,7 +3376,7 @@ TeX_functions (inf)
3364 i = TEX_Token (lasthit); 3376 i = TEX_Token (lasthit);
3365 if (0 <= i) 3377 if (0 <= i)
3366 { 3378 {
3367 pfnote (NULL, TRUE, 3379 pfnote ((char *)NULL, TRUE,
3368 lb.buffer, strlen (lb.buffer), lineno, linecharno); 3380 lb.buffer, strlen (lb.buffer), lineno, linecharno);
3369#if TeX_named_tokens 3381#if TeX_named_tokens
3370 TEX_getit (lasthit, TEX_toktab[i].len); 3382 TEX_getit (lasthit, TEX_toktab[i].len);
@@ -3542,7 +3554,7 @@ Prolog_functions (inf)
3542 else if (len = prolog_pred (dbp, last)) 3554 else if (len = prolog_pred (dbp, last))
3543 { 3555 {
3544 /* Predicate. Store the function name so that we only 3556 /* Predicate. Store the function name so that we only
3545 * generates a tag for the first clause. */ 3557 generate a tag for the first clause. */
3546 if (last == NULL) 3558 if (last == NULL)
3547 last = xnew(len + 1, char); 3559 last = xnew(len + 1, char);
3548 else if (len + 1 > allocated) 3560 else if (len + 1 > allocated)
@@ -3971,7 +3983,7 @@ add_regex (regexp_pattern)
3971 3983
3972 if (regexp_pattern[0] == '\0') 3984 if (regexp_pattern[0] == '\0')
3973 { 3985 {
3974 error ("missing regexp", NULL); 3986 error ("missing regexp", (char *)NULL);
3975 return; 3987 return;
3976 } 3988 }
3977 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0]) 3989 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
@@ -3982,7 +3994,7 @@ add_regex (regexp_pattern)
3982 name = scan_separators (regexp_pattern); 3994 name = scan_separators (regexp_pattern);
3983 if (regexp_pattern[0] == '\0') 3995 if (regexp_pattern[0] == '\0')
3984 { 3996 {
3985 error ("null regexp", NULL); 3997 error ("null regexp", (char *)NULL);
3986 return; 3998 return;
3987 } 3999 }
3988 (void) scan_separators (name); 4000 (void) scan_separators (name);
@@ -4191,7 +4203,7 @@ readline (linebuffer, stream)
4191 else 4203 else
4192 { 4204 {
4193 /* Make an unnamed tag. */ 4205 /* Make an unnamed tag. */
4194 pfnote (NULL, TRUE, 4206 pfnote ((char *)NULL, TRUE,
4195 linebuffer->buffer, match, lineno, linecharno); 4207 linebuffer->buffer, match, lineno, linecharno);
4196 } 4208 }
4197 break; 4209 break;
@@ -4547,7 +4559,7 @@ xmalloc (size)
4547{ 4559{
4548 long *result = (long *) malloc (size); 4560 long *result = (long *) malloc (size);
4549 if (result == NULL) 4561 if (result == NULL)
4550 fatal ("virtual memory exhausted", NULL); 4562 fatal ("virtual memory exhausted", (char *)NULL);
4551 return result; 4563 return result;
4552} 4564}
4553 4565
@@ -4558,6 +4570,6 @@ xrealloc (ptr, size)
4558{ 4570{
4559 long *result = (long *) realloc (ptr, size); 4571 long *result = (long *) realloc (ptr, size);
4560 if (result == NULL) 4572 if (result == NULL)
4561 fatal ("virtual memory exhausted", NULL); 4573 fatal ("virtual memory exhausted", (char *)NULL);
4562 return result; 4574 return result;
4563} 4575}