chiark
/
gitweb
/
~mdw
/
tig
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f88a531
)
Review all string_format users and use string_format instead of snprintf
author
Jonas Fonseca
<fonseca@diku.dk>
Mon, 11 Sep 2006 00:13:48 +0000
(
02:13
+0200)
committer
Jonas Fonseca
<fonseca@antimatter.localdomain>
Mon, 11 Sep 2006 00:13:48 +0000
(
02:13
+0200)
tig.c
patch
|
blob
|
blame
|
history
diff --git
a/tig.c
b/tig.c
index bd868994f1e299c7e279f166733f02da3f56d037..11eb06d3f4d0061b72b24a7d4c1df51800420f06 100644
(file)
--- a/
tig.c
+++ b/
tig.c
@@
-1731,8
+1731,7
@@
begin_update(struct view *view)
if (strcmp(view->vid, view->id))
opt_path[0] = 0;
if (strcmp(view->vid, view->id))
opt_path[0] = 0;
- if (snprintf(view->cmd, sizeof(view->cmd), format, id, opt_path)
- >= sizeof(view->cmd))
+ if (!string_format(view->cmd, format, id, opt_path))
return FALSE;
} else {
return FALSE;
} else {
@@
-2462,7
+2461,7
@@
tree_read(struct view *view, char *text)
if (first_read) {
/* Add path info line */
if (first_read) {
/* Add path info line */
- if (s
nprintf(buf, sizeof(buf), "Directory path /%s", opt_path) < sizeof(buf
) &&
+ if (s
tring_format(buf, "Directory path /%s", opt_path
) &&
realloc_lines(view, view->line_size + 1) &&
pager_read(view, buf))
view->line[view->lines - 1].type = LINE_DEFAULT;
realloc_lines(view, view->line_size + 1) &&
pager_read(view, buf))
view->line[view->lines - 1].type = LINE_DEFAULT;
@@
-2471,7
+2470,7
@@
tree_read(struct view *view, char *text)
/* Insert "link" to parent directory. */
if (*opt_path &&
/* Insert "link" to parent directory. */
if (*opt_path &&
- s
nprintf(buf, sizeof(buf), TREE_UP_FORMAT, view->ref) < sizeof(bu
f) &&
+ s
tring_format(buf, TREE_UP_FORMAT, view->re
f) &&
realloc_lines(view, view->line_size + 1) &&
pager_read(view, buf))
view->line[view->lines - 1].type = LINE_TREE_DIR;
realloc_lines(view, view->line_size + 1) &&
pager_read(view, buf))
view->line[view->lines - 1].type = LINE_TREE_DIR;
@@
-2548,9
+2547,13
@@
tree_enter(struct view *view, struct line *line)
} else {
size_t pathlen = strlen(opt_path);
} else {
size_t pathlen = strlen(opt_path);
+ size_t origlen = pathlen;
char *basename = data + SIZEOF_TREE_ATTR;
char *basename = data + SIZEOF_TREE_ATTR;
- string_format_from(opt_path, &pathlen, "%s/", basename);
+ if (string_format_from(opt_path, &pathlen, "%s/", basename)) {
+ opt_path[origlen] = 0;
+ return TRUE;
+ }
}
/* Trees and subtrees share the same ID, so they are not not
}
/* Trees and subtrees share the same ID, so they are not not