NB: In the 'case 8' in isMap() constant '8' inside strncmp() must also be 'len' as in other cases.


2014/1/13 Alexey Radkov <alexey.radkov@gmail.com>
Hi David.

Today i encountered same issue again. (Infinite loop in ctags). This time the issue was due to presence of external code in viml. Here is content of abusing code:


python<<EOF
# We register openers with PandocRegisterExecutor.
# We take its first argument as the name of a vim ex command, the second
# argument as a mapping, and the rest as the description of a command,
# which we'll pass to pandoc_open.

# pandoc_register_executor(...) adds a tuple of those elements to a list of
#executors. This list will be # read from by ftplugin/pandoc.vim and commands
#and mappings will be created from it.
pandoc_executors = []

def pandoc_register_executor(com_ref):
ššš args = com_ref.split()
ššš name = args[0]
ššš mapping = args[1]
ššš type = args[2]
ššš command = args[3:]
ššš pandoc_executors.append((name, mapping, type, " ".join(command)))
EOF

command! -nargs=? PandocRegisterExecutor exec 'py pandoc_register_executor("<args>")'

" We register here some default executors. The user can define other custom
" commands in his .vimrc.
"
" Generate html and open in default html viewer
PandocRegisterExecutor PandocHtml <LocalLeader>html html pandoc -t html -Ss -o %:r.html %%
" Generate pdf w/ citeproc and open in default pdf viewer
PandocRegisterExecutor PandocPdf <LocalLeader>pdf pdf markdown2pdf PANDOC#P_BIBS -o %:r.pdf %%
" Generate odt w/ citeproc and open in default odt viewer
PandocRegisterExecutor PandocOdt <LocalLeader>odt odt pandoc -t odt PANDOC#P_BIBS -o %:r.odt %%



This was taken from vim pandoc plugin. Try to do

ctags -f - --format=2 --excmd=pattern --fields=nksSa --extra= --sort=yes --language-force=vim --vim-kinds=vfacm pandoc.vim

and you'll get infinite loop!

I attached a patch that will fix it: readVimLine() checks whether it is inside external code context and skips until the endmarker found. There is a new auxiliary function skipExternalCode() for that. I also reimplemented function isMap() as far as skipExternalCode() is very similar and i found that checks like

strncmp ((const char*) line, "nno",ššššš (size_t) 3) == 0 ||
strncmp ((const char*) line, "nnor",šššš (size_t) 4) == 0 ||
strncmp ((const char*) line, "nnore",ššš (size_t) 5) == 0 ||
strncmp ((const char*) line, "nnorem",šš (size_t) 6) == 0 ||
strncmp ((const char*) line, "nnorema",š (size_t) 7) == 0 ||
strncmp ((const char*) line, "nnoremap", (size_t) 8) == 0 ||

have little sense because if last condition triggers then all the previous must also trigger. Additionally the new version checks that the word is a lexem (i.e. is a complete word). I tested the patch on my large .vimrc and all worked fine.

Cheers, Alexey.




2012/6/20 Alexey Radkov <alexey.radkov@gmail.com>
Hi David.

Your change works really well:


./ctags -f - --format=2 --excmd=pattern --fields=nksSa --extra= --sort=yes --language-force=vim --vim-kinds=vfacm /home/lyokha/.vim/Align.vba

(no output, no delay)

