summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ffc8ed2)
raw | patch | inline | side by side (parent: ffc8ed2)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 1 Jun 2010 12:36:57 +0000 (08:36 -0400) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 1 Jun 2010 13:02:06 +0000 (09:02 -0400) |
tig.c | patch | blob | history |
index b17d8dd07b50607a0a40c44c4ba236aa76810e4a..46f289ec1335debbcff6bc0ba014455bf7d06c77 100644 (file)
--- a/tig.c
+++ b/tig.c
free((void *) argv[argc]);
}
+static void
+argv_copy(const char *dst[], const char *src[])
+{
+ int argc;
+
+ for (argc = 0; src[argc]; argc++)
+ dst[argc] = src[argc];
+}
+
/*
* Executing external commands.
io->dir = dir;
}
+static void
+io_prepare(struct io *io, const char *dir, enum io_type type, const char *argv[])
+{
+ io_init(io, dir, type);
+ argv_copy(io->argv, argv);
+}
+
static bool
io_format(struct io *io, const char *dir, enum io_type type,
const char *argv[], enum format_flags flags)
static bool
io_run(struct io *io, const char **argv, const char *dir, enum io_type type)
{
- io_init(io, dir, type);
- if (!format_argv(io->argv, argv, FORMAT_NONE))
- return FALSE;
+ io_prepare(io, dir, type, argv);
return io_start(io);
}
{
struct io io = {};
- if (!io_format(&io, NULL, IO_BG, argv, FORMAT_NONE))
- return FALSE;
+ io_prepare(&io, NULL, IO_BG, argv);
return io_complete(&io);
}
{
struct io io = {};
- if (!io_format(&io, dir, IO_FG, argv, FORMAT_NONE))
- return FALSE;
+ io_prepare(&io, dir, IO_FG, argv);
return io_complete(&io);
}
{
struct io io = {};
- if (!io_format(&io, NULL, IO_AP, argv, FORMAT_NONE)) {
- close(fd);
- return FALSE;
- }
-
+ io_prepare(&io, NULL, IO_AP, argv);
io.pipe = fd;
return io_complete(&io);
}
{
struct io io = {};
- return io_run_rd(&io, argv, NULL) && io_read_buf(&io, buf, bufsize);
+ io_prepare(&io, NULL, IO_RD, argv);
+ return io_start(&io) && io_read_buf(&io, buf, bufsize);
}
static int
{
struct io io = {};
- return io_format(&io, NULL, IO_RD, argv, FORMAT_NONE)
- ? io_load(&io, separators, read_property) : ERR;
+ io_prepare(&io, NULL, IO_RD, argv);
+ return io_load(&io, separators, read_property);
}