aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì2002-03-12 13:31:57 +0000
committerFrancesco Potortì2002-03-12 13:31:57 +0000
commit49adb67ab27097fcd167f696713a017a82f85837 (patch)
tree03938e300541006392f76431b3758cda87de7210 /lib-src
parent1381f9e6a84626e712dcde6ba171f32d378a4395 (diff)
downloademacs-49adb67ab27097fcd167f696713a017a82f85837.tar.gz
emacs-49adb67ab27097fcd167f696713a017a82f85837.zip
* etags.c (Python_functions): Skip spaces at beginning of lines.
(Python_functions, PHP_functions): Name tags, for ctags' sake. (TeX_commands): Name tags. Correction of old disabled code. * etags.c (curfiledir, curtagfname): New global variables. (process_file): Initialise them. (readline): Canonicalize the name found in #line directive.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c108
1 files changed, 70 insertions, 38 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 60a67ff80f8..98c34407044 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -33,7 +33,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33 * Francesco Potortì <pot@gnu.org> has maintained it since 1993. 33 * Francesco Potortì <pot@gnu.org> has maintained it since 1993.
34 */ 34 */
35 35
36char pot_etags_version[] = "@(#) pot revision number is 14.39"; 36char pot_etags_version[] = "@(#) pot revision number is 15.2";
37 37
38#define TRUE 1 38#define TRUE 1
39#define FALSE 0 39#define FALSE 0
@@ -355,7 +355,9 @@ static char *cwd; /* current working directory */
355static char *tagfiledir; /* directory of tagfile */ 355static char *tagfiledir; /* directory of tagfile */
356static FILE *tagf; /* ioptr for tags file */ 356static FILE *tagf; /* ioptr for tags file */
357 357
358static char *curfile; /* current input file name */ 358static char *curfile; /* current input uncompressed file name */
359static char *curfiledir; /* absolute dir of curfile */
360static char *curtagfname; /* current file name to write in tagfile */
359static language *curlang; /* current language */ 361static language *curlang; /* current language */
360 362
361static int lineno; /* line number of current line */ 363static int lineno; /* line number of current line */
@@ -1394,7 +1396,7 @@ process_file (file)
1394 uncompressed_name = savenstr (file, ext - file); 1396 uncompressed_name = savenstr (file, ext - file);
1395 } 1397 }
1396 1398
1397 /* If the canonicalised uncompressed name has already be dealt with, 1399 /* If the canonicalized uncompressed name has already be dealt with,
1398 skip it silently, else add it to the list. */ 1400 skip it silently, else add it to the list. */
1399 { 1401 {
1400 typedef struct processed_file 1402 typedef struct processed_file
@@ -1482,20 +1484,23 @@ process_file (file)
1482 goto exit; 1484 goto exit;
1483 } 1485 }
1484 1486
1485 if (filename_is_absolute (uncompressed_name)) 1487 curfile = uncompressed_name;
1488 curfiledir = absolute_dirname (curfile, cwd);
1489 if (filename_is_absolute (curfile))
1486 { 1490 {
1487 /* file is an absolute file name. Canonicalise it. */ 1491 /* file is an absolute file name. Canonicalize it. */
1488 curfile = absolute_filename (uncompressed_name, cwd); 1492 curtagfname = absolute_filename (curfile, NULL);
1489 } 1493 }
1490 else 1494 else
1491 { 1495 {
1492 /* file is a file name relative to cwd. Make it relative 1496 /* file is a file name relative to cwd. Make it relative
1493 to the directory of the tags file. */ 1497 to the directory of the tags file. */
1494 curfile = relative_filename (uncompressed_name, tagfiledir); 1498 curtagfname = relative_filename (curfile, tagfiledir);
1495 } 1499 }
1496 nocharno = FALSE; /* use char position when making tags */ 1500 nocharno = FALSE; /* use char position when making tags */
1497 find_entries (uncompressed_name, inf); 1501 find_entries (curfile, inf);
1498 1502
1503 free (curfiledir);
1499 if (real_name == compressed_name) 1504 if (real_name == compressed_name)
1500 retval = pclose (inf); 1505 retval = pclose (inf);
1501 else 1506 else
@@ -1642,8 +1647,8 @@ pfnote (name, is_func, linestart, linelen, lno, cno)
1642 /* If ctags mode, change name "main" to M<thisfilename>. */ 1647 /* If ctags mode, change name "main" to M<thisfilename>. */
1643 if (CTAGS && !cxref_style && streq (name, "main")) 1648 if (CTAGS && !cxref_style && streq (name, "main"))
1644 { 1649 {
1645 register char *fp = etags_strrchr (curfile, '/'); 1650 register char *fp = etags_strrchr (curtagfname, '/');
1646 np->name = concat ("M", fp == NULL ? curfile : fp + 1, ""); 1651 np->name = concat ("M", fp == NULL ? curtagfname : fp + 1, "");
1647 fp = etags_strrchr (np->name, '.'); 1652 fp = etags_strrchr (np->name, '.');
1648 if (fp != NULL && fp[1] != '\0' && fp[2] == '\0') 1653 if (fp != NULL && fp[1] != '\0' && fp[2] == '\0')
1649 fp[0] = '\0'; 1654 fp[0] = '\0';
@@ -1651,7 +1656,7 @@ pfnote (name, is_func, linestart, linelen, lno, cno)
1651 else 1656 else
1652 np->name = name; 1657 np->name = name;
1653 np->been_warned = FALSE; 1658 np->been_warned = FALSE;
1654 np->file = curfile; 1659 np->file = curtagfname;
1655 np->is_func = is_func; 1660 np->is_func = is_func;
1656 np->lno = lno; 1661 np->lno = lno;
1657 if (nocharno) 1662 if (nocharno)
@@ -1838,7 +1843,6 @@ add_node (np, cur_node_p)
1838} 1843}
1839 1844
1840 1845
1841#if !CTAGS
1842static int total_size_of_entries __P((node *)); 1846static int total_size_of_entries __P((node *));
1843static int number_len __P((long)); 1847static int number_len __P((long));
1844 1848
@@ -1878,7 +1882,6 @@ total_size_of_entries (np)
1878 1882
1879 return total; 1883 return total;
1880} 1884}
1881#endif
1882 1885
1883static void 1886static void
1884put_entries (np) 1887put_entries (np)
@@ -1895,7 +1898,7 @@ put_entries (np)
1895 put_entries (np->left); 1898 put_entries (np->left);
1896 1899
1897 /* Output this entry */ 1900 /* Output this entry */
1898#if !CTAGS 1901 if (!CTAGS)
1899 { 1902 {
1900 /* Etags mode */ 1903 /* Etags mode */
1901 if (file != np->file 1904 if (file != np->file
@@ -1918,7 +1921,7 @@ put_entries (np)
1918 else 1921 else
1919 fprintf (tagf, "%ld\n", np->cno); 1922 fprintf (tagf, "%ld\n", np->cno);
1920 } 1923 }
1921#else 1924 else
1922 { 1925 {
1923 /* Ctags mode */ 1926 /* Ctags mode */
1924 if (np->name == NULL) 1927 if (np->name == NULL)
@@ -1957,7 +1960,7 @@ put_entries (np)
1957 putc ('\n', tagf); 1960 putc ('\n', tagf);
1958 } 1961 }
1959 } 1962 }
1960#endif 1963
1961 1964
1962 /* Output subentries that follow this one */ 1965 /* Output subentries that follow this one */
1963 put_entries (np->right); 1966 put_entries (np->right);
@@ -4056,8 +4059,9 @@ Perl_functions (inf)
4056 4059
4057/* 4060/*
4058 * Python support 4061 * Python support
4059 * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/ 4062 * Look for /^[\t]*def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
4060 * Idea by Eric S. Raymond <esr@thyrsus.com> (1997) 4063 * Idea by Eric S. Raymond <esr@thyrsus.com> (1997)
4064 * More ideas by seb bacon <seb@jamkit.com> (2002)
4061 */ 4065 */
4062static void 4066static void
4063Python_functions (inf) 4067Python_functions (inf)
@@ -4066,13 +4070,17 @@ Python_functions (inf)
4066 register char *cp; 4070 register char *cp;
4067 4071
4068 LOOP_ON_INPUT_LINES (inf, lb, cp) 4072 LOOP_ON_INPUT_LINES (inf, lb, cp)
4069 if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class")) 4073 {
4070 { 4074 cp = skip_spaces (cp);
4071 while (!notinname (*cp) && *cp != ':') 4075 if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
4072 cp++; 4076 {
4073 pfnote (NULL, TRUE, 4077 char *name = cp;
4074 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4078 while (!notinname (*cp) && *cp != ':')
4075 } 4079 cp++;
4080 pfnote (savenstr (name, cp-name), TRUE,
4081 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4082 }
4083 }
4076} 4084}
4077 4085
4078 4086
@@ -4090,18 +4098,19 @@ static void
4090PHP_functions (inf) 4098PHP_functions (inf)
4091 FILE *inf; 4099 FILE *inf;
4092{ 4100{
4093 register char *cp; 4101 register char *cp, *name;
4094 bool search_identifier = FALSE; 4102 bool search_identifier = FALSE;
4095 4103
4096 LOOP_ON_INPUT_LINES (inf, lb, cp) 4104 LOOP_ON_INPUT_LINES (inf, lb, cp)
4097 { 4105 {
4098 cp = skip_spaces (cp); 4106 cp = skip_spaces (cp);
4107 name = cp;
4099 if (search_identifier 4108 if (search_identifier
4100 && *cp != '\0') 4109 && *cp != '\0')
4101 { 4110 {
4102 while (!notinname (*cp)) 4111 while (!notinname (*cp))
4103 cp++; 4112 cp++;
4104 pfnote (NULL, TRUE, 4113 pfnote (savenstr (name, cp-name), TRUE,
4105 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4114 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4106 search_identifier = FALSE; 4115 search_identifier = FALSE;
4107 } 4116 }
@@ -4111,9 +4120,10 @@ PHP_functions (inf)
4111 cp = skip_spaces (cp+1); 4120 cp = skip_spaces (cp+1);
4112 if(*cp != '\0') 4121 if(*cp != '\0')
4113 { 4122 {
4123 name = cp;
4114 while (!notinname (*cp)) 4124 while (!notinname (*cp))
4115 cp++; 4125 cp++;
4116 pfnote (NULL, TRUE, 4126 pfnote (savenstr (name, cp-name), TRUE,
4117 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4127 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4118 } 4128 }
4119 else 4129 else
@@ -4123,9 +4133,10 @@ PHP_functions (inf)
4123 { 4133 {
4124 if (*cp != '\0') 4134 if (*cp != '\0')
4125 { 4135 {
4136 name = cp;
4126 while (*cp != '\0' && !iswhite (*cp)) 4137 while (*cp != '\0' && !iswhite (*cp))
4127 cp++; 4138 cp++;
4128 pfnote (NULL, FALSE, 4139 pfnote (savenstr (name, cp-name), FALSE,
4129 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4140 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4130 } 4141 }
4131 else 4142 else
@@ -4137,18 +4148,20 @@ PHP_functions (inf)
4137 && (*cp == '"' || *cp == '\'')) 4148 && (*cp == '"' || *cp == '\''))
4138 { 4149 {
4139 char quote = *cp++; 4150 char quote = *cp++;
4151 name = cp;
4140 while (*cp != quote && *cp != '\0') 4152 while (*cp != quote && *cp != '\0')
4141 cp++; 4153 cp++;
4142 pfnote (NULL, FALSE, 4154 pfnote (savenstr (name, cp-name), FALSE,
4143 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4155 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4144 } 4156 }
4145 else if (members 4157 else if (members
4146 && LOOKING_AT (cp, "var") 4158 && LOOKING_AT (cp, "var")
4147 && *cp == '$') 4159 && *cp == '$')
4148 { 4160 {
4161 name = cp;
4149 while (!notinname(*cp)) 4162 while (!notinname(*cp))
4150 cp++; 4163 cp++;
4151 pfnote (NULL, FALSE, 4164 pfnote (savenstr (name, cp-name), FALSE,
4152 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4165 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4153 } 4166 }
4154 } 4167 }
@@ -4574,13 +4587,16 @@ TeX_commands (inf)
4574 i = TEX_Token (lasthit); 4587 i = TEX_Token (lasthit);
4575 if (i >= 0) 4588 if (i >= 0)
4576 { 4589 {
4577 /* We seem to include the TeX command in the tag name.
4578 register char *p; 4590 register char *p;
4579 for (p = lasthit + TEX_toktab[i].len; 4591 for (lasthit += TEX_toktab[i].len;
4580 *p != '\0' && *p != TEX_clgrp; 4592 *lasthit == TEX_esc || *lasthit == TEX_opgrp;
4593 lasthit++)
4594 continue;
4595 for (p = lasthit;
4596 !iswhite (*p) && *p != TEX_opgrp && *p != TEX_clgrp;
4581 p++) 4597 p++)
4582 continue; */ 4598 continue;
4583 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE, 4599 pfnote (savenstr (lasthit, p-lasthit), TRUE,
4584 lb.buffer, lb.len, lineno, linecharno); 4600 lb.buffer, lb.len, lineno, linecharno);
4585 break; /* We only tag a line once */ 4601 break; /* We only tag a line once */
4586 } 4602 }
@@ -5427,6 +5443,7 @@ readline (lbp, stream)
5427 /* Read new line. */ 5443 /* Read new line. */
5428 long result = readline_internal (lbp, stream); 5444 long result = readline_internal (lbp, stream);
5429 5445
5446 /* Honour #line directives. */
5430 if (!no_line_directive 5447 if (!no_line_directive
5431 && result > 12 && strneq (lbp->buffer, "#line ", 6)) 5448 && result > 12 && strneq (lbp->buffer, "#line ", 6))
5432 { 5449 {
@@ -5441,16 +5458,31 @@ readline (lbp, stream)
5441 endp++; 5458 endp++;
5442 if (endp != NULL) 5459 if (endp != NULL)
5443 { 5460 {
5444 int len = endp - (lbp->buffer + start); 5461 char *absname, *name = lbp->buffer + start;
5462 *endp = '\0';
5463
5464 canonicalize_filename(name); /* for DOS */
5465 absname = absolute_filename (name, curfiledir);
5466 if (filename_is_absolute (name)
5467 || filename_is_absolute (curfile))
5468 name = absname;
5469 else
5470 {
5471 name = relative_filename (absname, tagfiledir);
5472 free (absname);
5473 }
5445 5474
5446 if (!strneq (curfile, lbp->buffer + start, len)) 5475 if (streq (curtagfname, name))
5447 curfile = savenstr (lbp->buffer + start, len); 5476 free (name);
5477 else
5478 curtagfname = name;
5448 lineno = lno; 5479 lineno = lno;
5449 nocharno = TRUE; /* do not use char position for tags */ 5480 nocharno = TRUE; /* do not use char position for tags */
5450 return readline (lbp, stream); 5481 return readline (lbp, stream);
5451 } 5482 }
5452 } 5483 }
5453 } 5484 }
5485
5454#ifdef ETAGS_REGEXPS 5486#ifdef ETAGS_REGEXPS
5455 { 5487 {
5456 int match; 5488 int match;