The word "function" embedded in a string results in a function tag, which results in especially ugly tags if one checks with type() if a given variable contains a function -- I attach a simple patch to address this case alone, alas I don't have the time to change the parser to consider if the occurence of function in question is inside a string.
The code in question:
if(type(dispatch[cmd]) == "function") then
[...]
end
will result in a function-tag "if(type(dispatch[cmd]))".
The Patch:
---------- snip %< ----------------
--- ctags-5.6/lua.c 2006-05-30 06:37:12.000000000 +0200
+++ ctags-5.6.new/lua.c 2007-07-02 15:14:41.000000000 +0200
@@ -104,7 +104,8 @@
p = (const char*) strstr ((const char*) line, "function");
if (p == NULL)
continue;
-
+ if ((const unsigned char*)p > line && *(p-1) == '"' && *(p+8) == '"') /* skip "function" as used */
+ continue; /* in type() checks */
q = strchr ((const char*) line, '=');
if (q == NULL) {
---------- snip %< ----------------
kind regards,
Tom
Logged In: YES
user_id=2091512
Originator: NO
Hello,
Just to confirm this bug and patch submitted by Tom.
When parsing a lua file to find the functions, the string "function" fools the parser, as in the following example (reduced indenting to make it fit this e-mail form). "function" string is not a keyword!
Ctags correctly identifies 'Group:new' as a function, but also says that 'if (type(arg[i].setGroup)' is a function, presumably because of the "function" string on that same line.
function Group:new(...)
local i = 1;
self.n = 0;
-- Remove invalid elements?
for i=1,arg.n do
if (type(arg[i].setGroup) == "function") then
arg[i]:setGroup(self);
end
end
-- Increment group number (the class member)
Group.number = Group.number + 1;
end
With non-patched version of Ctags (see version output below):
Exuberant Ctags 5.7, Copyright (C) 1996-2007 Darren Hiebert
Compiled: Sep 4 2007, 23:24:26
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +win32, +regex, +internal-sort
The output of Ctags on the above code:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.7 //
Group:new ctags.lua /^function Group:new(...) $/;" f
if (type(arg[i].setGroup) ctags.lua /^ if (type(arg[i].setGroup) == "function") then$/;" f
After compiling with Tom's patch the output of Ctags is:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;"
to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.7 //
Group:new h:\development\fea\femm\lua\ctags.lua /^function Group:new(...
) $/;" f
HTH.
Steve
May be fixed in 5606f3f711afeac74587a249650a5f7b416f19be in universal ctags(https://ctags.io). The fix is imported from geany.