Branch: refs/heads/master Author: Javier Mora cousteaulecommandant@gmail.com Committer: Javier Mora cousteaulecommandant@gmail.com Date: Wed, 04 Oct 2023 00:34:07 UTC Commit: 56afcc71d19fb6ed26441b6eaf5adddc620999d1 https://github.com/geany/geany/commit/56afcc71d19fb6ed26441b6eaf5adddc620999...
Log Message: ----------- ctags: Matlab: function name only, without args
A line like `function y = foo(a, b, c)` should yield a tag of `foo`, not `foo(a, b, c)`. That way, Ctrl-clicking `foo` somewhere in the code will take me there. The function name is `foo` after all, not `foo(a, b c)`.
Also, fixed issue where a line like `function foo() % this = bug` would yield a tag of `bug` instead of `foo` because the `=` in the comment was not ignored.
Modified Paths: -------------- ctags/parsers/geany_matlab.c
Modified: ctags/parsers/geany_matlab.c 17 lines changed, 10 insertions(+), 7 deletions(-) =================================================================== @@ -62,7 +62,8 @@ static void findMatlabTags (void) for (i = 0 ; line [i] != '\0' && ! isspace (line [i]) ; ++i) ;
- if (strncmp ((const char *) line, "function", (size_t) 8) == 0) + if (strncmp ((const char *) line, "function", (size_t) 8) == 0 + && isspace (line [8])) { const unsigned char *cp = line + i; const unsigned char *ptr = cp; @@ -71,9 +72,12 @@ static void findMatlabTags (void) while (isspace ((int) *cp)) ++cp;
- /* search for '=' character in the line */ + /* search for '=' character in the line (ignoring comments) */ while (*ptr != '\0') { + if (*ptr == '%') + break; + if (*ptr == '=') { eq=true; @@ -82,25 +86,24 @@ static void findMatlabTags (void) ptr++; }
- /* '=' was found => get the right most part of the line after '=' and before '%' */ + /* '=' was found => get the first word of the line after '=' */ if (eq) { ptr++; while (isspace ((int) *ptr)) ++ptr;
- while (*ptr != '\0' && *ptr != '%') + while (isalnum ((int) *ptr) || *ptr == '_') { vStringPut (name, (int) *ptr); ++ptr; } }
- /* '=' was not found => get the right most part of the line after - * 'function' and before '%' */ + /* '=' was not found => get the first word of the line after "function" */ else { - while (*cp != '\0' && *cp != '%') + while (isalnum ((int) *cp) || *cp == '_') { vStringPut (name, (int) *cp); ++cp;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).