summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-27 13:05:50 +0100
committerw0rp <devw0rp@gmail.com>2020-08-27 13:05:50 +0100
commit17605777d6cbe4a9eba5d31c799e73a6672f59cf (patch)
tree83330335f3d3b785733939e9e45fd166e7f9da8a
parent66ff00c4204095e65d8547c86e94325b205365ea (diff)
downloadale-17605777d6cbe4a9eba5d31c799e73a6672f59cf.zip
Fix #3317 - Parse -include from C flags
-rw-r--r--autoload/ale/c.vim1
-rw-r--r--test/test_c_flag_parsing.vader14
2 files changed, 9 insertions, 6 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index e6fcb8e6..6f18ce4c 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -133,6 +133,7 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
\ || stridx(l:option, '-isystem') == 0
\ || stridx(l:option, '-idirafter') == 0
\ || stridx(l:option, '-iframework') == 0
+ \ || stridx(l:option, '-include') == 0
if stridx(l:option, '-I') == 0 && l:option isnot# '-I'
let l:arg = join(split(l:option, '\zs')[2:], '')
let l:option = '-I'
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader
index e33a29ea..ce2e8018 100644
--- a/test/test_c_flag_parsing.vader
+++ b/test/test_c_flag_parsing.vader
@@ -452,14 +452,15 @@ Execute(ParseCFlags should handle parenthesis and quotes):
\ . '-Dtest3=`(" ")` file3.o '
\ )
-Execute(CFlags we want to pass):
+Execute(We should include flags with paths that we want):
AssertEqual
- \ '-I ' . ale#Escape(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/inc'))
- \ . ' -I ' . ale#Escape(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/include'))
- \ . ' -iquote ' . ale#Escape(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/incquote'))
- \ . ' -isystem ' . ale#Escape(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/incsystem'))
+ \ '-I ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/inc'))
+ \ . ' -I ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include'))
+ \ . ' -iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/incquote'))
+ \ . ' -isystem ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/incsystem'))
\ . ' -idirafter ' . ale#Escape(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/incafter'))
- \ . ' -iframework ' . ale#Escape(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/incframework'))
+ \ . ' -iframework ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/incframework'))
+ \ . ' -include ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/foo bar'))
\ . ' -Dmacro=value -D macro2 -Bbdir -B bdir2'
\ . ' -iprefix prefix -iwithprefix prefix2 -iwithprefixbefore prefix3'
\ . ' -isysroot sysroot --sysroot=test --no-sysroot-suffix -imultilib multidir'
@@ -470,6 +471,7 @@ Execute(CFlags we want to pass):
\ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
\ 'gcc'
\ . ' -Iinc -I include -iquote incquote -isystem incsystem -idirafter incafter -iframework incframework'
+ \ . ' -include ''foo bar'''
\ . ' -Dmacro=value -D macro2 -Bbdir -B bdir2'
\ . ' -iprefix prefix -iwithprefix prefix2 -iwithprefixbefore prefix3'
\ . ' -isysroot sysroot --sysroot=test --no-sysroot-suffix -imultilib multidir'