./ctags -f - --format=2 --excmd=pattern --fields=nksSa --extra= --sort=yes --language-force=vim --vim-kinds=vfacmn /home/lyokha/.vim/Align.vba
autoload/Align.vimššš /home/lyokha/.vim/Align.vbaššš /^autoload\/Align.vimššš [[[1$/;"ššš nššš line:2432
autoload/AlignMaps.vimššš /home/lyokha/.vim/Align.vbaššš /^autoload\/AlignMaps.vimššš [[[1$/;"ššš nššš line:3562
doc/Align.txtššš /home/lyokha/.vim/Align.vbaššš /^doc\/Align.txtššš [[[1$/;"ššš nššš line:836
plugin/AlignMapsPlugin.vimššš /home/lyokha/.vim/Align.vbaššš /^plugin\/AlignMapsPlugin.vimššš [[[1$/;"ššš nššš line:47
plugin/AlignPlugin.vimššš /home/lyokha/.vim/Align.vbaššš /^plugin\/AlignPlugin.vimššš [[[1$/;"ššš nššš line:4
plugin/cecutil.vimššš /home/lyokha/.vim/Align.vbaššš /^plugin\/cecutil.vimššš [[[1$/;"ššš nššš line:298

(listed all files to be installed).

Probably author of tagbar would like to add the new option 'n' by default.

Thank you, Alexey.



2012/6/20 David Fishburn <dfishburn.vim@gmail.com>
Good Morning Alexey.

I have checked in a change for this.

Now, when .vba files (Vimball Archive) are used, they are parsed differently from .vim files.
I also added a new kind:
ššš { TRUE,š 'n', "filename", "vimball filename" },

So the full list is:
ššš Vim
ššššššš aš autocommand groups
ššššššš cš user-defined commands
ššššššš fš function definitions
ššššššš mš maps
ššššššš vš variable definitions
ššššššš nš vimball filename


If you use the taglist or tagbar plugins, then you will want to add the following to your vimrc, so these new kinds show up automatically.

let g:tlist_vim_settingsš = 'vim;p:Project;a:autocommand groups;c:user-defined commands;f:function definitions;m:maps;v:variable definitions;n:vimball filename'

let g:tagbar_type_vimš = {
ššššššššššš \ 'ctagstype' : 'vim',
ššššššššššš \ 'kinds'šššš : [
ššššššššššš \ 'p:Project',
ššššššššššš \ 'a:autocommand groups',
ššššššššššš \ 'c:user-defined commands',
ššššššššššš \ 'f:function definitions',
ššššššššššš \ 'm:maps',
ššššššššššš \ 'v:variable definitions',
ššššššššššš \ 'n:vimball filename'
ššššššššššš \ ]
ššššššššššš \ }


Opening the Align.vba file will now show the following tags:
vimball filename
ššš autoload/Align.vim
ššš autoload/AlignMaps.vim
ššš doc/Align.txt
ššš plugin/AlignMapsPlugin.vim
ššš plugin/AlignPlugin.vim
ššš plugin/cecutil.vim

Thanks for reporting the problem.

If you wouldn't mind verifying the fix and if you have suggested changes, feel free to mention them.
I will post this information to the Vim_use list in a couple of days.

Dave



On 19/06/2012 10:20 AM, Alexey Radkov wrote:
Hi David.

Here is the link (from official vim scripts page):

http://www.vim.org/scripts/download_script.php?src_id=18148

Downoad it, then unzip it and do the ctags command on it

Cheers, Alexey.


2012/6/19 David Fishburn <dfishburn.vim@gmail.com>
Thanks for the report Alexey.

Could you send me the Align.vba script and I will try it out.

Dave


On 19/06/2012 5:15 AM, Alexey Radkov wrote:
Hi.

Recently i tried to update latest Align.vba in vim and my vim hung.š I found that this was due to the autoopen feature of plugin tagbar during which following command takes place:

/usr/local/bin/ctags -f - --format=2 --excmd=pattern --fields=nksSa --extra= --sort=yes --language-force=vim --vim-kinds=vfacm /home/lyokha/.vim/Align.vba

I tried to issue it in command-line and it hung. The backtrace of the hung command is:

(gdb) bt
#0š 0x00000000004242a5 in parseCommand (line=<optimized out>, line@entry=0xbb6c13 "command (ie. they are left justified, too).") at vim.c:396
#1š 0x0000000000424f90 in parseVimLine (line=0xbb6c13 "command (ie. they are left justified, too).") at vim.c:584
#2š parseVimFile (line=<optimized out>) at vim.c:618
#3š findVimTags () at vim.c:633
#4š 0x000000000041aee7 in createTagsForFile (passCount=1, language=40, fileName=0x7fffbd832f22 "/home/lyokha/.vim/Align.vba") at parse.c:617
#5š createTagsWithFallback (language=40, fileName=0x7fffbd832f22 "/home/lyokha/.vim/Align.vba") at parse.c:639
#6š parseFile (fileName=fileName@entry=0x7fffbd832f22 "/home/lyokha/.vim/Align.vba") at parse.c:666
#7š 0x0000000000413f87 in createTagsForEntry (entryName=0x7fffbd832f22 "/home/lyokha/.vim/Align.vba") at main.c:303
#8š 0x00000000004024c0 in createTagsForArgs (args=0xb68120) at main.c:348
#9š makeTags (args=0xb68120) at main.c:494
#10 main (argc=<optimized out>, argv=<optimized out>) at main.c:562
(gdb) l
391ššš ššš š* Strip off any spaces and options which are part of the command.
392ššš ššš š* These should preceed the command name.
393ššš ššš š*/
394ššš ššš do
395ššš ššš {
396ššš ššš ššš if (isspace ((int) *cp))
397ššš ššš ššš {
398ššš ššš ššš ššš ++cp;
399ššš ššš ššš }
400ššš ššš ššš else if (*cp == '-')
(gdb)
401ššš ššš ššš {
402ššš ššš ššš ššš /*
403ššš ššš ššš ššš š* Read until the next space which separates options or the name
404ššš ššš ššš ššš š*/
405ššš ššš ššš ššš while (*cp && !isspace ((int) *cp))
406ššš ššš ššš ššš ššš ++cp;
407ššš ššš ššš }
408ššš ššš } while ( *cp &&š !isalnum ((int) *cp) );
409ššš
410ššš ššš if ( ! *cp )

Evidently it tries to parse line

"command (ie. they are left justified, too)."

in Align.vba source (the line is not correct vim command of course, but rather some comment or help), and ctags is unable to go over the do-loop with check forš !isalnum() (*cp is '(' here and the pointer never changes).

Btw current release version works fine with it, i suppose it changed after revision r762:

------------------------------------------------------------------------
r762 | dfishburn | 2010-07-28 15:38:19 +0400 (๓า., 28 ษภฬั 2010) | 9 lines

VIM Parser updates for bug 3032253.

Vim parser did not handle an invalid 'command' format and hung".
Now it handles and checks for these formats:
šš command.
šš command!.
šš comma!.
šš comma! ThisIsValid


Cheers, Alexey.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
Ctags-devel mailing list
Ctags-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctags-devel



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ctags-devel mailing list
Ctags-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctags-devel