diff options
| author | Francesco Potortì | 2002-06-20 11:48:31 +0000 |
|---|---|---|
| committer | Francesco Potortì | 2002-06-20 11:48:31 +0000 |
| commit | 2201e3dcd65542e7b0de277c78d6df13fbf3f77a (patch) | |
| tree | 026bed11d2edfae2b89f0af41a0be934eb3ddfdb | |
| parent | ceaeb365d002f393adcd537ea6c5bb2254910fce (diff) | |
| download | emacs-2201e3dcd65542e7b0de277c78d6df13fbf3f77a.tar.gz emacs-2201e3dcd65542e7b0de277c78d6df13fbf3f77a.zip | |
Use, together with etags.el, an optimised form of tags,
which are almost always unnamed. etags.el looks for an explicit
tag name, then for an implicit one. See make_tag for details.
The change is both forwards and backwards compatible.
(make_tag): New function (was the disabled function new_pfnote).
(make_C_tag): Use it.
| -rw-r--r-- | lib-src/etags.c | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 326e7d10988..c6eb28f3849 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -27,7 +27,7 @@ | |||
| 27 | * 1989 Sam Kendall added C++. | 27 | * 1989 Sam Kendall added C++. |
| 28 | * 1992 Joseph B. Wells improved C and C++ parsing. | 28 | * 1992 Joseph B. Wells improved C and C++ parsing. |
| 29 | * 1993 Francesco Potortì reorganised C and C++. | 29 | * 1993 Francesco Potortì reorganised C and C++. |
| 30 | * 1994 Regexp tags by Tom Tromey. | 30 | * 1994 Line-by-line regexp tags by Tom Tromey. |
| 31 | * 2001 Nested classes by Francesco Potortì (concept by Mykola Dzyuba). | 31 | * 2001 Nested classes by Francesco Potortì (concept by Mykola Dzyuba). |
| 32 | * 2002 #line directives by Francesco Potortì. | 32 | * 2002 #line directives by Francesco Potortì. |
| 33 | * | 33 | * |
| @@ -35,7 +35,7 @@ | |||
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | char pot_etags_version[] = "@(#) pot revision number is 16.27"; | 38 | char pot_etags_version[] = "@(#) pot revision number is 16.29"; |
| 39 | 39 | ||
| 40 | #define TRUE 1 | 40 | #define TRUE 1 |
| 41 | #define FALSE 0 | 41 | #define FALSE 0 |
| @@ -374,7 +374,7 @@ static void find_entries __P((FILE *)); | |||
| 374 | static void free_tree __P((node *)); | 374 | static void free_tree __P((node *)); |
| 375 | static void free_fdesc __P((fdesc *)); | 375 | static void free_fdesc __P((fdesc *)); |
| 376 | static void pfnote __P((char *, bool, char *, int, int, long)); | 376 | static void pfnote __P((char *, bool, char *, int, int, long)); |
| 377 | static void new_pfnote __P((char *, int, bool, char *, int, int, long)); | 377 | static void make_tag __P((char *, int, bool, char *, int, int, long)); |
| 378 | static void invalidate_nodes __P((fdesc *, node **)); | 378 | static void invalidate_nodes __P((fdesc *, node **)); |
| 379 | static void put_entries __P((node *)); | 379 | static void put_entries __P((node *)); |
| 380 | 380 | ||
| @@ -426,7 +426,7 @@ static char | |||
| 426 | /* white chars */ | 426 | /* white chars */ |
| 427 | *white = " \f\t\n\r\v", | 427 | *white = " \f\t\n\r\v", |
| 428 | /* not in a name */ | 428 | /* not in a name */ |
| 429 | *nonam = " \f\t\n\r()=,;", | 429 | *nonam = " \f\t\n\r()=,;", /* look at make_tag before modifying! */ |
| 430 | /* token ending chars */ | 430 | /* token ending chars */ |
| 431 | *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?", | 431 | *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?", |
| 432 | /* token starting chars */ | 432 | /* token starting chars */ |
| @@ -1833,25 +1833,29 @@ pfnote (name, is_func, linestart, linelen, lno, cno) | |||
| 1833 | } | 1833 | } |
| 1834 | 1834 | ||
| 1835 | /* | 1835 | /* |
| 1836 | * Check whether an implicitly named tag should be created, | ||
| 1837 | * then call `pfnote'. | ||
| 1838 | * NAME is a string that is internally copied by this function. | ||
| 1839 | * | ||
| 1836 | * TAGS format specification | 1840 | * TAGS format specification |
| 1837 | * Idea by Sam Kendall <kendall@mv.mv.com> (1997) | 1841 | * Idea by Sam Kendall <kendall@mv.mv.com> (1997) |
| 1838 | * | 1842 | * |
| 1839 | * pfnote should emit the optimized form [unnamed tag] only if: | 1843 | * make_tag creates tags with "implicit tag names" (unnamed tags) |
| 1840 | * 1. name does not contain any of the characters " \t\r\n(),;"; | 1844 | * if the following are all true, assuming NONAM=" \f\t\n\r()=,;": |
| 1841 | * 2. linestart contains name as either a rightmost, or rightmost but | 1845 | * 1. NAME does not contain any of the characters in NONAM; |
| 1846 | * 2. LINESTART contains name as either a rightmost, or rightmost but | ||
| 1842 | * one character, substring; | 1847 | * one character, substring; |
| 1843 | * 3. the character, if any, immediately before name in linestart must | 1848 | * 3. the character, if any, immediately before NAME in LINESTART must |
| 1844 | * be one of the characters " \t(),;"; | 1849 | * be a character in NONAM; |
| 1845 | * 4. the character, if any, immediately after name in linestart must | 1850 | * 4. the character, if any, immediately after NAME in LINESTART must |
| 1846 | * also be one of the characters " \t(),;". | 1851 | * also be a character in NONAM. |
| 1847 | * | 1852 | * |
| 1848 | * The real implementation uses the notinname() macro, which recognises | 1853 | * The implementation uses the notinname() macro, which recognises the |
| 1849 | * characters slightly different from " \t\r\n(),;". See the variable | 1854 | * characters stored in the string `nonam'. |
| 1850 | * `nonam'. | 1855 | * etags.el needs to use the same characters that are in NONAM. |
| 1851 | */ | 1856 | */ |
| 1852 | #define traditional_tag_style TRUE | ||
| 1853 | static void | 1857 | static void |
| 1854 | new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno) | 1858 | make_tag (name, namelen, is_func, linestart, linelen, lno, cno) |
| 1855 | char *name; /* tag name, or NULL if unnamed */ | 1859 | char *name; /* tag name, or NULL if unnamed */ |
| 1856 | int namelen; /* tag length */ | 1860 | int namelen; /* tag length */ |
| 1857 | bool is_func; /* tag is a function */ | 1861 | bool is_func; /* tag is a function */ |
| @@ -1877,7 +1881,7 @@ new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno) | |||
| 1877 | && (cp == linestart | 1881 | && (cp == linestart |
| 1878 | || notinname (cp[-1])) /* rule #3 */ | 1882 | || notinname (cp[-1])) /* rule #3 */ |
| 1879 | && strneq (name, cp, namelen)) /* rule #2 */ | 1883 | && strneq (name, cp, namelen)) /* rule #2 */ |
| 1880 | named = FALSE; /* use unnamed tag */ | 1884 | named = FALSE; /* use implicit tag name */ |
| 1881 | } | 1885 | } |
| 1882 | } | 1886 | } |
| 1883 | 1887 | ||
| @@ -2981,31 +2985,18 @@ make_C_tag (isfun) | |||
| 2981 | { | 2985 | { |
| 2982 | /* This function should never be called when token.valid is FALSE, but | 2986 | /* This function should never be called when token.valid is FALSE, but |
| 2983 | we must protect against invalid input or internal errors. */ | 2987 | we must protect against invalid input or internal errors. */ |
| 2984 | if (DEBUG || token.valid) | 2988 | if (!DEBUG && !token.valid) |
| 2985 | { | 2989 | return; |
| 2986 | if (traditional_tag_style) | ||
| 2987 | { | ||
| 2988 | /* This was the original code. Now we call new_pfnote instead, | ||
| 2989 | which uses the new method for naming tags (see new_pfnote). */ | ||
| 2990 | char *name = NULL; | ||
| 2991 | 2990 | ||
| 2992 | if (CTAGS || token.named) | 2991 | if (!token.valid) /* this case is optimised away if !DEBUG */ |
| 2993 | name = savestr (token_name.buffer); | 2992 | make_tag (concat (token_name.buffer, "##invalid token##", ""), |
| 2994 | if (DEBUG && !token.valid) | 2993 | token_name.len + 17, isfun, token.line, |
| 2995 | { | 2994 | token.offset+token.length+1, token.lineno, token.linepos); |
| 2996 | if (token.named) | 2995 | else |
| 2997 | name = concat (name, "##invalid##", ""); | 2996 | make_tag (token_name.buffer, token_name.len, isfun, token.line, |
| 2998 | else | 2997 | token.offset+token.length+1, token.lineno, token.linepos); |
| 2999 | name = savestr ("##invalid##"); | 2998 | |
| 3000 | } | 2999 | token.valid = FALSE; |
| 3001 | pfnote (name, isfun, token.line, | ||
| 3002 | token.offset+token.length+1, token.lineno, token.linepos); | ||
| 3003 | } | ||
| 3004 | else | ||
| 3005 | new_pfnote (token_name.buffer, token_name.len, isfun, token.line, | ||
| 3006 | token.offset+token.length+1, token.lineno, token.linepos); | ||
| 3007 | token.valid = FALSE; | ||
| 3008 | } | ||
| 3009 | } | 3000 | } |
| 3010 | 3001 | ||
| 3011 | 3002 | ||