Safety net: avoid suffixesadd interfering with findfile().

This commit is contained in:
LCD 47 2015-06-26 07:28:50 +03:00
parent 176e32ca4d
commit 31cba018b3
9 changed files with 23 additions and 15 deletions

View File

@ -21,7 +21,7 @@ function! syntastic#c#ReadConfig(file) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: looking for', a:file)
" search upwards from the current file's directory
let config = findfile(a:file, escape(expand('%:p:h', 1), ' ') . ';')
let config = syntastic#util#findFileInParent(a:file, expand('%:p:h', 1))
if config ==# ''
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: file not found')
return ''

View File

@ -227,10 +227,18 @@ function! syntastic#util#bufIsActive(buffer) abort " {{{2
endfunction " }}}2
" start in directory a:where and walk up the parent folders until it finds a
" file matching a:what; return path to that file; do NOT use this function if
" a:what doesn't contain wildcards, use findfile(a:what, escape(a:where, ' ') . ';')
" instead
function! syntastic#util#findInParent(what, where) abort " {{{2
" file named a:what; return path to that file
function! syntastic#util#findFileInParent(what, where) abort " {{{2
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let file = findfile(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return file
endfunction " }}}2
" start in directory a:where and walk up the parent folders until it finds a
" file matching a:what; return path to that file
function! syntastic#util#findGlobInParent(what, where) abort " {{{2
let here = fnamemodify(a:where, ':p')
let root = syntastic#util#Slash()

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.6.0-109'
let g:_SYNTASTIC_VERSION = '3.6.0-110'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1

View File

@ -23,7 +23,7 @@ if !exists('g:syntastic_pc_lint_config_file')
endif
function! SyntaxCheckers_c_pc_lint_GetLocList() dict
let config = findfile(g:syntastic_pc_lint_config_file, escape(expand('%:p:h', 1), ' ') . ';')
let config = syntastic#util#findFileInParent(g:syntastic_pc_lint_config_file, expand('%:p:h', 1))
call self.log('config =', config)
" -hFs1 - show filename, add space after messages, try to make message 1 line

View File

@ -35,7 +35,7 @@ function! SyntaxCheckers_elixir_elixir_GetLocList() dict
let make_options = {}
let compile_command = 'elixir'
let mix_file = findfile('mix.exs', escape(expand('%:p:h', 1), ' ') . ';')
let mix_file = syntastic#util#findFileInParent('mix.exs', expand('%:p:h', 1))
if filereadable(mix_file)
let compile_command = 'mix compile'

View File

@ -24,7 +24,7 @@ function! SyntaxCheckers_haxe_haxe_GetLocList() dict
elseif exists('g:vaxe_hxml')
let hxml = g:vaxe_hxml
else
let hxml = syntastic#util#findInParent('*.hxml', expand('%:p:h', 1))
let hxml = syntastic#util#findGlobInParent('*.hxml', expand('%:p:h', 1))
endif
let hxml = fnamemodify(hxml, ':p')

View File

@ -315,7 +315,7 @@ endfunction " }}}2
function! s:GetMavenProperties() " {{{2
let mvn_properties = {}
let pom = findfile('pom.xml', escape(expand('%:p:h', 1), ' ') . ';')
let pom = syntastic#util#findFileInParent('pom.xml', expand('%:p:h', 1))
if s:has_maven && filereadable(pom)
if !has_key(g:syntastic_java_javac_maven_pom_properties, pom)
let mvn_cmd = syntastic#util#shexpand(g:syntastic_java_maven_executable) .
@ -350,7 +350,7 @@ function! s:GetMavenProperties() " {{{2
endfunction " }}}2
function! s:GetMavenClasspath() " {{{2
let pom = findfile('pom.xml', escape(expand('%:p:h', 1), ' ') . ';')
let pom = syntastic#util#findFileInParent('pom.xml', expand('%:p:h', 1))
if s:has_maven && filereadable(pom)
if !has_key(g:syntastic_java_javac_maven_pom_ftime, pom) || g:syntastic_java_javac_maven_pom_ftime[pom] != getftime(pom)
let mvn_cmd = syntastic#util#shexpand(g:syntastic_java_maven_executable) .
@ -394,7 +394,7 @@ function! s:GetMavenClasspath() " {{{2
endfunction " }}}2
function! s:MavenOutputDirectory() " {{{2
let pom = findfile('pom.xml', escape(expand('%:p:h', 1), ' ') . ';')
let pom = syntastic#util#findFileInParent('pom.xml', expand('%:p:h', 1))
if s:has_maven && filereadable(pom)
let mvn_properties = s:GetMavenProperties()
let output_dir = getcwd()

View File

@ -29,7 +29,7 @@ function! SyntaxCheckers_javascript_flow_IsAvailable() dict
endfunction
function! SyntaxCheckers_javascript_flow_GetLocList() dict
if findfile('.flowconfig', escape(expand('%:p:h', 1), ' ') . ';') ==# ''
if syntastic#util#findFileInParent('.flowconfig', expand('%:p:h', 1)) ==# ''
return []
endif

View File

@ -30,7 +30,7 @@ function! SyntaxCheckers_rst_sphinx_GetLocList() dict
let srcdir = syntastic#util#var('rst_sphinx_source_dir')
call self.log('g:syntastic_rst_sphinx_source_dir =', srcdir)
if srcdir == ''
let config = findfile('conf.py', escape(expand('%:p:h', 1), ' ') . ';')
let config = syntastic#util#findFileInParent('conf.py', expand('%:p:h', 1))
if config == '' || !filereadable(config)
call self.log('conf.py file not found')
return []
@ -41,7 +41,7 @@ function! SyntaxCheckers_rst_sphinx_GetLocList() dict
let confdir = syntastic#util#var('rst_sphinx_config_dir')
call self.log('g:syntastic_rst_sphinx_config_dir =', confdir)
if confdir == ''
let config = findfile('conf.py', escape(expand('%:p:h', 1), ' ') . ';')
let config = syntastic#util#findFileInParent('conf.py', expand('%:p:h', 1))
let confdir = (config != '' && filereadable(config)) ? fnamemodify(config, ':p:h') : srcdir
endif