aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorRoland McGrath1991-08-18 01:37:14 +0000
committerRoland McGrath1991-08-18 01:37:14 +0000
commit1e134a5fd866a40da7b2baf2a52c46ab82a08d74 (patch)
treed090c5c2a10e4ef923e2035bc9fd6be6458bf6ab /lib-src
parent6679505fd4203a42d4f8bc6271fe3e0f855e3151 (diff)
downloademacs-1e134a5fd866a40da7b2baf2a52c46ab82a08d74.tar.gz
emacs-1e134a5fd866a40da7b2baf2a52c46ab82a08d74.zip
*** empty log message ***
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c98
1 files changed, 52 insertions, 46 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 4e570f5fe33..680a8d43643 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -31,6 +31,16 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/stat.h> 32#include <sys/stat.h>
33 33
34#ifdef __GNUC__
35#define alloca __builtin_alloca
36#else
37#ifdef sparc
38#include <alloca.h>
39#else
40extern char *alloca ();
41#endif
42#endif
43
34extern char *malloc (), *realloc (); 44extern char *malloc (), *realloc ();
35extern char *getenv (); 45extern char *getenv ();
36extern char *index (), *rindex (); 46extern char *index (), *rindex ();
@@ -444,8 +454,6 @@ int no_warnings; /* -w: suppress warnings */
444int cxref_style; /* -x: create cxref style output */ 454int cxref_style; /* -x: create cxref style output */
445int cplusplus; /* .[hc] means C++, not C */ 455int cplusplus; /* .[hc] means C++, not C */
446int noindentypedefs; /* -S: ignore indentation in C */ 456int noindentypedefs; /* -S: ignore indentation in C */
447int files_are_tag_tables; /* -i: treat all spec'd files as */
448 /* included sub-tag-tables. */
449 457
450/* Name this program was invoked with. */ 458/* Name this program was invoked with. */
451char *progname; 459char *progname;
@@ -480,6 +488,8 @@ main (argc, argv)
480 char cmd[100]; 488 char cmd[100];
481 int i; 489 int i;
482 int outfflag = 0; 490 int outfflag = 0;
491 unsigned int nincluded_files = 0;
492 char **included_files = (char *) alloca (argc * sizeof (char *));
483 char *this_file; 493 char *this_file;
484#ifdef VMS 494#ifdef VMS
485 char got_err; 495 char got_err;
@@ -553,10 +563,19 @@ main (argc, argv)
553 563
554 /* Etags options */ 564 /* Etags options */
555 case 'i': 565 case 'i':
556 files_are_tag_tables++;
557 if (!emacs_tags_format) 566 if (!emacs_tags_format)
558 goto usage; 567 goto usage;
559 break; 568 --argc;
569 ++argv;
570 if (argc <= 1 || argv[1][0] == '\0')
571 {
572 fprintf (stderr,
573 "%s: -i flag must be followed by a filename\n",
574 progname);
575 goto usage;
576 }
577 included_files[nincluded_files++] = argv[1];
578 goto next_arg;
560 579
561 /* Ctags options. */ 580 /* Ctags options. */
562 case 'B': 581 case 'B':
@@ -675,6 +694,9 @@ main (argc, argv)
675 694
676 if (emacs_tags_format) 695 if (emacs_tags_format)
677 { 696 {
697 while (nincluded_files-- > 0)
698 fprintf (outf, "\f\n%s,include\n", *included_files++);
699
678 (void) fclose (outf); 700 (void) fclose (outf);
679 exit (0); 701 exit (0);
680 } 702 }
@@ -733,11 +755,6 @@ process_file (file)
733 fprintf (stderr, "Skipping inclusion of %s in self.\n", file); 755 fprintf (stderr, "Skipping inclusion of %s in self.\n", file);
734 return; 756 return;
735 } 757 }
736 if (files_are_tag_tables)
737 {
738 fprintf (outf, "\f\n%s,include\n", file);
739 return;
740 }
741 if (emacs_tags_format) 758 if (emacs_tags_format)
742 { 759 {
743 char *cp = rindex (file, '/'); 760 char *cp = rindex (file, '/');
@@ -745,11 +762,6 @@ process_file (file)
745 ++cp; 762 ++cp;
746 else 763 else
747 cp = file; 764 cp = file;
748 if (streq (cp, outfile)) /*file == "TAGS"*/
749 {
750 fprintf (outf, "\f\n%s,include\n", file);
751 return;
752 }
753 } 765 }
754 find_entries (file); 766 find_entries (file);
755 if (emacs_tags_format) 767 if (emacs_tags_format)
@@ -1302,32 +1314,19 @@ C_entries (c_ext)
1302 while (!feof (inf)) 1314 while (!feof (inf))
1303 { 1315 {
1304 c = *lp++; 1316 c = *lp++;
1305 if (c == 0)
1306 {
1307 CNL;
1308 gotone = FALSE;
1309 }
1310 if (c == '\\') 1317 if (c == '\\')
1311 { 1318 {
1312 c = *lp++; 1319 if (*lp == 0)
1313 if (c == 0) 1320 continue;
1314 { 1321 lp++;
1315 CNL_SAVE_DEFINEDEF;
1316 }
1317 c = ' '; 1322 c = ' ';
1318 } 1323 }
1319 else if (incomm) 1324 else if (incomm)
1320 { 1325 {
1321 if (c == '*') 1326 if (c == '*' && *lp == '/')
1322 { 1327 {
1323 while ((c = *lp++) == '*') 1328 c = *lp++;
1324 continue; 1329 incomm = FALSE;
1325 if (c == 0)
1326 {
1327 CNL;
1328 }
1329 if (c == '/')
1330 incomm = FALSE;
1331 } 1330 }
1332 } 1331 }
1333 else if (inquote) 1332 else if (inquote)
@@ -1363,7 +1362,7 @@ C_entries (c_ext)
1363 } 1362 }
1364 else if (c_ext && *lp == '/') 1363 else if (c_ext && *lp == '/')
1365 { 1364 {
1366 CNL; /* C++ comment: skip rest of line */ 1365 c = 0; /* C++ comment: skip rest of line */
1367 } 1366 }
1368 continue; 1367 continue;
1369 case '#': 1368 case '#':
@@ -1439,6 +1438,9 @@ C_entries (c_ext)
1439 } 1438 }
1440 else 1439 else
1441 { 1440 {
1441 /* The following is no longer true,
1442 now that we advance to the next line
1443 at the end of processing the character. */
1442 /* 1444 /*
1443 * We've just finished lexing an identifier. 1445 * We've just finished lexing an identifier.
1444 * Note that if `c' is '\0', `lb' is the NEXT 1446 * Note that if `c' is '\0', `lb' is the NEXT
@@ -1458,6 +1460,7 @@ C_entries (c_ext)
1458 logical bingo, tok_at_end_of_line; 1460 logical bingo, tok_at_end_of_line;
1459 char *lp_tmp; /* addressable */ 1461 char *lp_tmp; /* addressable */
1460 1462
1463#if 0
1461 if (c == '\0') 1464 if (c == '\0')
1462 { 1465 {
1463 getline (GET_COOKIE (prev_linepos)); 1466 getline (GET_COOKIE (prev_linepos));
@@ -1467,6 +1470,7 @@ C_entries (c_ext)
1467 tok.lineno = lineno - 1; 1470 tok.lineno = lineno - 1;
1468 } 1471 }
1469 else 1472 else
1473#endif
1470 { 1474 {
1471 tok_linebuf = lb.buffer; 1475 tok_linebuf = lb.buffer;
1472 tok_at_end_of_line = FALSE; 1476 tok_at_end_of_line = FALSE;
@@ -1524,6 +1528,12 @@ C_entries (c_ext)
1524 midtoken = TRUE; 1528 midtoken = TRUE;
1525 } 1529 }
1526 } 1530 }
1531 /* Detect end of line, after having handled the last token on the line. */
1532 if (c == 0)
1533 {
1534 CNL;
1535 gotone = FALSE;
1536 }
1527 if (c == ';' && tydef == end) /* clean with typedefs */ 1537 if (c == ';' && tydef == end) /* clean with typedefs */
1528 tydef = none; 1538 tydef = none;
1529 } 1539 }
@@ -1629,9 +1639,8 @@ consider_token (c, lpp, tokp, is_func, c_ext, level)
1629 c = *lp++; 1639 c = *lp++;
1630 if (c == 0) 1640 if (c == 0)
1631 { 1641 {
1632 if (feof (inf)) 1642 lp--;
1633 break; 1643 break;
1634 CNL;
1635 } 1644 }
1636 } 1645 }
1637 if (c == '*' && *lp == '/') 1646 if (c == '*' && *lp == '/')
@@ -1648,9 +1657,8 @@ consider_token (c, lpp, tokp, is_func, c_ext, level)
1648 1657
1649 if (c == 0) 1658 if (c == 0)
1650 { 1659 {
1651 if (feof (inf)) 1660 lp--;
1652 break; 1661 break;
1653 CNL;
1654 } 1662 }
1655 } 1663 }
1656 1664
@@ -1767,9 +1775,8 @@ consider_token (c, lpp, tokp, is_func, c_ext, level)
1767 { 1775 {
1768 if (c == 0) 1776 if (c == 0)
1769 { 1777 {
1770 if (feof (inf)) 1778 lp--;
1771 break; 1779 break;
1772 CNL;
1773 } 1780 }
1774 /* 1781 /*
1775 * This line used to confuse ctags: 1782 * This line used to confuse ctags:
@@ -1787,9 +1794,8 @@ consider_token (c, lpp, tokp, is_func, c_ext, level)
1787 { 1794 {
1788 if (c == 0) 1795 if (c == 0)
1789 { 1796 {
1790 if (feof (inf)) 1797 lp--;
1791 break; 1798 break;
1792 CNL;
1793 } 1799 }
1794 } 1800 }
1795 if (!isgood (c)) 1801 if (!isgood (c))