summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-01-03 20:37:16 +0000
committerGitHub <noreply@github.com>2019-01-03 20:37:16 +0000
commit1b264b86621430fd190ba6b2d464ed0b34de59f9 (patch)
tree4ddf50f0e946982a51dec2f6803bfc400d4cd739 /autoload
parent78724f4cd3b7a9f050550205da933231dfd02392 (diff)
parente5f33c65982aea8ef082d058a32a08a7883c5c1c (diff)
downloadale-1b264b86621430fd190ba6b2d464ed0b34de59f9.zip
Merge pull request #2168 from fx-carton/master
Fix CFLAGS & Makefile issues
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/c.vim32
1 files changed, 22 insertions, 10 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index ce5105b6..617e81f6 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -48,26 +48,38 @@ endfunction
function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
let l:cflags_list = []
- let l:previous_options = []
+ let l:previous_options = ''
- let l:split_lines = split(a:cflag_line, '-')
+ let l:split_lines = split(a:cflag_line, ' ')
let l:option_index = 0
while l:option_index < len(l:split_lines)
- let l:option = l:split_lines[l:option_index]
+ let l:option = l:previous_options . l:split_lines[l:option_index]
let l:option_index = l:option_index + 1
- call add(l:previous_options, l:option)
- " Check if cflag contained a '-' and should not have been splitted
- let l:option_list = split(l:option, '\zs')
- if len(l:option_list) > 0 && l:option_list[-1] isnot# ' ' && l:option_index < len(l:split_lines)
+ " Check if cflag contained an unmatched characters and should not have been splitted
+ let l:option_special = substitute(l:option, '\\"', '', 'g')
+ let l:option_special = substitute(l:option_special, '[^"''()`]', '', 'g')
+ let l:option_special = substitute(l:option_special, '""', '', 'g')
+ let l:option_special = substitute(l:option_special, '''''', '', 'g')
+ let l:option_special = substitute(l:option_special, '``', '', 'g')
+ let l:option_special = substitute(l:option_special, '((', '(', 'g')
+ let l:option_special = substitute(l:option_special, '))', ')', 'g')
+ let l:option_special = substitute(l:option_special, '()', '', 'g')
+
+ if len(l:option_special) > 0 && l:option_index < len(l:split_lines)
+ let l:previous_options = l:option . ' '
continue
endif
- let l:option = join(l:previous_options, '-')
- let l:previous_options = []
+ " Check if there was spaces after -D/-I and the flag should not have been splitted
+ if l:option is# '-D' || l:option is# '-I'
+ let l:previous_options = l:option
+ continue
+ endif
+
+ let l:previous_options = ''
- let l:option = '-' . substitute(l:option, '^\s*\(.\{-}\)\s*$', '\1', '')
" Fix relative paths if needed
if stridx(l:option, '-I') >= 0 &&