diff --git a/exec.cpp b/exec.cpp index c11d36dfe..4c6e8bfc1 100644 --- a/exec.cpp +++ b/exec.cpp @@ -1008,7 +1008,7 @@ void exec(parser_t &parser, job_t *j) io_remove(j->io, io_buffer); - io_buffer_read(io_buffer.get()); + io_buffer->read(); const char *buffer = io_buffer->out_buffer_ptr(); size_t count = io_buffer->out_buffer_size(); @@ -1423,7 +1423,7 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst) status = proc_get_last_status(); } - io_buffer_read(io_buffer.get()); + io_buffer->read(); proc_set_last_status(prev_status); diff --git a/io.cpp b/io.cpp index 4dfd811e2..0020659cf 100644 --- a/io.cpp +++ b/io.cpp @@ -81,23 +81,23 @@ void io_buffer_t::print() const fprintf(stderr, "buffer %p (size %lu)\n", out_buffer_ptr(), out_buffer_size()); } -void io_buffer_read(io_buffer_t *d) +void io_buffer_t::read() { - exec_close(d->param1.pipe_fd[1]); + exec_close(param1.pipe_fd[1]); - if (d->io_mode == IO_BUFFER) + if (io_mode == IO_BUFFER) { - /* if( fcntl( d->param1.pipe_fd[0], F_SETFL, 0 ) ) + /* if( fcntl( param1.pipe_fd[0], F_SETFL, 0 ) ) { wperror( L"fcntl" ); return; } */ - debug(4, L"io_buffer_read: blocking read on fd %d", d->param1.pipe_fd[0]); + debug(4, L"io_buffer_t::read: blocking read on fd %d", param1.pipe_fd[0]); while (1) { char b[4096]; long l; - l=read_blocked(d->param1.pipe_fd[0], b, 4096); + l=read_blocked(param1.pipe_fd[0], b, 4096); if (l==0) { break; @@ -115,15 +115,15 @@ void io_buffer_read(io_buffer_t *d) { debug(1, _(L"An error occured while reading output from code block on file descriptor %d"), - d->param1.pipe_fd[0]); - wperror(L"io_buffer_read"); + param1.pipe_fd[0]); + wperror(L"io_buffer_t::read"); } break; } else { - d->out_buffer_append(b, l); + out_buffer_append(b, l); } } } diff --git a/io.h b/io.h index 30d0dfe22..62087037c 100644 --- a/io.h +++ b/io.h @@ -163,6 +163,11 @@ public: return out_buffer->size(); } + /** + Close output pipe, and read from input pipe until eof. + */ + void read(); + /** Create a IO_BUFFER type io redirection, complete with a pipe and a vector for output. The default file descriptor used is 1 for @@ -212,11 +217,6 @@ shared_ptr io_chain_get(const io_chain_t &src, int fd); shared_ptr io_chain_get(io_chain_t &src, int fd); -/** - Close output pipe, and read from input pipe until eof. -*/ -void io_buffer_read(io_buffer_t *d); - /** Print debug information about the specified IO redirection chain to stderr. */ void io_print(const io_chain_t &chain); diff --git a/reader.cpp b/reader.cpp index 477795837..f90df311f 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1143,7 +1143,7 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vectorread(); int nil=0; out->out_buffer_append((char *)&nil, 1);