if exists("g:loaded_syntastic_c_autoload") || !exists("g:loaded_syntastic_plugin") finish endif let g:loaded_syntastic_c_autoload = 1 let s:save_cpo = &cpo set cpo&vim " Public functions {{{1 " convenience function to determine the 'null device' parameter " based on the current operating system function! syntastic#c#NullOutput() " {{{2 let known_os = has('unix') || has('mac') || syntastic#util#isRunningWindows() return known_os ? '-o ' . syntastic#util#DevNull() : '' endfunction " }}}2 " read additional compiler flags from the given configuration file " the file format and its parsing mechanism is inspired by clang_complete function! syntastic#c#ReadConfig(file) " {{{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, '.;') if config == '' call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: file not found') return '' endif call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: config file:', config) if !filereadable(config) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: file unreadable') return '' endif " convert filename into absolute path let filepath = fnamemodify(config, ':p:h') " try to read config file try let lines = readfile(config) catch /\m^Vim\%((\a\+)\)\=:E48[45]/ call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: error reading file') return '' endtry " filter out empty lines and comments call filter(lines, 'v:val !~ ''\v^(\s*#|$)''') " remove leading and trailing spaces call map(lines, 'substitute(v:val, ''\m^\s\+'', "", "")') call map(lines, 'substitute(v:val, ''\m\s\+$'', "", "")') let parameters = [] for line in lines let matches = matchstr(line, '\m\C^\s*-I\s*\zs.\+') if matches != '' " this one looks like an absolute path if match(matches, '\m^\%(/\|\a:\)') != -1 call add(parameters, '-I' . matches) else call add(parameters, '-I' . filepath . syntastic#util#Slash() . matches) endif else call add(parameters, line) endif endfor return join(map(parameters, 'syntastic#util#shescape(v:val)')) endfunction " }}}2 " GetLocList() for C-like compilers function! syntastic#c#GetLocList(filetype, subchecker, options) " {{{2 try let flags = s:_get_cflags(a:filetype, a:subchecker, a:options) catch /\m\C^Syntastic: skip checks$/ return [] endtry let makeprg = syntastic#util#shexpand(g:syntastic_{a:filetype}_compiler) . \ ' ' . flags . ' ' . syntastic#util#shexpand('%') let errorformat = s:_get_checker_var('g', a:filetype, a:subchecker, 'errorformat', a:options['errorformat']) let postprocess = s:_get_checker_var('g', a:filetype, a:subchecker, 'remove_include_errors', 0) ? \ ['filterForeignErrors'] : [] " process makeprg return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, \ 'postprocess': postprocess }) endfunction " }}}2 " }}}1 " Private functions {{{1 " initialize c/cpp syntax checker handlers function! s:_init() " {{{2 let s:handlers = [] let s:cflags = {} call s:_registerHandler('\m\', 's:_checkPhp', []) call s:_registerHandler('\m\', 's:_checkPython', []) call s:_registerHandler('\m\