aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì1995-02-22 15:06:49 +0000
committerFrancesco Potortì1995-02-22 15:06:49 +0000
commit75bdbc6afde32c3f981a5f1ec02aed56023f5be8 (patch)
treea6ce5632dfe62b352168a6b966f6d30006777645 /lib-src
parentbeecf6a1d16afdf34dfecd38cc5cfbb05c0b59a6 (diff)
downloademacs-75bdbc6afde32c3f981a5f1ec02aed56023f5be8.tar.gz
emacs-75bdbc6afde32c3f981a5f1ec02aed56023f5be8.zip
* etags.c (C_entries): token_saved removed. Initialise tok.valid and
savetok.valid. Mark token as valid when it is initialised. (make_tag): Make token only if token is valid and reset validity. (CNL_SAVE_DEFINEDEF): Test for savetok.valid instead of token_saved. (TOKEN): Added a new member: valid.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c63
1 files changed, 37 insertions, 26 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 80f7893e039..5c293b6cacf 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -31,7 +31,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
31 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. 31 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer.
32 */ 32 */
33 33
34char pot_etags_version[] = "@(#) pot revision number is 11.24"; 34char pot_etags_version[] = "@(#) pot revision number is 11.25";
35
36#define TRUE 1
37#define FALSE 0
38#ifndef DEBUG
39# define DEBUG FALSE
40#endif
35 41
36#ifdef MSDOS 42#ifdef MSDOS
37#include <fcntl.h> 43#include <fcntl.h>
@@ -71,9 +77,6 @@ extern int errno;
71#include <regex.h> 77#include <regex.h>
72#endif /* ETAGS_REGEXPS */ 78#endif /* ETAGS_REGEXPS */
73 79
74#define TRUE 1
75#define FALSE 0
76
77/* Define CTAGS to make the program "ctags" compatible with the usual one. 80/* Define CTAGS to make the program "ctags" compatible with the usual one.
78 Let it undefined to make the program "etags", which makes emacs-style 81 Let it undefined to make the program "etags", which makes emacs-style
79 tag tables and tags typedefs, #defines and struct/union/enum by default. */ 82 tag tables and tags typedefs, #defines and struct/union/enum by default. */
@@ -218,7 +221,7 @@ struct linebuffer
218}; 221};
219 222
220struct linebuffer lb; /* the current line */ 223struct linebuffer lb; /* the current line */
221struct linebuffer token_str; /* used by C_entries as temporary area */ 224struct linebuffer token_name; /* used by C_entries as temporary area */
222struct 225struct
223{ 226{
224 long linepos; 227 long linepos;
@@ -861,7 +864,7 @@ main (argc, argv)
861 init (); /* set up boolean "functions" */ 864 init (); /* set up boolean "functions" */
862 865
863 initbuffer (&lb); 866 initbuffer (&lb);
864 initbuffer (&token_str); 867 initbuffer (&token_name);
865 initbuffer (&lbs[0].lb); 868 initbuffer (&lbs[0].lb);
866 initbuffer (&lbs[1].lb); 869 initbuffer (&lbs[1].lb);
867 initbuffer (&filename_lb); 870 initbuffer (&filename_lb);
@@ -1809,6 +1812,7 @@ consider_token (str, len, c, c_ext, cblev, is_func)
1809 */ 1812 */
1810typedef struct 1813typedef struct
1811{ 1814{
1815 logical valid;
1812 char *str; 1816 char *str;
1813 logical named; 1817 logical named;
1814 int linelen; 1818 int linelen;
@@ -1840,16 +1844,22 @@ do { \
1840#define CNL \ 1844#define CNL \
1841do { \ 1845do { \
1842 CNL_SAVE_DEFINEDEF; \ 1846 CNL_SAVE_DEFINEDEF; \
1843 if (token_saved) \ 1847 if (savetok.valid) \
1844 { \ 1848 { \
1845 tok = savetok; \ 1849 tok = savetok; \
1846 token_saved = FALSE; \ 1850 savetok.valid = FALSE; \
1847 } \ 1851 } \
1848 definedef = dnone; \ 1852 definedef = dnone; \
1849} while (0) 1853} while (0)
1850 1854
1851#define make_tag(isfun) pfnote (savestr (token_str.buffer), isfun, \ 1855#define make_tag(isfun) do \
1852 tok.named, tok.buffer, tok.linelen, tok.lineno, tok.linepos) 1856{ \
1857 if (tok.valid) \
1858 pfnote (savestr (token_name.buffer), isfun, tok.named, \
1859 tok.buffer, tok.linelen, tok.lineno, tok.linepos); \
1860 else if (DEBUG) abort (); \
1861 tok.valid = FALSE; \
1862} while (0)
1853 1863
1854void 1864void
1855C_entries (c_ext, inf) 1865C_entries (c_ext, inf)
@@ -1866,9 +1876,9 @@ C_entries (c_ext, inf)
1866 int parlev; /* current parenthesis level */ 1876 int parlev; /* current parenthesis level */
1867 logical incomm, inquote, inchar, quotednl, midtoken; 1877 logical incomm, inquote, inchar, quotednl, midtoken;
1868 logical cplpl; 1878 logical cplpl;
1869 logical token_saved; /* token saved */
1870 TOKEN savetok; /* token saved during preprocessor handling */ 1879 TOKEN savetok; /* token saved during preprocessor handling */
1871 1880
1881
1872 curndx = newndx = 0; 1882 curndx = newndx = 0;
1873 lineno = 0; 1883 lineno = 0;
1874 charno = 0; 1884 charno = 0;
@@ -1876,8 +1886,9 @@ C_entries (c_ext, inf)
1876 *lp = 0; 1886 *lp = 0;
1877 1887
1878 definedef = dnone; funcdef = fnone; typdef = tnone; structdef = snone; 1888 definedef = dnone; funcdef = fnone; typdef = tnone; structdef = snone;
1879 next_token_is_func = yacc_rules = token_saved = FALSE; 1889 next_token_is_func = yacc_rules = FALSE;
1880 midtoken = inquote = inchar = incomm = quotednl = FALSE; 1890 midtoken = inquote = inchar = incomm = quotednl = FALSE;
1891 tok.valid = savetok.valid = FALSE;
1881 cblev = 0; 1892 cblev = 0;
1882 parlev = 0; 1893 parlev = 0;
1883 cplpl = c_ext & C_PLPL; 1894 cplpl = c_ext & C_PLPL;
@@ -2052,29 +2063,29 @@ C_entries (c_ext, inf)
2052 /* function defined in C++ class body */ 2063 /* function defined in C++ class body */
2053 { 2064 {
2054 int strsize = strlen(structtag) + 2 + toklen + 1; 2065 int strsize = strlen(structtag) + 2 + toklen + 1;
2055 while (token_str.size < strsize) 2066 while (token_name.size < strsize)
2056 { 2067 {
2057 token_str.size *= 2; 2068 token_name.size *= 2;
2058 token_str.buffer = xrealloc(token_str.buffer, 2069 token_name.buffer=xrealloc(token_name.buffer,
2059 token_str.size); 2070 token_name.size);
2060 } 2071 }
2061 strcpy (token_str.buffer, structtag); 2072 strcpy (token_name.buffer, structtag);
2062 strcat (token_str.buffer, "::"); 2073 strcat (token_name.buffer, "::");
2063 strncat (token_str.buffer, 2074 strncat (token_name.buffer,
2064 newlb.buffer+tokoff, toklen); 2075 newlb.buffer+tokoff, toklen);
2065 tok.named = TRUE; 2076 tok.named = TRUE;
2066 } 2077 }
2067 else 2078 else
2068 { 2079 {
2069 while (token_str.size < toklen + 1) 2080 while (token_name.size < toklen + 1)
2070 { 2081 {
2071 token_str.size *= 2; 2082 token_name.size *= 2;
2072 token_str.buffer = xrealloc(token_str.buffer, 2083 token_name.buffer=xrealloc(token_name.buffer,
2073 token_str.size); 2084 token_name.size);
2074 } 2085 }
2075 strncpy (token_str.buffer, 2086 strncpy (token_name.buffer,
2076 newlb.buffer+tokoff, toklen); 2087 newlb.buffer+tokoff, toklen);
2077 token_str.buffer[toklen] = '\0'; 2088 token_name.buffer[toklen] = '\0';
2078 if (structdef == stagseen 2089 if (structdef == stagseen
2079 || typdef == tend 2090 || typdef == tend
2080 || (is_func 2091 || (is_func
@@ -2087,6 +2098,7 @@ C_entries (c_ext, inf)
2087 tok.linelen = tokoff + toklen + 1; 2098 tok.linelen = tokoff + toklen + 1;
2088 tok.buffer = newlb.buffer; 2099 tok.buffer = newlb.buffer;
2089 tok.linepos = newlinepos; 2100 tok.linepos = newlinepos;
2101 tok.valid = TRUE;
2090 2102
2091 if (definedef == dnone 2103 if (definedef == dnone
2092 && (funcdef == ftagseen 2104 && (funcdef == ftagseen
@@ -2131,7 +2143,6 @@ C_entries (c_ext, inf)
2131 break; 2143 break;
2132 case dsharpseen: 2144 case dsharpseen:
2133 savetok = tok; 2145 savetok = tok;
2134 token_saved = TRUE;
2135 } 2146 }
2136 if (!yacc_rules || lp == newlb.buffer + 1) 2147 if (!yacc_rules || lp == newlb.buffer + 1)
2137 { 2148 {