diff --git a/exec.cpp b/exec.cpp index 428978115..c11d36dfe 100644 --- a/exec.cpp +++ b/exec.cpp @@ -801,7 +801,7 @@ void exec(parser_t &parser, job_t *j) if (p->next) { - io_buffer.reset(io_buffer_create(0)); + io_buffer.reset(io_buffer_t::create(0)); j->io.push_back(io_buffer); } @@ -818,7 +818,7 @@ void exec(parser_t &parser, job_t *j) { if (p->next) { - io_buffer.reset(io_buffer_create(0)); + io_buffer.reset(io_buffer_t::create(0)); j->io.push_back(io_buffer); } @@ -1409,7 +1409,7 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst) is_subshell=1; - const shared_ptr io_buffer(io_buffer_create(0)); + const shared_ptr io_buffer(io_buffer_t::create(0)); prev_status = proc_get_last_status(); diff --git a/io.cpp b/io.cpp index 6970a1c9d..4dfd811e2 100644 --- a/io.cpp +++ b/io.cpp @@ -130,7 +130,7 @@ void io_buffer_read(io_buffer_t *d) } -io_buffer_t *io_buffer_create(bool is_input) +io_buffer_t *io_buffer_t::create(bool is_input) { bool success = true; io_buffer_t *buffer_redirect = new io_buffer_t(is_input ? 0 : 1); diff --git a/io.h b/io.h index cc2a37667..0c39963fc 100644 --- a/io.h +++ b/io.h @@ -119,15 +119,15 @@ private: /** buffer to save output in */ shared_ptr > out_buffer; -public: - virtual void print() const; - io_buffer_t(int f): io_data_t(IO_BUFFER, f), out_buffer() { } +public: + virtual void print() const; + ~io_buffer_t(); /** Function to create the output buffer */ @@ -162,6 +162,17 @@ public: assert(out_buffer.get() != NULL); return out_buffer->size(); } + + /** + Create a IO_BUFFER type io redirection, complete with a pipe and a + vector for output. The default file descriptor used is 1 for + output buffering and 0 for input buffering. + + \param is_input set this parameter to zero if the buffer should be + used to buffer the output of a command, or non-zero to buffer the + input to a command. + */ + static io_buffer_t *create(bool is_input); }; class io_chain_t : public std::vector > @@ -201,17 +212,6 @@ shared_ptr io_chain_get(const io_chain_t &src, int fd); shared_ptr io_chain_get(io_chain_t &src, int fd); -/** - Create a IO_BUFFER type io redirection, complete with a pipe and a - vector for output. The default file descriptor used is 1 for - output buffering and 0 for input buffering. - - \param is_input set this parameter to zero if the buffer should be - used to buffer the output of a command, or non-zero to buffer the - input to a command. -*/ -io_buffer_t *io_buffer_create(bool is_input); - /** Close output pipe, and read from input pipe until eof. */ diff --git a/reader.cpp b/reader.cpp index 56e9f8100..477795837 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1064,7 +1064,7 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector in(io_buffer_create(true)); + shared_ptr in(io_buffer_t::create(true)); in->fd = 3; escaped_separator = escape(COMPLETE_SEP_STR, 1); @@ -1133,7 +1133,7 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector out(io_buffer_create(false)); + shared_ptr out(io_buffer_t::create(false)); out->fd = 4; parser_t &parser = parser_t::principal_parser();