aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì2002-06-13 17:53:35 +0000
committerFrancesco Potortì2002-06-13 17:53:35 +0000
commit89fb2be16c4796e4e05dac2405a8f1705b9b69c6 (patch)
tree59240188e13984171836b54a0fb7c33c42300d6c /lib-src
parent82ef78b31dc7a66cb82537b5ff4a4a29b402aefa (diff)
downloademacs-89fb2be16c4796e4e05dac2405a8f1705b9b69c6.tar.gz
emacs-89fb2be16c4796e4e05dac2405a8f1705b9b69c6.zip
* etags.c (erlang_atom, erlang_attribute): Bugs corrected.
(invalidate_nodes): Bug corrected. (print_help): Better help for regexps.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c104
1 files changed, 38 insertions, 66 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index be60b476972..5f46013153b 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -34,7 +34,7 @@
34 * Francesco Potortì <pot@gnu.org> has maintained it since 1993. 34 * Francesco Potortì <pot@gnu.org> has maintained it since 1993.
35 */ 35 */
36 36
37char pot_etags_version[] = "@(#) pot revision number is 16.19"; 37char pot_etags_version[] = "@(#) pot revision number is 16.26";
38 38
39#define TRUE 1 39#define TRUE 1
40#define FALSE 0 40#define FALSE 0
@@ -766,18 +766,18 @@ Relative ones are stored relative to the output file's directory.\n");
766 Create tag entries for member variables in C and derived languages."); 766 Create tag entries for member variables in C and derived languages.");
767 767
768#ifdef ETAGS_REGEXPS 768#ifdef ETAGS_REGEXPS
769 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\ 769 puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\
770 Make a tag for each line matching pattern REGEXP in the following\n\ 770 Make a tag for each line matching the regular expression pattern\n\
771 files. {LANGUAGE}/REGEXP/ uses REGEXP for LANGUAGE files only.\n\ 771 in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\
772 regexfile is a file containing one REGEXP per line.\n\ 772 files only. REGEXFILE is a file containing one REGEXP per line.\n\
773 REGEXP is anchored (as if preceded by ^).\n\ 773 REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\
774 The form /REGEXP/NAME/ creates a named tag.\n\ 774 optional. The TAGREGEXP pattern is anchored (as if preceded by ^).");
775 puts (" If TAGNAME/ is present, the tags created are named.\n\
775 For example Tcl named tags can be created with:\n\ 776 For example Tcl named tags can be created with:\n\
776 --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\"."); 777 --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\".\n\
777 puts ("In the form /REGEXP/MODS or /REGEXP/NAME/MODS, MODS are\n\ 778 MODS are optional one-letter modifiers: `i' means to ignore case,\n\
778 one-letter modifiers: `i' means to ignore case, `m' means\n\ 779 `m' means to allow multi-line matches, `s' implies `m' and\n\
779 allow multi-line matches, `s' implies `m' and additionally\n\ 780 causes dot to match the newline character as well.");
780 causes dot to match the newline character.");
781 puts ("-R, --no-regex\n\ 781 puts ("-R, --no-regex\n\
782 Don't create tags from regexps for the following files."); 782 Don't create tags from regexps for the following files.");
783#endif /* ETAGS_REGEXPS */ 783#endif /* ETAGS_REGEXPS */
@@ -1227,7 +1227,7 @@ main (argc, argv)
1227 1227
1228 if (!CTAGS || cxref_style) 1228 if (!CTAGS || cxref_style)
1229 { 1229 {
1230 put_entries (nodehead); 1230 put_entries (nodehead); /* write the remainig tags (ETAGS) */
1231 free_tree (nodehead); 1231 free_tree (nodehead);
1232 nodehead = NULL; 1232 nodehead = NULL;
1233 if (!CTAGS) 1233 if (!CTAGS)
@@ -1264,7 +1264,7 @@ main (argc, argv)
1264 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w"); 1264 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
1265 if (tagf == NULL) 1265 if (tagf == NULL)
1266 pfatal (tagfile); 1266 pfatal (tagfile);
1267 put_entries (nodehead); 1267 put_entries (nodehead); /* write all the tags (CTAGS) */
1268 free_tree (nodehead); 1268 free_tree (nodehead);
1269 nodehead = NULL; 1269 nodehead = NULL;
1270 if (fclose (tagf) == EOF) 1270 if (fclose (tagf) == EOF)
@@ -2012,11 +2012,6 @@ add_node (np, cur_node_p)
2012 * invalidate_nodes () 2012 * invalidate_nodes ()
2013 * Scan the node tree and invalidate all nodes pointing to the 2013 * Scan the node tree and invalidate all nodes pointing to the
2014 * given file description (CTAGS case) or free them (ETAGS case). 2014 * given file description (CTAGS case) or free them (ETAGS case).
2015 *
2016 * This function most likely contains a bug, but I cannot tell where.
2017 * I have a case of a binary that crashes inside this function with a bus
2018 * error. Unfortunately, the binary does not contain debug information, and
2019 * compiling with debugging information makes the bug disappear.
2020 */ 2015 */
2021static void 2016static void
2022invalidate_nodes (badfdp, npp) 2017invalidate_nodes (badfdp, npp)
@@ -2039,14 +2034,16 @@ invalidate_nodes (badfdp, npp)
2039 } 2034 }
2040 else 2035 else
2041 { 2036 {
2042 node **next = &np->left; 2037 assert (np->fdp != NULL);
2043 if (np->fdp == badfdp) 2038 if (np->fdp == badfdp)
2044 { 2039 {
2045 *npp = *next; /* detach the sublist from the list */ 2040 *npp = np->left; /* detach the sublist from the list */
2046 np->left = NULL; /* isolate it */ 2041 np->left = NULL; /* isolate it */
2047 free_tree (np); /* free it */ 2042 free_tree (np); /* free it */
2043 invalidate_nodes (badfdp, npp);
2048 } 2044 }
2049 invalidate_nodes (badfdp, next); 2045 else
2046 invalidate_nodes (badfdp, &np->left);
2050 } 2047 }
2051} 2048}
2052 2049
@@ -5095,7 +5092,7 @@ prolog_atom (s, pos)
5095 */ 5092 */
5096static int erlang_func __P((char *, char *)); 5093static int erlang_func __P((char *, char *));
5097static void erlang_attribute __P((char *)); 5094static void erlang_attribute __P((char *));
5098static int erlang_atom __P((char *, int)); 5095static int erlang_atom __P((char *));
5099 5096
5100static void 5097static void
5101Erlang_functions (inf) 5098Erlang_functions (inf)
@@ -5160,7 +5157,7 @@ erlang_func (s, last)
5160 int pos; 5157 int pos;
5161 int len; 5158 int len;
5162 5159
5163 pos = erlang_atom (s, 0); 5160 pos = erlang_atom (s);
5164 if (pos < 1) 5161 if (pos < 1)
5165 return 0; 5162 return 0;
5166 5163
@@ -5194,19 +5191,15 @@ static void
5194erlang_attribute (s) 5191erlang_attribute (s)
5195 char *s; 5192 char *s;
5196{ 5193{
5197 int pos; 5194 char *cp = s;
5198 int len;
5199 5195
5200 if (LOOKING_AT (s, "-define") || LOOKING_AT (s, "-record")) 5196 if ((LOOKING_AT (cp, "-define") || LOOKING_AT (cp, "-record"))
5197 && *cp++ == '(')
5201 { 5198 {
5202 if (s[pos++] == '(') 5199 int len = erlang_atom (skip_spaces (cp));
5203 { 5200 if (len > 0)
5204 pos = skip_spaces (s + pos) - s; 5201 pfnote (savenstr (cp, len), TRUE,
5205 len = erlang_atom (s, pos); 5202 s, cp + len - s, lineno, linecharno);
5206 if (len != 0)
5207 pfnote (savenstr (& s[pos], len), TRUE,
5208 s, pos + len, lineno, linecharno);
5209 }
5210 } 5203 }
5211 return; 5204 return;
5212} 5205}
@@ -5217,49 +5210,28 @@ erlang_attribute (s)
5217 * Return the number of bytes consumed, or -1 if there was an error. 5210 * Return the number of bytes consumed, or -1 if there was an error.
5218 */ 5211 */
5219static int 5212static int
5220erlang_atom (s, pos) 5213erlang_atom (s)
5221 char *s; 5214 char *s;
5222 int pos;
5223{ 5215{
5224 int origpos; 5216 int pos = 0;
5225
5226 origpos = pos;
5227 5217
5228 if (ISALPHA (s[pos]) || s[pos] == '_') 5218 if (ISALPHA (s[pos]) || s[pos] == '_')
5229 { 5219 {
5230 /* The atom is unquoted. */ 5220 /* The atom is unquoted. */
5231 pos++; 5221 do
5232 while (ISALNUM (s[pos]) || s[pos] == '_')
5233 pos++; 5222 pos++;
5234 return pos - origpos; 5223 while (ISALNUM (s[pos]) || s[pos] == '_');
5235 } 5224 }
5236 else if (s[pos] == '\'') 5225 else if (s[pos] == '\'')
5237 { 5226 {
5227 for (pos++; s[pos] != '\''; pos++)
5228 if (s[pos] == '\0' /* multiline quoted atoms are ignored */
5229 || (s[pos] == '\\' && s[++pos] == '\0'))
5230 return 0;
5238 pos++; 5231 pos++;
5239
5240 for (;;)
5241 {
5242 if (s[pos] == '\'')
5243 {
5244 pos++;
5245 break;
5246 }
5247 else if (s[pos] == '\0')
5248 /* Multiline quoted atoms are ignored. */
5249 return -1;
5250 else if (s[pos] == '\\')
5251 {
5252 if (s[pos+1] == '\0')
5253 return -1;
5254 pos += 2;
5255 }
5256 else
5257 pos++;
5258 }
5259 return pos - origpos;
5260 } 5232 }
5261 else 5233
5262 return -1; 5234 return pos;
5263} 5235}
5264 5236
5265 5237