summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorJacob Segal <jacob.e.segal@gmail.com>2018-09-10 18:46:18 -0700
committerJacob Segal <jacob.e.segal@gmail.com>2018-11-17 04:04:39 -0800
commit1b3fa9828c79a6ca53561945348832de66cbab7b (patch)
tree1eb888a8debc1206e3c13749711597f2f9e14341 /autoload
parent531868f759404e11d1f34f72e19dcd6112a88567 (diff)
downloadale-1b3fa9828c79a6ca53561945348832de66cbab7b.zip
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.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/c.vim11
1 files changed, 8 insertions, 3 deletions
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index ce59ae31..ce5105b6 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -50,12 +50,17 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
let l:cflags_list = []
let l:previous_options = []
- for l:option in 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_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# ' '
+ if len(l:option_list) > 0 && l:option_list[-1] isnot# ' ' && l:option_index < len(l:split_lines)
continue
endif
@@ -81,7 +86,7 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort
call add(l:cflags_list, l:option)
endif
endif
- endfor
+ endwhile
return join(l:cflags_list, ' ')
endfunction