summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2fe753e)
raw | patch | inline | side by side (parent: 2fe753e)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 21 Mar 2010 21:00:38 +0000 (17:00 -0400) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 29 Mar 2010 00:18:17 +0000 (20:18 -0400) |
tig.c | patch | blob | history |
index ccd810d85d8c64bc9e500cef647351d63ba23ca4..cad66c8e6e20d85fe8f84eb262e007c7e2112dc7 100644 (file)
--- a/tig.c
+++ b/tig.c
}
static bool
-io_init_rd(struct io *io, const char *argv[], const char *dir,
- enum format_flags flags)
+io_format(struct io *io, const char *dir, enum io_type type,
+ const char *argv[], enum format_flags flags)
{
- io_init(io, dir, IO_RD);
+ io_init(io, dir, type);
return format_argv(io->argv, argv, flags);
}
{
struct io io = {};
- io_init(&io, NULL, IO_BG);
- if (!format_argv(io.argv, argv, FORMAT_NONE))
+ if (!io_format(&io, NULL, IO_BG, argv, FORMAT_NONE))
return FALSE;
return io_complete(&io);
}
{
struct io io = {};
- io_init(&io, dir, IO_FG);
- if (!format_argv(io.argv, argv, FORMAT_NONE))
+ if (!io_format(&io, dir, IO_FG, argv, FORMAT_NONE))
return FALSE;
return io_complete(&io);
}
{
struct io io = {};
- io_init(&io, NULL, IO_AP);
+ if (!io_format(&io, NULL, IO_AP, argv, flags)) {
+ close(fd);
+ return FALSE;
+ }
+
io.pipe = fd;
- if (format_argv(io.argv, argv, flags))
- return io_complete(&io);
- close(fd);
- return FALSE;
+ return io_complete(&io);
}
static bool
io_run_rd(struct io *io, const char **argv, const char *dir, enum format_flags flags)
{
- return io_init_rd(io, argv, dir, flags) && io_start(io);
+ return io_format(io, dir, IO_RD, argv, flags) && io_start(io);
}
static bool
{
struct io io = {};
- return io_init_rd(&io, argv, NULL, FORMAT_NONE)
+ return io_format(&io, NULL, IO_RD, argv, FORMAT_NONE)
? io_load(&io, separators, read_property) : ERR;
}
return NULL;
}
+
static bool
format_argv(const char *dst_argv[], const char *src_argv[], enum format_flags flags)
{
{
if (view->pipe)
end_update(view, TRUE);
- return io_init_rd(&view->io, argv, dir, flags);
+ return io_format(&view->io, dir, IO_RD, argv, flags);
}
static bool
if (view->ops->prepare) {
if (!view->ops->prepare(view))
return FALSE;
- } else if (!io_init_rd(&view->io, view->ops->argv, NULL, FORMAT_ALL)) {
+ } else if (!io_format(&view->io, NULL, IO_RD, view->ops->argv, FORMAT_ALL)) {
return FALSE;
}
opt_path[0] = 0;
}
- return io_init_rd(&view->io, view->ops->argv, opt_cdup, FORMAT_ALL);
+ return io_format(&view->io, opt_cdup, IO_RD, view->ops->argv, FORMAT_ALL);
}
static const char *tree_argv[SIZEOF_ARG] = {