mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-03 18:14:01 +08:00
Fix bug where last c flag was ignored
There is currently a check that tries to prevent c-flags that contain '-' in them from being unintentionally split and included in the list of commands. For example, we wouldn't want "-fno-exceptions " to appear as "-fno" and "-exceptions ". The way this check was done was by making sure the last character of the split string was a space. This meant that the very last option to appear in the compile command was ignored (as it doesn't end with a space). This fix explicitly skips the ends-with-space check on the last option in the command-line. This isn't the best fix. Really we should be using the same argument-processing rules as a shell would rather than just splitting on '-'. That's a much larger and more complicated change though.
This commit is contained in:
@@ -141,6 +141,22 @@ Execute(ParseCFlags should handle -D with minuses):
|
||||
\ . ' -DTEST=`date +%s` -c file.c'
|
||||
\ )
|
||||
|
||||
Execute(ParseCFlags should handle flags at the end of the line):
|
||||
AssertEqual
|
||||
\ '-Dgoal=9'
|
||||
\ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
|
||||
\ . ' -Dmacro-with-dash'
|
||||
\ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces'))
|
||||
\ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash'))
|
||||
\ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
|
||||
\ ale#c#ParseCFlags(
|
||||
\ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
|
||||
\ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
|
||||
\ . '-Dmacro-with-dash '
|
||||
\ . '-I''dir with spaces''' . ' -Idir-with-dash'
|
||||
\ . ' -I'. ale#path#Simplify('kernel/include')
|
||||
\ )
|
||||
|
||||
Execute(FlagsFromCompileCommands should tolerate empty values):
|
||||
AssertEqual '', ale#c#FlagsFromCompileCommands(bufnr(''), '')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user