From: Jonas Fonseca Date: Tue, 1 Jun 2010 12:40:31 +0000 (-0400) Subject: Refactor io_complete into a single backend for {back,fore}ground and append IO X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c3961fe1f3310d5c8ebfd993e9d3be24beb09ed0;p=tig.git Refactor io_complete into a single backend for {back,fore}ground and append IO --- diff --git a/tig.c b/tig.c index 46f289e..a9924c9 100644 --- a/tig.c +++ b/tig.c @@ -879,38 +879,32 @@ io_run(struct io *io, const char **argv, const char *dir, enum io_type type) return io_start(io); } -static int -io_complete(struct io *io) +static bool +io_complete(enum io_type type, const char **argv, const char *dir, int fd) { - return io_start(io) && io_done(io); + struct io io = {}; + + io_prepare(&io, dir, type, argv); + io.pipe = fd; + return io_start(&io) && io_done(&io); } -static int +static bool io_run_bg(const char **argv) { - struct io io = {}; - - io_prepare(&io, NULL, IO_BG, argv); - return io_complete(&io); + return io_complete(IO_BG, argv, NULL, -1); } static bool io_run_fg(const char **argv, const char *dir) { - struct io io = {}; - - io_prepare(&io, dir, IO_FG, argv); - return io_complete(&io); + return io_complete(IO_FG, argv, dir, -1); } static bool io_run_append(const char **argv, int fd) { - struct io io = {}; - - io_prepare(&io, NULL, IO_AP, argv); - io.pipe = fd; - return io_complete(&io); + return io_complete(IO_AP, argv, NULL, -1); } static bool