diff options
author | David Hull <david.hull@openx.com> | 2019-06-25 19:12:22 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-25 19:14:20 +0200 |
commit | f0151e17d296bfdeb1ca3f002c9b430c8302a6e7 (patch) | |
tree | a3b1d497fb7f353b70dd78ae3fee027b2452b9e6 /lib-src | |
parent | a8457f0adadacbb0360d84b0ed6d59a34c56d58c (diff) | |
download | emacs-f0151e17d296bfdeb1ca3f002c9b430c8302a6e7.tar.gz |
etags: Fix handling of quoted symbol names in Erlang
* lib-src/etags.c (erlang_attribute): Fix handling of quoted
symbol names in Erlang (bug#24960).
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/etags.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index f70a1f67bc8..442b622cceb 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -6043,7 +6043,7 @@ prolog_atom (char *s, size_t pos) * Assumes that Erlang functions start at column 0. * Original code by Anders Lindgren (1996) */ -static int erlang_func (char *, char *); +static int erlang_func (char *, char *, int *); static void erlang_attribute (char *); static int erlang_atom (char *); @@ -6053,6 +6053,7 @@ Erlang_functions (FILE *inf) char *cp, *last; int len; int allocated; + int name_offset = 0; allocated = 0; len = 0; @@ -6077,7 +6078,7 @@ Erlang_functions (FILE *inf) last = NULL; } } - else if ((len = erlang_func (cp, last)) > 0) + else if ((len = erlang_func (cp, last, &name_offset)) > 0) { /* * Function. Store the function name so that we only @@ -6088,7 +6089,7 @@ Erlang_functions (FILE *inf) else if (len + 1 > allocated) xrnew (last, len + 1, char); allocated = len + 1; - memcpy (last, cp, len); + memcpy (last, cp + name_offset, len); last[len] = '\0'; } } @@ -6107,12 +6108,13 @@ Erlang_functions (FILE *inf) * was found. */ static int -erlang_func (char *s, char *last) +erlang_func (char *s, char *last, int *name_offset) /* Name of last clause. */ { int pos; int len; + char *name = s; pos = erlang_atom (s); if (pos < 1) @@ -6121,13 +6123,23 @@ erlang_func (char *s, char *last) len = pos; pos = skip_spaces (s + pos) - s; + /* If the name is quoted, the quotes are not part of the name. */ + if (len > 2 && name[0] == '\'' && name[len - 1] == '\'') + { + *name_offset = 1; + name++; + len -= 2; + } + else + *name_offset = 0; + /* Save only the first clause. */ if (s[pos++] == '(' && (last == NULL || len != (int)strlen (last) - || !strneq (s, last, len))) + || !strneq (name, last, len))) { - make_tag (s, len, true, s, pos, lineno, linecharno); + make_tag (name, len, true, s, pos, lineno, linecharno); return len; } @@ -6148,13 +6160,25 @@ static void erlang_attribute (char *s) { char *cp = s; + int pos; + int len; if ((LOOKING_AT (cp, "-define") || LOOKING_AT (cp, "-record")) && *cp++ == '(') { - int len = erlang_atom (skip_spaces (cp)); + cp = skip_spaces (cp); + len = erlang_atom (cp); + pos = cp + len - s; if (len > 0) - make_tag (cp, len, true, s, cp + len - s, lineno, linecharno); + { + /* If the name is quoted, the quotes are not part of the name. */ + if (len > 2 && cp[0] == '\'' && cp[len - 1] == '\'') + { + cp++; + len -= 2; + } + make_tag (cp, len, true, s, pos, lineno, linecharno); + } } return; } |