Patch 7.4.1484
Problem: Channel "err-io" value "out" is not supported.
Solution: Connect stderr to stdout if wanted.
Files: src/os_unix.c, src/os_win32.c, src/testdir/test_channel.vim,
src/testdir/test_channel_pipe.py
*** ../vim-7.4.1483/src/os_unix.c 2016-03-02 21:51:08.676257463 +0100
--- src/os_unix.c 2016-03-03 20:47:13.204717185 +0100
***************
*** 5045,5050 ****
--- 5045,5051 ----
int fd_err[2]; /* for stderr */
# ifdef FEAT_CHANNEL
channel_T *channel = NULL;
+ int use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT;
#endif
/* default is to fail */
***************
*** 5056,5062 ****
/* TODO: without the channel feature connect the child to /dev/null? */
# ifdef FEAT_CHANNEL
/* Open pipes for stdin, stdout, stderr. */
! if ((pipe(fd_in) < 0) || (pipe(fd_out) < 0) ||(pipe(fd_err) < 0))
goto failed;
channel = add_channel();
--- 5057,5064 ----
/* TODO: without the channel feature connect the child to /dev/null? */
# ifdef FEAT_CHANNEL
/* Open pipes for stdin, stdout, stderr. */
! if (pipe(fd_in) < 0 || pipe(fd_out) < 0
! || (!use_out_for_err && pipe(fd_err) < 0))
goto failed;
channel = add_channel();
***************
*** 5093,5109 ****
ignored = dup(fd_in[0]);
close(fd_in[0]);
/* set up stdout for the child */
close(fd_out[0]);
close(1);
ignored = dup(fd_out[1]);
close(fd_out[1]);
- /* set up stderr for the child */
- close(fd_err[0]);
- close(2);
- ignored = dup(fd_err[1]);
- close(fd_err[1]);
# endif
/* See above for type of argv. */
--- 5095,5120 ----
ignored = dup(fd_in[0]);
close(fd_in[0]);
+ /* set up stderr for the child */
+ if (use_out_for_err)
+ {
+ close(2);
+ ignored = dup(fd_out[1]);
+ }
+ else
+ {
+ close(fd_err[0]);
+ close(2);
+ ignored = dup(fd_err[1]);
+ close(fd_err[1]);
+ }
+
/* set up stdout for the child */
close(fd_out[0]);
close(1);
ignored = dup(fd_out[1]);
close(fd_out[1]);
# endif
/* See above for type of argv. */
***************
*** 5123,5131 ****
/* child stdin, stdout and stderr */
close(fd_in[0]);
close(fd_out[1]);
- close(fd_err[1]);
# ifdef FEAT_CHANNEL
! channel_set_pipes(channel, fd_in[1], fd_out[0], fd_err[0]);
channel_set_job(channel, job);
channel_set_options(channel, options);
# ifdef FEAT_GUI
--- 5134,5146 ----
/* child stdin, stdout and stderr */
close(fd_in[0]);
close(fd_out[1]);
# ifdef FEAT_CHANNEL
! if (!use_out_for_err)
! # endif
! close(fd_err[1]);
! # ifdef FEAT_CHANNEL
! channel_set_pipes(channel, fd_in[1], fd_out[0],
! use_out_for_err ? INVALID_FD : fd_err[0]);
channel_set_job(channel, job);
channel_set_options(channel, options);
# ifdef FEAT_GUI
*** ../vim-7.4.1483/src/os_win32.c 2016-02-27 18:13:05.240593068 +0100
--- src/os_win32.c 2016-03-03 20:53:34.848746475 +0100
***************
*** 5000,5005 ****
--- 5000,5006 ----
HANDLE jo;
# ifdef FEAT_CHANNEL
channel_T *channel;
+ int use_out_for_err = options->jo_io[PART_ERR] ==
JIO_OUT;
HANDLE ifd[2];
HANDLE ofd[2];
HANDLE efd[2];
***************
*** 5038,5050 ****
|| !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)
|| !CreatePipe(&ofd[0], &ofd[1], &saAttr, 0)
|| !pSetHandleInformation(ofd[0], HANDLE_FLAG_INHERIT, 0)
! || !CreatePipe(&efd[0], &efd[1], &saAttr, 0)
! || !pSetHandleInformation(efd[0], HANDLE_FLAG_INHERIT, 0))
goto failed;
si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdInput = ifd[0];
si.hStdOutput = ofd[1];
! si.hStdError = efd[1];
# endif
if (!vim_create_process(cmd, TRUE,
--- 5039,5052 ----
|| !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)
|| !CreatePipe(&ofd[0], &ofd[1], &saAttr, 0)
|| !pSetHandleInformation(ofd[0], HANDLE_FLAG_INHERIT, 0)
! || (!use_out_for_err
! && (!CreatePipe(&efd[0], &efd[1], &saAttr, 0)
! || !pSetHandleInformation(efd[0], HANDLE_FLAG_INHERIT, 0))))
goto failed;
si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdInput = ifd[0];
si.hStdOutput = ofd[1];
! si.hStdError = use_out_for_err ? ofd[1] : efd[1];
# endif
if (!vim_create_process(cmd, TRUE,
***************
*** 5075,5084 ****
# ifdef FEAT_CHANNEL
CloseHandle(ifd[0]);
CloseHandle(ofd[1]);
! CloseHandle(efd[1]);
job->jv_channel = channel;
! channel_set_pipes(channel, (sock_T)ifd[1], (sock_T)ofd[0],
(sock_T)efd[0]);
channel_set_job(channel, job);
channel_set_options(channel, options);
--- 5077,5088 ----
# ifdef FEAT_CHANNEL
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_job(channel, job);
channel_set_options(channel, options);
*** ../vim-7.4.1483/src/testdir/test_channel.vim 2016-03-03
19:34:58.221362693 +0100
--- src/testdir/test_channel.vim 2016-03-03 20:45:11.269980869 +0100
***************
*** 339,348 ****
endfunc
func Test_raw_one_time_callback()
- call ch_logfile('channellog', 'w')
call ch_log('Test_raw_one_time_callback()')
call s:run_server('s:raw_one_time_callback')
- call ch_logfile('')
endfunc
"""""""""
--- 339,346 ----
***************
*** 420,425 ****
--- 418,426 ----
call ch_sendraw(handle, "echo something\n")
call assert_equal("something", ch_readraw(handle))
+ call ch_sendraw(handle, "echoerr wrong\n")
+ call assert_equal("wrong", ch_readraw(handle, {'part': 'err'}))
+
call ch_sendraw(handle, "double this\n")
call assert_equal("this", ch_readraw(handle))
call assert_equal("AND this", ch_readraw(handle))
***************
*** 429,434 ****
--- 430,454 ----
finally
call job_stop(job)
endtry
+ endfunc
+
+ func Test_nl_err_to_out_pipe()
+ if !has('job')
+ return
+ endif
+ call ch_log('Test_nl_err_to_out_pipe()')
+ let job = job_start(s:python . " test_channel_pipe.py", {'err-io': 'out'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echo something\n")
+ call assert_equal("something", ch_readraw(handle))
+
+ call ch_sendraw(handle, "echoerr wrong\n")
+ call assert_equal("wrong", ch_readraw(handle))
+ finally
+ call job_stop(job)
+ endtry
endfunc
func Test_pipe_to_buffer()
*** ../vim-7.4.1483/src/testdir/test_channel_pipe.py 2016-02-16
19:25:07.584925674 +0100
--- src/testdir/test_channel_pipe.py 2016-03-03 20:41:26.184314131 +0100
***************
*** 18,26 ****
print("Goodbye!")
sys.stdout.flush()
break
! if typed.startswith("echo"):
print(typed[5:-1])
sys.stdout.flush()
if typed.startswith("double"):
print(typed[7:-1] + "\nAND " + typed[7:-1])
sys.stdout.flush()
--- 18,29 ----
print("Goodbye!")
sys.stdout.flush()
break
! if typed.startswith("echo "):
print(typed[5:-1])
sys.stdout.flush()
+ if typed.startswith("echoerr"):
+ print(typed[8:-1], file=sys.stderr)
+ sys.stderr.flush()
if typed.startswith("double"):
print(typed[7:-1] + "\nAND " + typed[7:-1])
sys.stdout.flush()
*** ../vim-7.4.1483/src/version.c 2016-03-03 19:34:58.221362693 +0100
--- src/version.c 2016-03-03 20:33:12.857428362 +0100
***************
*** 745,746 ****
--- 745,748 ----
{ /* Add new patch number below this line */
+ /**/
+ 1484,
/**/
--
FIRST VILLAGER: We have found a witch. May we burn her?
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.