diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-08 13:48:51 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-08 13:48:51 +0100 |
commit | 94d0191dbcce829ad9b92d902b6e2717041db3b8 (patch) | |
tree | 6ea861448e4ff2885f27214d719c3df0d5e6a9d5 | |
parent | af6e36ff16736106a1bc63bb4d01f51fdfeb29a2 (diff) | |
download | vim-git-94d0191dbcce829ad9b92d902b6e2717041db3b8.tar.gz |
patch 7.4.1512v7.4.1512
Problem: Channel input from file not supported on MS-Windows.
Solution: Implement it. (Yasuhiro Matsumoto)
-rw-r--r-- | src/os_win32.c | 42 | ||||
-rw-r--r-- | src/testdir/test_channel.vim | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 35 insertions, 13 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index 9201b3497..12b156aae 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -5039,10 +5039,31 @@ mch_start_job(char *cmd, job_T *job, jobopt_T *options) if (use_file_for_in) { char_u *fname = options->jo_io_name[PART_IN]; +#ifdef FEAT_MBYTE + WCHAR *wn = NULL; + if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) + { + wn = enc_to_utf16(fname, NULL); + if (wn != NULL) + { + ifd[0] = CreateFileW(wn, GENERIC_WRITE, FILE_SHARE_READ, + &saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + vim_free(wn); + if (ifd[0] == INVALID_HANDLE_VALUE + && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + wn = NULL; + } + } + if (wn == NULL) +#endif - // TODO - EMSG2(_(e_notopen), fname); - goto failed; + ifd[0] = CreateFile((LPCSTR)fname, GENERIC_READ, FILE_SHARE_READ, + &saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (ifd[0] == INVALID_HANDLE_VALUE) + { + EMSG2(_(e_notopen), fname); + goto failed; + } } else if (!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0) || !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)) @@ -5088,18 +5109,21 @@ mch_start_job(char *cmd, job_T *job, jobopt_T *options) job->jv_status = JOB_STARTED; # ifdef FEAT_CHANNEL - CloseHandle(ifd[0]); + if (!use_file_for_in) + CloseHandle(ifd[0]); CloseHandle(ofd[1]); if (!use_out_for_err) CloseHandle(efd[1]); job->jv_channel = channel; - channel_set_pipes(channel, (sock_T)ifd[1], (sock_T)ofd[0], - use_out_for_err ? INVALID_FD : (sock_T)efd[0]); + channel_set_pipes(channel, + use_file_for_in ? INVALID_FD : (sock_T)ifd[1], + (sock_T)ofd[0], + use_out_for_err ? INVALID_FD : (sock_T)efd[0]); channel_set_job(channel, job, options); -# ifdef FEAT_GUI - channel_gui_register(channel); -# endif +# ifdef FEAT_GUI + channel_gui_register(channel); +# endif # endif return; diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 3f6511ad0..dd7ef4ec4 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -538,10 +538,6 @@ func Test_nl_read_file() if !has('job') return endif - " TODO: make this work for MS-Windows. - if !has('unix') - return - endif call ch_log('Test_nl_read_file()') call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput') let job = job_start(s:python . " test_channel_pipe.py", diff --git a/src/version.c b/src/version.c index 6141a2e4e..eb9c48667 100644 --- a/src/version.c +++ b/src/version.c @@ -744,6 +744,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1512, +/**/ 1511, /**/ 1510, |