aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorRichard M. Stallman1993-07-09 18:56:47 +0000
committerRichard M. Stallman1993-07-09 18:56:47 +0000
commit591fa824dd089b7f499cb42cd88c671576f4ed06 (patch)
tree948336824b8a8b90999d4eb6de352a7302da3460 /lib-src
parentce3be3d53117edfc77de3efc6bd4288f4bccd237 (diff)
downloademacs-591fa824dd089b7f499cb42cd88c671576f4ed06.tar.gz
emacs-591fa824dd089b7f499cb42cd88c671576f4ed06.zip
(consider_token): was `==', now is `='.
(consider_token): DEFUNs now treated like funcs in ctags mode. (LEVEL_OK_FOR_FUNCDEF): removed. (C_entries): optimized the test that used LEVEL_OK_FOR_FUNCDEF. (C_entries): removed a piece of useless code. (C_entries): making typedef tags is delayed until a semicolon is met. This handles "typedef int X, Y, Z;" correctly.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index c582d61b444..f3007c50836 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -1380,7 +1380,7 @@ typedef enum
1380 skeyseen, /* struct-like keyword seen */ 1380 skeyseen, /* struct-like keyword seen */
1381 stagseen, /* struct-like tag seen */ 1381 stagseen, /* struct-like tag seen */
1382 scolonseen, /* colon seen after struct-like tag */ 1382 scolonseen, /* colon seen after struct-like tag */
1383 sinbody /* in class body: recognize member func defs */ 1383 sinbody /* in struct body: recognize member func defs*/
1384} STRUCTST; 1384} STRUCTST;
1385STRUCTST structdef; 1385STRUCTST structdef;
1386/* 1386/*
@@ -1420,14 +1420,6 @@ logical yacc_rules;
1420 * to the list. 1420 * to the list.
1421 */ 1421 */
1422 1422
1423/*
1424 * LEVEL_OK_FOR_FUNCDEF allows C++ function definition within class body.
1425 * Currently typdef and structdef stuff (typedefs and struct
1426 * definitions) are only noticed when level==0, but that may change.
1427 */
1428#define LEVEL_OK_FOR_FUNCDEF() \
1429 (level==0 || (cplpl && level==1 && structdef==sinbody))
1430
1431#define curlb (lbs[curndx].lb) 1423#define curlb (lbs[curndx].lb)
1432#define othlb (lbs[1-curndx].lb) 1424#define othlb (lbs[1-curndx].lb)
1433#define newlb (lbs[newndx].lb) 1425#define newlb (lbs[newndx].lb)
@@ -1467,7 +1459,7 @@ C_entries (c_ext)
1467 char tokb[BUFSIZ]; /* latest token name for funcdef & structdef */ 1459 char tokb[BUFSIZ]; /* latest token name for funcdef & structdef */
1468 register int tokoff; /* offset in line of start of latest token */ 1460 register int tokoff; /* offset in line of start of latest token */
1469 register int toklen; /* length of latest token */ 1461 register int toklen; /* length of latest token */
1470 int level; /* current curly brace level */ 1462 int cblev; /* current curly brace level */
1471 logical incomm, inquote, inchar, quotednl, midtoken; 1463 logical incomm, inquote, inchar, quotednl, midtoken;
1472 logical cplpl; 1464 logical cplpl;
1473 1465
@@ -1480,7 +1472,7 @@ C_entries (c_ext)
1480 definedef = dnone; funcdef = fnone; typdef= tnone; structdef= snone; 1472 definedef = dnone; funcdef = fnone; typdef= tnone; structdef= snone;
1481 next_token_is_func = yacc_rules = FALSE; 1473 next_token_is_func = yacc_rules = FALSE;
1482 midtoken = inquote = inchar = incomm = quotednl = FALSE; 1474 midtoken = inquote = inchar = incomm = quotednl = FALSE;
1483 level = 0; 1475 cblev = 0;
1484 cplpl = c_ext & C_PLPL; 1476 cplpl = c_ext & C_PLPL;
1485 1477
1486 C_create_stabs (); 1478 C_create_stabs ();
@@ -1573,10 +1565,10 @@ C_entries (c_ext)
1573 typdef= tnone; structdef= snone; 1565 typdef= tnone; structdef= snone;
1574 next_token_is_func = FALSE; 1566 next_token_is_func = FALSE;
1575 midtoken = inquote = inchar = incomm = quotednl = FALSE; 1567 midtoken = inquote = inchar = incomm = quotednl = FALSE;
1576 level = 0; 1568 cblev = 0;
1577 yacc_rules = !yacc_rules; 1569 yacc_rules = !yacc_rules;
1578 continue; 1570 continue;
1579 } 1571 }
1580 case '#': 1572 case '#':
1581 if (lp == newlb.buffer + 1 && definedef == dnone) 1573 if (lp == newlb.buffer + 1 && definedef == dnone)
1582 definedef = dsharpseen; 1574 definedef = dsharpseen;
@@ -1584,9 +1576,10 @@ C_entries (c_ext)
1584 } /* switch (c) */ 1576 } /* switch (c) */
1585 1577
1586 1578
1587 if (LEVEL_OK_FOR_FUNCDEF () 1579 /* Consider token only if some complicated conditions are satisfied. */
1580 if (((cblev == 0 && structdef != scolonseen)
1581 || (cblev == 1 && cplpl && structdef == sinbody))
1588 && definedef != dignorerest 1582 && definedef != dignorerest
1589 && structdef != scolonseen
1590 && funcdef != finlist) 1583 && funcdef != finlist)
1591 { 1584 {
1592 if (midtoken) 1585 if (midtoken)
@@ -1612,7 +1605,7 @@ C_entries (c_ext)
1612 tok.rewritten = FALSE; 1605 tok.rewritten = FALSE;
1613 if (yacc_rules 1606 if (yacc_rules
1614 || consider_token (c, lp, &tok, 1607 || consider_token (c, lp, &tok,
1615 c_ext, level, &is_func)) 1608 c_ext, cblev, &is_func))
1616 { 1609 {
1617 if (structdef == sinbody 1610 if (structdef == sinbody
1618 && definedef == dnone && is_func) 1611 && definedef == dnone && is_func)
@@ -1628,7 +1621,9 @@ C_entries (c_ext)
1628 sprintf (tokb, "%.*s", tok.len, tok.p); 1621 sprintf (tokb, "%.*s", tok.len, tok.p);
1629 } 1622 }
1630 1623
1631 if (funcdef == ftagseen || structdef == stagseen) 1624 if (funcdef == ftagseen
1625 || structdef == stagseen
1626 || typdef == tend)
1632 { 1627 {
1633 if (newndx == curndx) 1628 if (newndx == curndx)
1634 curndx = 1 - curndx; /* switch line buffers */ 1629 curndx = 1 - curndx; /* switch line buffers */
@@ -1683,13 +1678,14 @@ C_entries (c_ext)
1683 } 1678 }
1684 break; 1679 break;
1685 case ';': 1680 case ';':
1681 if (cblev == 0 && typdef == tend)
1682 {
1683 typdef = tnone;
1684 MAKE_TAG_FROM_OTH_LB (FALSE);
1685 }
1686 funcdef = fnone; 1686 funcdef = fnone;
1687 /* FALLTHRU */ 1687 /* FALLTHRU */
1688 case ',': 1688 case ',':
1689 if (funcdef != finlist)
1690 funcdef = fnone;
1691 if (level == 0 && typdef == tend)
1692 typdef = tnone;
1693 /* FALLTHRU */ 1689 /* FALLTHRU */
1694 case '[': 1690 case '[':
1695 if (funcdef != finlist) 1691 if (funcdef != finlist)
@@ -1728,7 +1724,7 @@ C_entries (c_ext)
1728 MAKE_TAG_FROM_OTH_LB (FALSE); 1724 MAKE_TAG_FROM_OTH_LB (FALSE);
1729 break; 1725 break;
1730 } 1726 }
1731 level++; 1727 cblev++;
1732 /* FALLTHRU */ 1728 /* FALLTHRU */
1733 case '*': 1729 case '*':
1734 if (funcdef == flistseen) 1730 if (funcdef == flistseen)
@@ -1739,10 +1735,10 @@ C_entries (c_ext)
1739 break; 1735 break;
1740 case '}': 1736 case '}':
1741 if (!noindentypedefs && lp == newlb.buffer + 1) 1737 if (!noindentypedefs && lp == newlb.buffer + 1)
1742 level = 0; /* reset level if first column */ 1738 cblev = 0; /* reset curly brace level if first column */
1743 else if (level > 0) 1739 else if (cblev > 0)
1744 level--; 1740 cblev--;
1745 if (level == 0) 1741 if (cblev == 0)
1746 { 1742 {
1747 if (typdef == tinbody) 1743 if (typdef == tinbody)
1748 typdef = tend; 1744 typdef = tend;
@@ -1785,12 +1781,12 @@ C_entries (c_ext)
1785 */ 1781 */
1786 1782
1787logical 1783logical
1788consider_token (c, lp, tokp, c_ext, level, is_func) 1784consider_token (c, lp, tokp, c_ext, cblev, is_func)
1789 register char c; /* IN: first char after the token */ 1785 register char c; /* IN: first char after the token */
1790 register char *lp; /* IN: lp points to 2nd char after the token */ 1786 register char *lp; /* IN: lp points to 2nd char after the token */
1791 register TOKEN *tokp; /* IN */ 1787 register TOKEN *tokp; /* IN: token pointer */
1792 int c_ext; /* IN */ 1788 int c_ext; /* IN: C extensions mask */
1793 int level; /* IN */ 1789 int cblev; /* IN: curly brace level */
1794 logical *is_func; /* OUT */ 1790 logical *is_func; /* OUT */
1795{ 1791{
1796 logical firsttok; /* TRUE if have seen first token in ()'s */ 1792 logical firsttok; /* TRUE if have seen first token in ()'s */
@@ -1871,9 +1867,10 @@ consider_token (c, lp, tokp, c_ext, level, is_func)
1871 } 1867 }
1872 1868
1873 /* 1869 /*
1874 * This structdef business is currently only invoked when level==0. 1870 * This structdef business is currently only invoked when cblev==0.
1875 * It should be recursively invoked whatever the level, and a stack of 1871 * It should be recursively invoked whatever the curly brace level,
1876 * states kept, to allow for definitions of structs within structs. 1872 * and a stack of states kept, to allow for definitions of structs
1873 * within structs.
1877 * 1874 *
1878 * This structdef business is NOT invoked when we are ctags and the 1875 * This structdef business is NOT invoked when we are ctags and the
1879 * file is plain C. This is because a struct tag may have the same 1876 * file is plain C. This is because a struct tag may have the same
@@ -1889,7 +1886,7 @@ consider_token (c, lp, tokp, c_ext, level, is_func)
1889 case st_C_struct: 1886 case st_C_struct:
1890 case st_C_enum: 1887 case st_C_enum:
1891 if (typdef == ttypedseen 1888 if (typdef == ttypedseen
1892 || (typedefs_and_cplusplus && level == 0 && structdef == snone)) 1889 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
1893 { 1890 {
1894 structdef = skeyseen; 1891 structdef = skeyseen;
1895 structkey = tokse; 1892 structkey = tokse;
@@ -1938,6 +1935,7 @@ consider_token (c, lp, tokp, c_ext, level, is_func)
1938 if (next_token_is_func) 1935 if (next_token_is_func)
1939 { 1936 {
1940 next_token_is_func = FALSE; 1937 next_token_is_func = FALSE;
1938 *is_func = TRUE;
1941 return (TRUE); 1939 return (TRUE);
1942 } 1940 }
1943 1941
@@ -1945,7 +1943,7 @@ consider_token (c, lp, tokp, c_ext, level, is_func)
1945 switch (toktype) 1943 switch (toktype)
1946 { 1944 {
1947 case st_C_typespec: 1945 case st_C_typespec:
1948 funcdef == fnone; /* should be useless */ 1946 funcdef = fnone; /* should be useless */
1949 return (FALSE); 1947 return (FALSE);
1950 default: 1948 default:
1951 funcdef = ftagseen; 1949 funcdef = ftagseen;
@@ -2406,7 +2404,8 @@ L_getit ()
2406 cp[0] = 0; 2404 cp[0] = 0;
2407 (void) strcpy (nambuf, dbp); 2405 (void) strcpy (nambuf, dbp);
2408 cp[0] = c; 2406 cp[0] = c;
2409 pfnote (nambuf, TRUE, FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 2407 pfnote (nambuf, TRUE, FALSE, lb.buffer,
2408 cp - lb.buffer + 1, lineno, linecharno);
2410 pfcnt++; 2409 pfcnt++;
2411} 2410}
2412 2411