aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì1995-02-14 17:31:55 +0000
committerFrancesco Potortì1995-02-14 17:31:55 +0000
commit2bd88040e741c39ac773921869f3708f189f3a61 (patch)
tree1231ed75bea8a76439991c32e5f251a6e690f35c /lib-src
parent95c74a10a48a825370613a89b22eb0ef751edf12 (diff)
downloademacs-2bd88040e741c39ac773921869f3708f189f3a61.tar.gz
emacs-2bd88040e741c39ac773921869f3708f189f3a61.zip
* etags.c (C_entries): Initialise the new members of TOKEN.
(C_entries): Do not allocate a new space for each token found by consider_token. Let make_tag do that instead. (make_tag): Since now TOKEN has memory of where it is taken from, this new macro substitutes both make_tag_from_new_lb and make_tag_from_oth_lb. All callers changed. (TOKEN): Add linepos and buffer members. (main): Initialise token_str. (lang_extensions): Recognise .c++ and .h++ as C++ file suffixes. (token_str): New global variable used by C_entries.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c63
1 files changed, 40 insertions, 23 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index fc0ce6522cc..a7be231f5f1 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -30,9 +30,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
30 * 30 *
31 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. 31 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer.
32 */ 32 */
33char pot_etags_version[] = "@(#) pot revision number is 11.21";
33 34
34 35
35char pot_etags_version[] = "@(#) pot revision number is 11.19";
36#ifdef MSDOS 36#ifdef MSDOS
37#include <fcntl.h> 37#include <fcntl.h>
38#include <sys/param.h> 38#include <sys/param.h>
@@ -218,6 +218,7 @@ struct linebuffer
218}; 218};
219 219
220struct linebuffer lb; /* the current line */ 220struct linebuffer lb; /* the current line */
221struct linebuffer token_str; /* used by C_entries as temporary area */
221struct 222struct
222{ 223{
223 long linepos; 224 long linepos;
@@ -368,12 +369,15 @@ struct lang_entry lang_extensions[] =
368 { "c", default_C_entries }, 369 { "c", default_C_entries },
369 { "h", default_C_entries }, 370 { "h", default_C_entries },
370 371
371 /* .C or .H or .cpp or .cxx or .hxx or .hh or .cc or .cpp: a C++ file */ 372 /* .C or .H or .c++ or .cc or .cpp or .cxx or .h++ or .hh or .hxx:
373 a C++ file */
372 { "C", Cplusplus_entries }, 374 { "C", Cplusplus_entries },
373 { "H", Cplusplus_entries }, 375 { "H", Cplusplus_entries },
376 { "c++", Cplusplus_entries },
374 { "cc", Cplusplus_entries }, 377 { "cc", Cplusplus_entries },
375 { "cpp", Cplusplus_entries }, 378 { "cpp", Cplusplus_entries },
376 { "cxx", Cplusplus_entries }, 379 { "cxx", Cplusplus_entries },
380 { "h++", Cplusplus_entries },
377 { "hh", Cplusplus_entries }, 381 { "hh", Cplusplus_entries },
378 { "hxx", Cplusplus_entries }, 382 { "hxx", Cplusplus_entries },
379 383
@@ -857,6 +861,7 @@ main (argc, argv)
857 init (); /* set up boolean "functions" */ 861 init (); /* set up boolean "functions" */
858 862
859 initbuffer (&lb); 863 initbuffer (&lb);
864 initbuffer (&token_str);
860 initbuffer (&lbs[0].lb); 865 initbuffer (&lbs[0].lb);
861 initbuffer (&lbs[1].lb); 866 initbuffer (&lbs[1].lb);
862 initbuffer (&filename_lb); 867 initbuffer (&filename_lb);
@@ -921,7 +926,6 @@ main (argc, argv)
921 break; 926 break;
922 } 927 }
923 } 928 }
924
925 if (!CTAGS) 929 if (!CTAGS)
926 { 930 {
927 while (nincluded_files-- > 0) 931 while (nincluded_files-- > 0)
@@ -1815,6 +1819,8 @@ typedef struct
1815 logical named; 1819 logical named;
1816 int linelen; 1820 int linelen;
1817 int lineno; 1821 int lineno;
1822 long linepos;
1823 char *buffer;
1818} TOKEN; 1824} TOKEN;
1819 1825
1820#define current_lb_is_new (newndx == curndx) 1826#define current_lb_is_new (newndx == curndx)
@@ -1848,10 +1854,8 @@ do { \
1848 definedef = dnone; \ 1854 definedef = dnone; \
1849} while (0) 1855} while (0)
1850 1856
1851#define make_tag_from_new_lb(isfun) pfnote (tok.str, isfun, tok.named, \ 1857#define make_tag(isfun) pfnote (savestr (token_str.buffer), isfun, \
1852 newlb.buffer, tok.linelen, tok.lineno, newlinepos) 1858 tok.named, tok.buffer, tok.linelen, tok.lineno, tok.linepos)
1853#define make_tag_from_oth_lb(isfun) pfnote (tok.str, isfun, tok.named, \
1854 othlb.buffer, tok.linelen, tok.lineno, othlinepos)
1855 1859
1856void 1860void
1857C_entries (c_ext, inf) 1861C_entries (c_ext, inf)
@@ -2053,17 +2057,28 @@ C_entries (c_ext, inf)
2053 && is_func) 2057 && is_func)
2054 /* function defined in C++ class body */ 2058 /* function defined in C++ class body */
2055 { 2059 {
2056 char *cp = newlb.buffer + tokoff + toklen; 2060 int strsize = strlen(structtag) + 2 + toklen + 1;
2057 char c = *cp; 2061 while (token_str.size < strsize)
2058 *cp = '\0'; 2062 {
2059 tok.str = concat (structtag, "::", 2063 token_str.size *= 2;
2060 newlb.buffer + tokoff); 2064 xrealloc (token_str.buffer, token_str.size);
2061 *cp = c; 2065 }
2066 strcpy (token_str.buffer, structtag);
2067 strcat (token_str.buffer, "::");
2068 strncat (token_str.buffer,
2069 newlb.buffer+tokoff, toklen);
2062 tok.named = TRUE; 2070 tok.named = TRUE;
2063 } 2071 }
2064 else 2072 else
2065 { 2073 {
2066 tok.str = savenstr (newlb.buffer+tokoff, toklen); 2074 while (token_str.size < toklen + 1)
2075 {
2076 token_str.size *= 2;
2077 xrealloc (token_str.buffer, token_str.size);
2078 }
2079 strncpy (token_str.buffer,
2080 newlb.buffer+tokoff, toklen);
2081 token_str.buffer[toklen] = '\0';
2067 if (structdef == stagseen 2082 if (structdef == stagseen
2068 || typdef == tend 2083 || typdef == tend
2069 || (is_func 2084 || (is_func
@@ -2074,6 +2089,8 @@ C_entries (c_ext, inf)
2074 } 2089 }
2075 tok.lineno = lineno; 2090 tok.lineno = lineno;
2076 tok.linelen = tokoff + toklen + 1; 2091 tok.linelen = tokoff + toklen + 1;
2092 tok.buffer = newlb.buffer;
2093 tok.linepos = newlinepos;
2077 2094
2078 if (definedef == dnone 2095 if (definedef == dnone
2079 && (funcdef == ftagseen 2096 && (funcdef == ftagseen
@@ -2084,7 +2101,7 @@ C_entries (c_ext, inf)
2084 switch_line_buffers (); 2101 switch_line_buffers ();
2085 } 2102 }
2086 else 2103 else
2087 make_tag_from_new_lb (is_func); 2104 make_tag (is_func);
2088 } 2105 }
2089 midtoken = FALSE; 2106 midtoken = FALSE;
2090 } 2107 }
@@ -2106,7 +2123,7 @@ C_entries (c_ext, inf)
2106 funcdef = finlist; 2123 funcdef = finlist;
2107 continue; 2124 continue;
2108 case flistseen: 2125 case flistseen:
2109 make_tag_from_oth_lb (TRUE); 2126 make_tag (TRUE);
2110 funcdef = fignore; 2127 funcdef = fignore;
2111 break; 2128 break;
2112 case ftagseen: 2129 case ftagseen:
@@ -2146,7 +2163,7 @@ C_entries (c_ext, inf)
2146 case ftagseen: 2163 case ftagseen:
2147 if (yacc_rules) 2164 if (yacc_rules)
2148 { 2165 {
2149 make_tag_from_oth_lb (FALSE); 2166 make_tag (FALSE);
2150 funcdef = fignore; 2167 funcdef = fignore;
2151 } 2168 }
2152 break; 2169 break;
@@ -2162,7 +2179,7 @@ C_entries (c_ext, inf)
2162 switch (typdef) 2179 switch (typdef)
2163 { 2180 {
2164 case tend: 2181 case tend:
2165 make_tag_from_oth_lb (FALSE); 2182 make_tag (FALSE);
2166 /* FALLTHRU */ 2183 /* FALLTHRU */
2167 default: 2184 default:
2168 typdef = tnone; 2185 typdef = tnone;
@@ -2186,7 +2203,7 @@ C_entries (c_ext, inf)
2186 if (cblev == 0 && typdef == tend) 2203 if (cblev == 0 && typdef == tend)
2187 { 2204 {
2188 typdef = tignore; 2205 typdef = tignore;
2189 make_tag_from_oth_lb (FALSE); 2206 make_tag (FALSE);
2190 break; 2207 break;
2191 } 2208 }
2192 if (funcdef != finlist && funcdef != fignore) 2209 if (funcdef != finlist && funcdef != fignore)
@@ -2210,7 +2227,7 @@ C_entries (c_ext, inf)
2210 if (*lp != '*') 2227 if (*lp != '*')
2211 { 2228 {
2212 typdef = tignore; 2229 typdef = tignore;
2213 make_tag_from_oth_lb (FALSE); 2230 make_tag (FALSE);
2214 } 2231 }
2215 break; 2232 break;
2216 } /* switch (typdef) */ 2233 } /* switch (typdef) */
@@ -2239,7 +2256,7 @@ C_entries (c_ext, inf)
2239 if (cblev == 0 && typdef == tend) 2256 if (cblev == 0 && typdef == tend)
2240 { 2257 {
2241 typdef = tignore; 2258 typdef = tignore;
2242 make_tag_from_oth_lb (FALSE); 2259 make_tag (FALSE);
2243 } 2260 }
2244 } 2261 }
2245 else if (parlev < 0) /* can happen due to ill-conceived #if's. */ 2262 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
@@ -2259,13 +2276,13 @@ C_entries (c_ext, inf)
2259 case stagseen: 2276 case stagseen:
2260 case scolonseen: /* named struct */ 2277 case scolonseen: /* named struct */
2261 structdef = sinbody; 2278 structdef = sinbody;
2262 make_tag_from_oth_lb (FALSE); 2279 make_tag (FALSE);
2263 break; 2280 break;
2264 } 2281 }
2265 switch (funcdef) 2282 switch (funcdef)
2266 { 2283 {
2267 case flistseen: 2284 case flistseen:
2268 make_tag_from_oth_lb (TRUE); 2285 make_tag (TRUE);
2269 /* FALLTHRU */ 2286 /* FALLTHRU */
2270 case fignore: 2287 case fignore:
2271 funcdef = fnone; 2288 funcdef = fnone;