BaseX: allow filenames to contain special characters.

Bug fix: proper escaping of special characters in filenames.

Workaround for a bug in Vim: errorformat's "%f" doesn't properly detect
filenames if they are not delimited by characters that are illegal in
filenames, such as ":".  Solution: switch to a preprocess function.

References: http://docs.basex.org/wiki/Commands#Valid_Names
This commit is contained in:
LCD 47 2015-10-26 10:07:29 +02:00
parent 2553f63893
commit e484ac9416
3 changed files with 28 additions and 6 deletions

View File

@ -8,6 +8,28 @@ set cpo&vim
" Public functions {{{1 " Public functions {{{1
function! syntastic#preprocess#basex(errors) abort " {{{2a
let out = []
let idx = 0
while idx < len(a:errors)
let parts = matchlist(a:errors[idx], '\v^\[\S+\] Stopped at (.+), (\d+)/(\d+):')
if len(parts) > 3
let err = parts[1] . ':' . parts[2] . ':' . parts[3] . ':'
let parts = matchlist(a:errors[idx+1], '\v^\[(.)\D+(\d+)\] (.+)')
if len(parts) > 3
let err .= (parts[1] ==? 'W' || parts[1] ==? 'E' ? parts[1] : 'E') . ':' . parts[2] . ':' . parts[3]
call add(out, err)
let idx +=1
endif
elseif a:errors[idx] =~# '\m^\['
" unparseable errors
call add(out, a:errors[idx])
endif
let idx +=1
endwhile
return out
endfunction " }}}2
function! syntastic#preprocess#cabal(errors) abort " {{{2 function! syntastic#preprocess#cabal(errors) abort " {{{2
let out = [] let out = []
let star = 0 let star = 0

View File

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

View File

@ -20,17 +20,17 @@ set cpo&vim
function! SyntaxCheckers_xquery_basex_GetLocList() dict function! SyntaxCheckers_xquery_basex_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'args_after': '-z', \ 'args_after': '-z',
\ 'fname': ['-q', "inspect:module('" . expand('%:p', 1) . "')"] }) \ 'fname_before': '-q',
\ 'fname': syntastic#util#shescape('inspect:module("' . escape(expand('%:p', 1), '"') . '")') })
let errorformat = let errorformat =
\ '%-GStopped at %\%.\, %l/%c:,'. \ '%f:%l:%c:%t:%n:%m,' .
\ '%A[%.%#] Stopped at %f\, %l/%c:,'. \ '%m'
\ '%Z[%t%\D%#%n] %m'
let loclist = SyntasticMake({ let loclist = SyntasticMake({
\ 'makeprg': makeprg, \ 'makeprg': makeprg,
\ 'errorformat': errorformat, \ 'errorformat': errorformat,
\ 'postprocess': ['compressWhitespace'] }) \ 'preprocess': 'basex' })
for e in loclist for e in loclist
if e['type'] !=# 'W' && e['type'] !=# 'E' if e['type'] !=# 'W' && e['type'] !=# 'E'