summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6859ce5)
raw | patch | inline | side by side (parent: 6859ce5)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 18 Nov 2009 04:01:21 +0000 (23:01 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 18 Nov 2009 04:31:31 +0000 (23:31 -0500) |
tig.c | patch | blob | history |
index f98fb24a4a076a5f317e38ff1b6ed539347dfaed..9e76ea0c21afb2b3987c94677588685f752b7dd6 100644 (file)
--- a/tig.c
+++ b/tig.c
}
static bool
-io_open(struct io *io, const char *name)
+io_open(struct io *io, const char *fmt, ...)
{
+ char name[SIZEOF_STR] = "";
+ bool fits;
+ va_list args;
+
init_io(io, NULL, IO_FD);
+
+ va_start(args, fmt);
+ fits = vsnprintf(name, sizeof(name), fmt, args) < sizeof(name);
+ va_end(args);
+
+ if (!fits) {
+ io->error = ENAMETOOLONG;
+ return FALSE;
+ }
io->pipe = *name ? open(name, O_RDONLY) : STDIN_FILENO;
if (io->pipe == -1)
io->error = errno;
struct io io = {};
/* It's OK that the file doesn't exist. */
- if (!io_open(&io, path))
+ if (!io_open(&io, "%s", path))
return;
config_lineno = 0;
{
if (view->pipe)
end_update(view, TRUE);
- return io_open(&view->io, name);
+ return io_open(&view->io, "%s", name);
}
static bool
return FALSE;
}
- if (!string_format(path, "%s%s", opt_cdup, opt_file))
- return FALSE;
-
- if (*opt_ref || !io_open(&view->io, path)) {
+ if (*opt_ref || !io_open(&view->io, "%s%s", opt_cdup, opt_file)) {
if (!run_io_rd(&view->io, blame_cat_file_argv, opt_cdup, FORMAT_ALL))
return FALSE;
}
if (!*opt_head) {
struct io io = {};
- if (string_format(buf, "%s/rebase-merge/head-name", opt_git_dir) &&
- io_open(&io, buf) &&
+ if (io_open(&io, "%s/rebase-merge/head-name", opt_git_dir) &&
io_read_buf(&io, buf, sizeof(buf))) {
head = buf;
if (!prefixcmp(head, "refs/heads/"))