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 {
if (first_read) {
/* Add path info line */
- if (snprintf(buf, sizeof(buf), "Directory path /%s", opt_path) < sizeof(buf) &&
+ if (string_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;
/* Insert "link" to parent directory. */
if (*opt_path &&
- snprintf(buf, sizeof(buf), TREE_UP_FORMAT, view->ref) < sizeof(buf) &&
+ string_format(buf, TREE_UP_FORMAT, view->ref) &&
realloc_lines(view, view->line_size + 1) &&
pager_read(view, buf))
view->line[view->lines - 1].type = LINE_TREE_DIR;
} else {
size_t pathlen = strlen(opt_path);
+ size_t origlen = pathlen;
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