Skip to content

Commit 55bd01d

Browse files
committed
fix passing empty string to stdin on calling syste()
1 parent 1cf402c commit 55bd01d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Format your C family code
22
=======================================
3-
[![Build Status](https://travis-ci.org/rhysd/vim-clang-format.png?branch=master)](https://travis-ci.org/rhysd/vim-clang-format)
3+
[![Build Status](https://travis-ci.org/rhysd/vim-clang-format.svg?branch=master)](https://travis-ci.org/rhysd/vim-clang-format)
44

55
This plugin formats your code with specific coding style using [clang-format](http://clang.llvm.org/docs/ClangFormat.html).
66

@@ -145,10 +145,9 @@ $ clang-format -dump-config
145145
```
146146

147147
clang-format's documentation and API documentation is useful in some cases.
148-
In paticular, the following link is useful to know the information of a key and its value of a style setting.
148+
In particular, the following link is useful to know the information of a key and its value of a style setting.
149149
[CLANG-FORMAT STYLE OPTIONS](http://clang.llvm.org/docs/ClangFormatStyleOptions.html)
150150

151-
152151
## License
153152

154153
The MIT License (MIT)

autoload/clang_format.vim

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function! s:system(str, ...) abort
2020
let command = a:str
2121
let input = a:0 >= 1 ? a:1 : ''
2222

23-
if a:0 == 0
23+
if a:0 == 0 || a:1 ==# ''
2424
let output = s:has_vimproc() ?
2525
\ vimproc#system(command) : system(command)
2626
elseif a:0 == 1
@@ -72,8 +72,8 @@ function! s:make_style_options() abort
7272
endfunction
7373

7474
function! s:success(result) abort
75-
return (s:has_vimproc() ? vimproc#get_last_status() : v:shell_error) == 0
76-
\ && a:result !~# '^YAML:\d\+:\d\+: error: unknown key '
75+
let exit_success = (s:has_vimproc() ? vimproc#get_last_status() : v:shell_error) == 0
76+
return exit_success && a:result !~# '^YAML:\d\+:\d\+: error: unknown key '
7777
endfunction
7878

7979
function! s:error_message(result) abort
@@ -212,7 +212,8 @@ function! clang_format#format(line1, line2) abort
212212
endif
213213
let args .= g:clang_format#extra_args
214214
let clang_format = printf('%s %s --', s:shellescape(g:clang_format#command), args)
215-
return s:system(clang_format, join(getline(1, '$'), "\n"))
215+
let source = join(getline(1, '$'), "\n")
216+
return s:system(clang_format, source)
216217
endfunction
217218
" }}}
218219

0 commit comments

Comments
 (0)