summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorroel0 <roel.postelmans@altran.com>2018-03-20 11:56:46 +0100
committerroel0 <roel.postelmans@altran.com>2018-03-20 11:56:46 +0100
commit3fb7efa2c6d249ccc5b69036dbeda690c7459515 (patch)
tree33393c06810204d57e558ed7cec68cb0902032ba /autoload
parentc47b5fd4b8f9b7c08774e631dae60ca51c23e7c9 (diff)
downloadale-3fb7efa2c6d249ccc5b69036dbeda690c7459515.zip
Added some unit tests and fixed some linting errors for automatic makefile parsing in C #1167
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/c.vim32
1 files changed, 16 insertions, 16 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index 4bf8ad4d..7dc532b3 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -24,42 +24,42 @@ endfunction
function! ale#c#ParseCFlags(project_root, stdout_make) abort
let l:cflags_list = []
- let l:cflags = split(a:stdout_make, " ")
+ let l:cflags = split(a:stdout_make)
let l:shell_option = 0
let l:macro_option = 0
let l:previous_option = ''
for l:option in l:cflags
" Check if cflag contained spaces
- if l:shell_option || stridx(l:option, "=`") >= 0
+ if l:shell_option || stridx(l:option, '=`') >= 0
" Cflag contained shell command with spaces (ex. -D='date +%s')
let l:shell_option = 1
let l:previous_option .= l:option . ' '
- if l:option[-1: -1] != "`"
+ if l:option[-1: -1] isnot? '`'
continue
endif
let l:shell_option = 0
- elseif l:macro_option || stridx(l:option, "$((") > 0
+ elseif l:macro_option || stridx(l:option, '$((') > 0
" Cflag contained macro with spaces (ex -Da=$(( 4 * 20 )))
let l:macro_option = 1
let l:previous_option .= l:option . ' '
- if stridx(l:option, "))") < 0
+ if stridx(l:option, '))') < 0
continue
endif
let l:macro_option = 0
endif
- if l:previous_option != ''
+ if l:previous_option isnot? ''
let l:option = l:previous_option
let l:previous_option = ''
endif
" Fix relative paths if needed
- if stridx(l:option, "-I") >= 0
- if stridx(l:option, "-I/") < 0
+ if stridx(l:option, '-I') >= 0
+ if stridx(l:option, '-I' . s:sep) < 0
let l:option = '-I' . a:project_root . s:sep . l:option[2:]
endif
endif
" Parse the cflag
- if stridx(l:option, "-I") >= 0 ||
- \ stridx(l:option, "-D") >= 0
+ if stridx(l:option, '-I') >= 0 ||
+ \ stridx(l:option, '-D') >= 0
if index(l:cflags_list, l:option) < 0
call add(l:cflags_list, l:option)
endif
@@ -74,12 +74,12 @@ function! ale#c#ParseMakefile(buffer) abort
if !empty(l:project_root)
if !empty(globpath(l:project_root, 'Makefile', 0))
- let stdout_make = system('cd '. l:project_root . ' && make -n')
- for l:object in split(l:stdout_make, '\n')
- if stridx(l:object, expand("%t"))
- return ale#c#ParseCFlags(l:project_root, l:object)
- endif
- endfor
+ let l:stdout_make = system('cd '. l:project_root . ' && make -n')
+ for l:object in split(l:stdout_make, '\n')
+ if stridx(l:object, expand('#' . a:buffer . '...'))
+ return ale#c#ParseCFlags(l:project_root, l:object)
+ endif
+ endfor
endif
endif
return []