diff options
| author | Francesco Potortì | 1994-09-30 17:18:24 +0000 |
|---|---|---|
| committer | Francesco Potortì | 1994-09-30 17:18:24 +0000 |
| commit | ee70dba58986cc93c0e188ac28c88a1a979857cf (patch) | |
| tree | 5040189a97724614be5ae1daced3905a3b990846 /lib-src | |
| parent | 48be3850d42faf41b41687aef388cbe7310b42c6 (diff) | |
| download | emacs-ee70dba58986cc93c0e188ac28c88a1a979857cf.tar.gz emacs-ee70dba58986cc93c0e188ac28c88a1a979857cf.zip | |
* etags.c (C_entries): Recognise typedef of ANSI style functions.
(C_entries): Recognise #define inside a struct.
(C_entries): ANSI tells that preprocessor commands do not have to
start on the first column.
(print_help): Documentation corrected for -d and -D.
(white, endtk): ANSI tells the vertical tab is a separator.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 73 |
1 files changed, 57 insertions, 16 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index f4fea9ff1dd..f32d35d9cdf 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -231,8 +231,8 @@ long linecharno; /* charno of start of line; not used by C, but | |||
| 231 | 231 | ||
| 232 | char *curfile, /* current input file name */ | 232 | char *curfile, /* current input file name */ |
| 233 | *tagfile, /* output file */ | 233 | *tagfile, /* output file */ |
| 234 | *white = " \f\t\n", /* white chars */ | 234 | *white = " \f\t\n\013", /* white chars */ |
| 235 | *endtk = " \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?", /* token ending chars */ | 235 | *endtk = " \t\n\013\"'#()[]{}=-+%*/&|^~!<>;,.:?", /* token ending chars */ |
| 236 | /* token starting chars */ | 236 | /* token starting chars */ |
| 237 | *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~", | 237 | *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~", |
| 238 | /* valid in-token chars */ | 238 | /* valid in-token chars */ |
| @@ -333,11 +333,11 @@ names from stdin.\n\n", progname); | |||
| 333 | 333 | ||
| 334 | if (CTAGS) | 334 | if (CTAGS) |
| 335 | puts ("-d, --defines\n\ | 335 | puts ("-d, --defines\n\ |
| 336 | Create tag entries for C #defines, too."); | 336 | Create tag entries for constant C #defines, too."); |
| 337 | else | 337 | else |
| 338 | puts ("-D, --no-defines\n\ | 338 | puts ("-D, --no-defines\n\ |
| 339 | Don't create tag entries for C #defines. This makes the tags\n\ | 339 | Don't create tag entries for constant C #defines. This makes\n\ |
| 340 | file smaller."); | 340 | the tags file smaller."); |
| 341 | 341 | ||
| 342 | if (!CTAGS) | 342 | if (!CTAGS) |
| 343 | puts ("-i FILE, --include=FILE\n\ | 343 | puts ("-i FILE, --include=FILE\n\ |
| @@ -1413,7 +1413,8 @@ consider_token (c, tokp, c_ext, cblev, is_func) | |||
| 1413 | return (FALSE); | 1413 | return (FALSE); |
| 1414 | case ddefineseen: | 1414 | case ddefineseen: |
| 1415 | /* | 1415 | /* |
| 1416 | * Make a tag for any macro. | 1416 | * Make a tag for any macro, unless it is a constant |
| 1417 | * and constantypedefs is FALSE. | ||
| 1417 | */ | 1418 | */ |
| 1418 | definedef = dignorerest; | 1419 | definedef = dignorerest; |
| 1419 | *is_func = (c == '('); | 1420 | *is_func = (c == '('); |
| @@ -1745,19 +1746,40 @@ C_entries (c_ext, inf) | |||
| 1745 | else | 1746 | else |
| 1746 | break; | 1747 | break; |
| 1747 | case '#': | 1748 | case '#': |
| 1748 | if (lp == newlb.buffer + 1 && definedef == dnone) | 1749 | if (definedef == dnone) |
| 1749 | definedef = dsharpseen; | 1750 | { |
| 1751 | char *cp; | ||
| 1752 | logical cpptoken = TRUE; | ||
| 1753 | |||
| 1754 | /* Look back on this line. If all blanks, or nonblanks | ||
| 1755 | followed by an end of comment, this is a preprocessor | ||
| 1756 | token. */ | ||
| 1757 | for (cp = newlb.buffer; cp < lp-1; cp++) | ||
| 1758 | if (!iswhite (*cp)) | ||
| 1759 | { | ||
| 1760 | if (*cp == '*' && *(cp+1) == '/') | ||
| 1761 | { | ||
| 1762 | cp++; | ||
| 1763 | cpptoken = TRUE; | ||
| 1764 | } | ||
| 1765 | else | ||
| 1766 | cpptoken = FALSE; | ||
| 1767 | } | ||
| 1768 | if (cpptoken) | ||
| 1769 | definedef = dsharpseen; | ||
| 1770 | } /* if (definedef == dnone) */ | ||
| 1771 | |||
| 1750 | continue; | 1772 | continue; |
| 1751 | } /* switch (c) */ | 1773 | } /* switch (c) */ |
| 1752 | 1774 | ||
| 1753 | 1775 | ||
| 1754 | /* Consider token only if some complicated conditions are satisfied. */ | 1776 | /* Consider token only if some complicated conditions are satisfied. */ |
| 1755 | if (((cblev == 0 && structdef != scolonseen) | 1777 | if ((definedef != dnone |
| 1778 | || (cblev == 0 && structdef != scolonseen) | ||
| 1756 | || (cblev == 1 && cplpl && structdef == sinbody)) | 1779 | || (cblev == 1 && cplpl && structdef == sinbody)) |
| 1757 | && typdef != tignore | 1780 | && typdef != tignore |
| 1758 | && definedef != dignorerest | 1781 | && definedef != dignorerest |
| 1759 | && (funcdef != finlist | 1782 | && funcdef != finlist) |
| 1760 | || definedef != dnone)) | ||
| 1761 | { | 1783 | { |
| 1762 | if (midtoken) | 1784 | if (midtoken) |
| 1763 | { | 1785 | { |
| @@ -1766,8 +1788,8 @@ C_entries (c_ext, inf) | |||
| 1766 | if (cplpl && c == ':' && *lp == ':' && begtoken(*(lp + 1))) | 1788 | if (cplpl && c == ':' && *lp == ':' && begtoken(*(lp + 1))) |
| 1767 | { | 1789 | { |
| 1768 | /* | 1790 | /* |
| 1769 | * This handles :: in the middle, but not at beginning | 1791 | * This handles :: in the middle, but not at the |
| 1770 | * of an identifier. | 1792 | * beginning of an identifier. |
| 1771 | */ | 1793 | */ |
| 1772 | lp += 2; | 1794 | lp += 2; |
| 1773 | toklen += 3; | 1795 | toklen += 3; |
| @@ -1788,11 +1810,11 @@ C_entries (c_ext, inf) | |||
| 1788 | && is_func) | 1810 | && is_func) |
| 1789 | /* function defined in C++ class body */ | 1811 | /* function defined in C++ class body */ |
| 1790 | { | 1812 | { |
| 1791 | tok.named = TRUE; | ||
| 1792 | sprintf (nameb, "%s::%.*s", | 1813 | sprintf (nameb, "%s::%.*s", |
| 1793 | ((structtag[0] == '\0') | 1814 | ((structtag[0] == '\0') |
| 1794 | ? "_anonymous_" : structtag), | 1815 | ? "_anonymous_" : structtag), |
| 1795 | tok.len, tok.p); | 1816 | tok.len, tok.p); |
| 1817 | tok.named = TRUE; | ||
| 1796 | } | 1818 | } |
| 1797 | else | 1819 | else |
| 1798 | { | 1820 | { |
| @@ -1800,7 +1822,10 @@ C_entries (c_ext, inf) | |||
| 1800 | } | 1822 | } |
| 1801 | 1823 | ||
| 1802 | if (structdef == stagseen | 1824 | if (structdef == stagseen |
| 1803 | || typdef == tend) | 1825 | || typdef == tend |
| 1826 | /* Better not to name the #define's in | ||
| 1827 | order to reduce the TAGS file size. | ||
| 1828 | || definedef == dignorerest */ ) | ||
| 1804 | tok.named = TRUE; | 1829 | tok.named = TRUE; |
| 1805 | 1830 | ||
| 1806 | if (definedef == dnone | 1831 | if (definedef == dnone |
| @@ -1845,7 +1870,7 @@ C_entries (c_ext, inf) | |||
| 1845 | structdef = snone; | 1870 | structdef = snone; |
| 1846 | break; | 1871 | break; |
| 1847 | case dsharpseen: | 1872 | case dsharpseen: |
| 1848 | /* Take a quick peek ahead for define directive, | 1873 | /* Take a quick peek ahead for a define directive, |
| 1849 | so we can avoid saving the token when not absolutely | 1874 | so we can avoid saving the token when not absolutely |
| 1850 | necessary. [This is a speed hack.] */ | 1875 | necessary. [This is a speed hack.] */ |
| 1851 | if (c == 'd' && strneq(lp, "efine", 5) | 1876 | if (c == 'd' && strneq(lp, "efine", 5) |
| @@ -1938,6 +1963,22 @@ C_entries (c_ext, inf) | |||
| 1938 | break; | 1963 | break; |
| 1939 | switch (funcdef) | 1964 | switch (funcdef) |
| 1940 | { | 1965 | { |
| 1966 | case fnone: | ||
| 1967 | switch (typdef) | ||
| 1968 | { | ||
| 1969 | case ttypedseen: | ||
| 1970 | case tend: | ||
| 1971 | /* Make sure that the next char is not a '*'. | ||
| 1972 | This handles constructs like: | ||
| 1973 | typedef void OperatorFun (int fun); */ | ||
| 1974 | if (*lp != '*') | ||
| 1975 | { | ||
| 1976 | typdef = tignore; | ||
| 1977 | MAKE_TAG_FROM_OTH_LB (FALSE); | ||
| 1978 | } | ||
| 1979 | break; | ||
| 1980 | } /* switch (typdef) */ | ||
| 1981 | break; | ||
| 1941 | case ftagseen: | 1982 | case ftagseen: |
| 1942 | funcdef = fstartlist; | 1983 | funcdef = fstartlist; |
| 1943 | break; | 1984 | break; |