Allow makeprgBuild() arguments to be lists.

String arguments to makeprgBuild() are used unchanged.  Lists, both
inside checkers and in user variables, have their elements run through
syntastic#util#shescape() first.  This solves an otherwise untractable
escaping problem.
This commit is contained in:
LCD 47 2014-02-02 12:20:47 +02:00
parent 1220888334
commit 650ee9c309

View File

@ -74,13 +74,14 @@ endfunction
function! g:SyntasticChecker.makeprgBuild(opts) function! g:SyntasticChecker.makeprgBuild(opts)
let setting = 'g:syntastic_' . self._filetype . '_' . self._name . '_' let setting = 'g:syntastic_' . self._filetype . '_' . self._name . '_'
let parts = self._getOpt(a:opts, setting, 'exe', self.getExec()) let parts = []
call extend(parts, self._getOpt(a:opts, setting, 'exe', self.getExec()))
call extend(parts, self._getOpt(a:opts, setting, 'args', '')) call extend(parts, self._getOpt(a:opts, setting, 'args', ''))
call extend(parts, self._getOpt(a:opts, setting, 'fname', syntastic#util#shexpand('%'))) call extend(parts, self._getOpt(a:opts, setting, 'fname', syntastic#util#shexpand('%')))
call extend(parts, self._getOpt(a:opts, setting, 'post_args', '')) call extend(parts, self._getOpt(a:opts, setting, 'post_args', ''))
call extend(parts, self._getOpt(a:opts, setting, 'tail', '')) call extend(parts, self._getOpt(a:opts, setting, 'tail', ''))
return join(filter(parts, 'v:val != ""')) return join(parts)
endfunction endfunction
function! g:SyntasticChecker.isAvailable() function! g:SyntasticChecker.isAvailable()
@ -111,19 +112,23 @@ function! g:SyntasticChecker._populateHighlightRegexes(errors)
endfunction endfunction
function! g:SyntasticChecker._getOpt(opts, setting, name, default) function! g:SyntasticChecker._getOpt(opts, setting, name, default)
return [ let sname = a:setting . a:name
\ get(a:opts, a:name . '_before', ''), let ret = []
\ self._getUserOpt(a:opts, a:setting, a:name, a:default), call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) )
\ get(a:opts, a:name . '_after', '') ] call extend( ret, self._shescape(exists(sname) ? {sname} : get(a:opts, a:name, a:default)) )
call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) )
return ret
endfunction endfunction
function! g:SyntasticChecker._getUserOpt(opts, setting, name, default) function! g:SyntasticChecker._shescape(opt)
let sname = a:setting . a:name if type(a:opt) == type('') && a:opt != ''
if exists(sname) return [a:opt]
return {sname} elseif type(a:opt) == type([])
return map(a:opt, 'syntastic#util#shescape(v:val)')
endif endif
return get(a:opts, a:name, a:default) return []
endfunction endfunction
" Non-method functions {{{1 " Non-method functions {{{1