forked from aniani/vim
patch 7.4.1512
Problem: Channel input from file not supported on MS-Windows. Solution: Implement it. (Yasuhiro Matsumoto)
This commit is contained in:
@@ -5039,10 +5039,31 @@ mch_start_job(char *cmd, job_T *job, jobopt_T *options)
|
|||||||
if (use_file_for_in)
|
if (use_file_for_in)
|
||||||
{
|
{
|
||||||
char_u *fname = options->jo_io_name[PART_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
|
ifd[0] = CreateFile((LPCSTR)fname, GENERIC_READ, FILE_SHARE_READ,
|
||||||
EMSG2(_(e_notopen), fname);
|
&saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
goto failed;
|
if (ifd[0] == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
EMSG2(_(e_notopen), fname);
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0)
|
else if (!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0)
|
||||||
|| !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 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;
|
job->jv_status = JOB_STARTED;
|
||||||
|
|
||||||
# ifdef FEAT_CHANNEL
|
# ifdef FEAT_CHANNEL
|
||||||
CloseHandle(ifd[0]);
|
if (!use_file_for_in)
|
||||||
|
CloseHandle(ifd[0]);
|
||||||
CloseHandle(ofd[1]);
|
CloseHandle(ofd[1]);
|
||||||
if (!use_out_for_err)
|
if (!use_out_for_err)
|
||||||
CloseHandle(efd[1]);
|
CloseHandle(efd[1]);
|
||||||
|
|
||||||
job->jv_channel = channel;
|
job->jv_channel = channel;
|
||||||
channel_set_pipes(channel, (sock_T)ifd[1], (sock_T)ofd[0],
|
channel_set_pipes(channel,
|
||||||
use_out_for_err ? INVALID_FD : (sock_T)efd[0]);
|
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);
|
channel_set_job(channel, job, options);
|
||||||
# ifdef FEAT_GUI
|
# ifdef FEAT_GUI
|
||||||
channel_gui_register(channel);
|
channel_gui_register(channel);
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -538,10 +538,6 @@ func Test_nl_read_file()
|
|||||||
if !has('job')
|
if !has('job')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
" TODO: make this work for MS-Windows.
|
|
||||||
if !has('unix')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
call ch_log('Test_nl_read_file()')
|
call ch_log('Test_nl_read_file()')
|
||||||
call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput')
|
call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput')
|
||||||
let job = job_start(s:python . " test_channel_pipe.py",
|
let job = job_start(s:python . " test_channel_pipe.py",
|
||||||
|
@@ -743,6 +743,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1512,
|
||||||
/**/
|
/**/
|
||||||
1511,
|
1511,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user