Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Sat, 14 Oct 2023 09:25:37 UTC Commit: 20c39c858bc7a4bd6f3d062df4de3484b979fd1f https://github.com/geany/geany/commit/20c39c858bc7a4bd6f3d062df4de3484b979fd...
Log Message: ----------- Merge pull request #3358 from cousteaulecommandant/matlab-ctag-bug
ctags: Matlab: generate tag with only the function name, not the function name plus arguments
Modified Paths: -------------- ctags/parsers/geany_matlab.c tests/ctags/matlab_backtracking.m.tags tests/ctags/matlab_test.m tests/ctags/matlab_test.m.tags
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;
Modified: tests/ctags/matlab_backtracking.m.tags 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -1,2 +1,2 @@ -backtrack(xc,d,fc,fnc,DDfnc,c,gamma,eps)�16�0 -function: backtrack(xc,d,fc,fnc,DDfnc,c,gamma,eps) +backtrack�16�0 +function: backtrack
Modified: tests/ctags/matlab_test.m 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -1,4 +1,7 @@ function [x,y,z] = func1 function x = func2 function func3 +function y = func4(a, b, c) +function func5 % this comment should be ignored --> X = FAIL5 +functionality = FAIL6; % this is not a function and should not be parsed
Modified: tests/ctags/matlab_test.m.tags 16 lines changed, 10 insertions(+), 6 deletions(-) =================================================================== @@ -1,6 +1,10 @@ -func1 �16�0 -function: func1 -func2 �16�0 -function: func2 -func3 �16�0 -function: func3 +func1�16�0 +function: func1 +func2�16�0 +function: func2 +func3�16�0 +function: func3 +func4�16�0 +function: func4 +func5�16�0 +function: func5
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).