summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 018510c)
raw | patch | inline | side by side (parent: 018510c)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 9 Jan 2009 14:11:48 +0000 (09:11 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 13 Jan 2009 21:55:19 +0000 (22:55 +0100) |
tig.c | patch | blob | history |
index fdf1dc6c56b01b96118058a7dda67facea50ddbc..12c385ad27c3bf5a5b9acf1f026e04734c454822 100644 (file)
--- a/tig.c
+++ b/tig.c
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
+#include <fcntl.h>
#include <regex.h>
}
static bool
-init_io_fd(struct io *io, FILE *pipe)
+io_open(struct io *io, const char *name)
{
init_io(io, NULL, IO_FD);
- io->pipe = pipe;
+ io->pipe = *name ? fopen(name, "r") : stdin;
return io->pipe != NULL;
}
struct io io = {};
/* It's ok that the file doesn't exist. */
- if (!init_io_fd(&io, fopen(path, "r")))
+ if (!io_open(&io, path))
return;
config_lineno = 0;
{
if (view->pipe)
end_update(view, TRUE);
- return init_io_fd(&view->io, fopen(name, "r"));
+ return io_open(&view->io, name);
}
static bool
static bool
blame_open(struct view *view)
{
- if (*opt_ref || !init_io_fd(&view->io, fopen(opt_file, "r"))) {
+ if (*opt_ref || !io_open(&view->io, opt_file)) {
if (!run_io_rd(&view->io, blame_cat_file_argv, FORMAT_ALL))
return FALSE;
}
if (request == REQ_VIEW_PAGER || run_argv) {
if (request == REQ_VIEW_PAGER)
- init_io_fd(&VIEW(request)->io, stdin);
+ io_open(&VIEW(request)->io, "");
else if (!prepare_update(VIEW(request), run_argv, NULL, FORMAT_NONE))
die("Failed to format arguments");
open_view(NULL, request, OPEN_PREPARED);