mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Fix C flag parsing and tests on Windows
This commit is contained in:
@@ -356,9 +356,27 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
|||||||
|
|
||||||
" Search for an exact file match first.
|
" Search for an exact file match first.
|
||||||
let l:file_list = get(a:file_lookup, l:buffer_filename, [])
|
let l:file_list = get(a:file_lookup, l:buffer_filename, [])
|
||||||
|
|
||||||
|
" We may have to look for /foo/bar instead of C:\foo\bar
|
||||||
|
if empty(l:file_list) && has('win32')
|
||||||
|
let l:file_list = get(
|
||||||
|
\ a:file_lookup,
|
||||||
|
\ ale#path#RemoveDriveLetter(l:buffer_filename),
|
||||||
|
\ []
|
||||||
|
\)
|
||||||
|
endif
|
||||||
|
|
||||||
" Try the absolute path to the directory second.
|
" Try the absolute path to the directory second.
|
||||||
let l:dir_list = get(a:dir_lookup, l:dir, [])
|
let l:dir_list = get(a:dir_lookup, l:dir, [])
|
||||||
|
|
||||||
|
if empty(l:dir_list) && has('win32')
|
||||||
|
let l:dir_list = get(
|
||||||
|
\ a:dir_lookup,
|
||||||
|
\ ale#path#RemoveDriveLetter(l:dir),
|
||||||
|
\ []
|
||||||
|
\)
|
||||||
|
endif
|
||||||
|
|
||||||
if empty(l:file_list) && empty(l:dir_list)
|
if empty(l:file_list) && empty(l:dir_list)
|
||||||
" If we can't find matches with the path to the file, try a
|
" If we can't find matches with the path to the file, try a
|
||||||
" case-insensitive match for any similarly-named file.
|
" case-insensitive match for any similarly-named file.
|
||||||
@@ -378,6 +396,14 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
|||||||
let l:key = fnamemodify(l:buffer_filename, ':r') . l:suffix
|
let l:key = fnamemodify(l:buffer_filename, ':r') . l:suffix
|
||||||
let l:file_list = get(a:file_lookup, l:key, [])
|
let l:file_list = get(a:file_lookup, l:key, [])
|
||||||
|
|
||||||
|
if empty(l:file_list) && has('win32')
|
||||||
|
let l:file_list = get(
|
||||||
|
\ a:file_lookup,
|
||||||
|
\ ale#path#RemoveDriveLetter(l:key),
|
||||||
|
\ []
|
||||||
|
\)
|
||||||
|
endif
|
||||||
|
|
||||||
if empty(l:file_list)
|
if empty(l:file_list)
|
||||||
" Look fuzzy matches on the basename second.
|
" Look fuzzy matches on the basename second.
|
||||||
let l:key = fnamemodify(l:basename, ':r') . l:suffix
|
let l:key = fnamemodify(l:basename, ':r') . l:suffix
|
||||||
@@ -412,7 +438,8 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
|||||||
for l:item in l:dir_list
|
for l:item in l:dir_list
|
||||||
let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file)
|
let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file)
|
||||||
|
|
||||||
if ale#path#Simplify(fnamemodify(l:filename, ':h')) is? l:dir
|
if ale#path#RemoveDriveLetter(fnamemodify(l:filename, ':h'))
|
||||||
|
\ is? ale#path#RemoveDriveLetter(l:dir)
|
||||||
let [l:should_quote, l:args] = s:GetArguments(l:item)
|
let [l:should_quote, l:args] = s:GetArguments(l:item)
|
||||||
|
|
||||||
return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args)
|
return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args)
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ function! ale#path#Simplify(path) abort
|
|||||||
return substitute(simplify(l:win_path), '^\\\+', '\', 'g') " no-custom-checks
|
return substitute(simplify(l:win_path), '^\\\+', '\', 'g') " no-custom-checks
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Simplify a path without a Windows drive letter.
|
||||||
|
" This function can be used for checking if paths are equal.
|
||||||
|
function! ale#path#RemoveDriveLetter(path) abort
|
||||||
|
return has('win32') && a:path[1:2] is# ':\'
|
||||||
|
\ ? ale#path#Simplify(a:path[2:])
|
||||||
|
\ : ale#path#Simplify(a:path)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Given a buffer and a filename, find the nearest file by searching upwards
|
" Given a buffer and a filename, find the nearest file by searching upwards
|
||||||
" through the paths relative to the given buffer.
|
" through the paths relative to the given buffer.
|
||||||
function! ale#path#FindNearestFile(buffer, filename) abort
|
function! ale#path#FindNearestFile(buffer, filename) abort
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ Execute(ShellSplit should not merge flags):
|
|||||||
\ '-Idir-with-dash',
|
\ '-Idir-with-dash',
|
||||||
\ 'subdir/somedep3.o',
|
\ 'subdir/somedep3.o',
|
||||||
\ 'subdir/somedep4.o',
|
\ 'subdir/somedep4.o',
|
||||||
\ '-Ikernel/include',
|
\ '-I' . ale#path#Simplify('kernel/include'),
|
||||||
\ 'subdir/somedep5.o',
|
\ 'subdir/somedep5.o',
|
||||||
\ 'subdir/somedep6.o',
|
\ 'subdir/somedep6.o',
|
||||||
\ ],
|
\ ],
|
||||||
|
|||||||
Reference in New Issue
Block a user