summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jeanson <mjeanson@gmail.com>2021-07-04 08:27:55 -0400
committerGitHub <noreply@github.com>2021-07-04 21:27:55 +0900
commit9efa96eb9431e43e183a73f91db4c84126880a15 (patch)
tree9488352b9d2700d46c1b5347237af769c77cc065
parentf9332bae1fc9f2599847e4641b27527df415507b (diff)
downloadale-9efa96eb9431e43e183a73f91db4c84126880a15.zip
fix: cflags parser: no absolute path for '-include' (#3775)
Both '-include' and '-imacros' take a file as an argument that will then be searched in the include path like a regular '#include "..."' statement in a source file. As such, they should not have their path converted to an absolute path. Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
-rw-r--r--autoload/ale/c.vim3
-rw-r--r--test/test_c_flag_parsing.vader16
2 files changed, 9 insertions, 10 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index ec9d4482..e729aec8 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -151,8 +151,6 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort
\ || stridx(l:option, '-isystem') == 0
\ || stridx(l:option, '-idirafter') == 0
\ || stridx(l:option, '-iframework') == 0
- \ || stridx(l:option, '-include') == 0
- \ || stridx(l:option, '-imacros') == 0
if stridx(l:option, '-I') == 0 && l:option isnot# '-I'
let l:arg = join(split(l:option, '\zs')[2:], '')
let l:option = '-I'
@@ -182,6 +180,7 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort
" Options that have an argument (always separate)
elseif l:option is# '-iprefix' || stridx(l:option, '-iwithprefix') == 0
\ || l:option is# '-isysroot' || l:option is# '-imultilib'
+ \ || l:option is# '-include' || l:option is# '-imacros'
call add(l:items, [0, l:option])
call add(l:items, [0, l:arguments[l:option_index]])
let l:option_index = l:option_index + 1
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader
index 4204d8ea..c661651e 100644
--- a/test/test_c_flag_parsing.vader
+++ b/test/test_c_flag_parsing.vader
@@ -495,8 +495,8 @@ Execute(We should include several important flags):
\ . ' -isystem ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/incsystem'))
\ . ' -idirafter ' . ale#Escape(ale#path#Simplify(g:dir. '/test-files/c/makefile_project/incafter'))
\ . ' -iframework ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/incframework'))
- \ . ' -include ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/foo bar'))
- \ . ' -imacros ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/incmacros'))
+ \ . ' -include file.h'
+ \ . ' -imacros macros.h'
\ . ' -Dmacro="value"'
\ . ' -DGoal=9'
\ . ' -D macro2'
@@ -525,9 +525,9 @@ Execute(We should include several important flags):
\ '-iframework',
\ 'incframework',
\ '-include',
- \ '''foo bar''',
+ \ 'file.h',
\ '-imacros',
- \ 'incmacros',
+ \ 'macros.h',
\ '-Dmacro="value"',
\ '-DGoal=9',
\ '-D',
@@ -575,8 +575,8 @@ Execute(We should quote the flags we need to quote):
\ . ' -isystem ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/incsystem'))
\ . ' -idirafter ' . ale#Escape(ale#path#Simplify(g:dir. '/test-files/c/makefile_project/incafter'))
\ . ' -iframework ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/incframework'))
- \ . ' -include ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/foo bar'))
- \ . ' -imacros ' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/c/makefile_project/incmacros'))
+ \ . ' -include file.h'
+ \ . ' -imacros macros.h'
\ . ' ' . ale#Escape('-Dmacro="value"')
\ . ' -DGoal=9'
\ . ' -D macro2'
@@ -608,9 +608,9 @@ Execute(We should quote the flags we need to quote):
\ '-iframework',
\ 'incframework',
\ '-include',
- \ '''foo bar''',
+ \ 'file.h',
\ '-imacros',
- \ 'incmacros',
+ \ 'macros.h',
\ '-Dmacro="value"',
\ '-DGoal=9',
\ '-D',