Wednesday, October 27, 2010

Re: [PATCH] Protect read of g:Perl_PerlTags with exists()

Benjamin Haskell wrote:

> There's an unprotected check of one of the configuration variables.
> It's only triggered when you set ft=perl from .vimrc because the
> plugin hasn't been loaded yet.
>
> You shouldn't do that. Let the ftplugin system detect your files as
> Perl files, or if they have non-standard extensions (something other
> than .pl/.perl) set up an autocmd, e.g.:
>
> au BufNewFile,BufRead *.not-perl setf perl
>
> Patch below. BCC:'ed Dr. Fritz Mehner (maintainer)
>
> Pushed to http://github.com/benizi/perl-support.vim
>
> ================================================== commit message
>
> Most tests of global variables in conditionals have the form:
>
> if exists("g:variable") && g:variable == 'somevalue'
>
> This one didn't, and caused errors when unitialized.
> ---
> ftplugin/perl.vim | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/ftplugin/perl.vim b/ftplugin/perl.vim
> index e34accc..82f949d 100644
> --- a/ftplugin/perl.vim
> +++ b/ftplugin/perl.vim
> @@ -411,7 +411,7 @@ endif
> " Generate (possibly exuberant) Ctags style tags for Perl sourcecode.
> " Controlled by g:Perl_PerlTags, enabled by default.
> " ----------------------------------------------------------------------------
> -if has('perl') && g:Perl_PerlTags == 'enabled'
> +if has('perl') && ( exists("g:Perl_PerlTags") && g:Perl_PerlTags == 'enabled' )
> let g:Perl_PerlTagsTempfile = tempname()
> if getfsize( expand('%') ) > 0
> call Perl_do_tags( expand('%'), g:Perl_PerlTagsTempfile )

My ftplugin/perl.vim doesn't look anything like this. The header is:

" Vim filetype plugin file
" Language: Perl
" Maintainer: Andy Lester <andy@petdance.com>
" URL: http://github.com/petdance/vim-perl
" Last Change: 2009-08-14

--
Seen on the back of a biker's vest: If you can read this, my wife fell off.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: