comparison src/os_unix.c @ 16227:a70f0d6686c4 v8.1.1118

patch 8.1.1118: a couple of conditions are hard to understand commit https://github.com/vim/vim/commit/652de23dc7abf6aa2721ccee7fe279b5cce8069c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 4 20:13:09 2019 +0200 patch 8.1.1118: a couple of conditions are hard to understand Problem: A couple of conditions are hard to understand. Solution: Split the conditions into pieces. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/3879)
author Bram Moolenaar <Bram@vim.org>
date Thu, 04 Apr 2019 20:15:05 +0200
parents cd5c83115ec6
children 4e9bea9b8025
comparison
equal deleted inserted replaced
16226:e1e238ab3300 16227:a70f0d6686c4
5605 close(fd_out[1]); 5605 close(fd_out[1]);
5606 if (fd_err[1] >= 0) 5606 if (fd_err[1] >= 0)
5607 close(fd_err[1]); 5607 close(fd_err[1]);
5608 if (channel != NULL) 5608 if (channel != NULL)
5609 { 5609 {
5610 int in_fd = use_file_for_in || use_null_for_in 5610 int in_fd = INVALID_FD;
5611 ? INVALID_FD : fd_in[1] < 0 ? pty_master_fd : fd_in[1]; 5611 int out_fd = INVALID_FD;
5612 int out_fd = use_file_for_out || use_null_for_out 5612 int err_fd = INVALID_FD;
5613 ? INVALID_FD : fd_out[0] < 0 ? pty_master_fd : fd_out[0]; 5613
5614 /* When using pty_master_fd only set it for stdout, do not duplicate it 5614 if (!(use_file_for_in || use_null_for_in))
5615 * for stderr, it only needs to be read once. */ 5615 in_fd = fd_in[1] >= 0 ? fd_in[1] : pty_master_fd;
5616 int err_fd = use_out_for_err || use_file_for_err || use_null_for_err 5616
5617 ? INVALID_FD 5617 if (!(use_file_for_out || use_null_for_out))
5618 : fd_err[0] >= 0 5618 out_fd = fd_out[0] >= 0 ? fd_out[0] : pty_master_fd;
5619 ? fd_err[0] 5619
5620 : (out_fd == pty_master_fd 5620 // When using pty_master_fd only set it for stdout, do not duplicate
5621 ? INVALID_FD 5621 // it for stderr, it only needs to be read once.
5622 : pty_master_fd); 5622 if (!(use_out_for_err || use_file_for_err || use_null_for_err))
5623 {
5624 if (fd_err[0] >= 0)
5625 err_fd = fd_err[0];
5626 else if (out_fd != pty_master_fd)
5627 err_fd = pty_master_fd;
5628 }
5623 5629
5624 channel_set_pipes(channel, in_fd, out_fd, err_fd); 5630 channel_set_pipes(channel, in_fd, out_fd, err_fd);
5625 channel_set_job(channel, job, options); 5631 channel_set_job(channel, job, options);
5626 } 5632 }
5627 else 5633 else