From 7353b32d77b6ebab0de5a251d07911b99f70b4c9 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 18 Dec 2012 09:35:21 +0000 Subject: [PATCH] perl: add -Tc to makeprg if the shebang contains -T If the shebang contains -T, then the makeprg looks like: perl '/path/to/efm_perl.pl' -c -w '/tmp/foo.pl' -Tc Mods to syntastic#util#ParseMagicNumber * rename it to ParseShebang (since this name seems more common) * return an empty result set rather than 0 so callers dont have to check if empty() --- autoload/syntastic/util.vim | 4 +++- syntax_checkers/perl.vim | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index e97b4169..e570484c 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -23,7 +23,7 @@ endfunction "returns " "{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']} -function! syntastic#util#ParseMagicNumber() +function! syntastic#util#ParseShebang() for lnum in range(1,5) let line = getline(lnum) @@ -33,6 +33,8 @@ function! syntastic#util#ParseMagicNumber() return {'exe': exe, 'args': args} endif endfor + + return {'exe': '', 'args': []} endfunction let &cpo = s:save_cpo diff --git a/syntax_checkers/perl.vim b/syntax_checkers/perl.vim index 27326d55..b1baa333 100644 --- a/syntax_checkers/perl.vim +++ b/syntax_checkers/perl.vim @@ -40,7 +40,18 @@ function! SyntaxCheckers_perl_GetLocList() else let makeprg = g:syntastic_perl_efm_program . ' ' . shellescape(expand('%')) endif + let makeprg .= s:ExtraMakeprgArgs() + let errorformat = '%t:%f:%l:%m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction + +function! s:ExtraMakeprgArgs() + let shebang = syntastic#util#ParseShebang() + if index(shebang['args'], '-T') != -1 + return ' -Tc' + endif + + return '' +endfunction