xbps-{bin,repo}: wrap long lines for list, pkg-list and search targets.
Fixes issue #26
This commit is contained in:
@@ -32,6 +32,7 @@ struct repo_search_data {
|
||||
int npatterns;
|
||||
char **patterns;
|
||||
size_t pkgver_len;
|
||||
size_t maxcols;
|
||||
};
|
||||
|
||||
/* From common.c */
|
||||
|
||||
@@ -50,11 +50,10 @@ repo_pkg_list_cb(struct xbps_handle *xhp,
|
||||
lpc.check_state = false;
|
||||
lpc.state = 0;
|
||||
lpc.pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
||||
|
||||
if (arg == NULL)
|
||||
printf("From %s repository ...\n", rpi->uri);
|
||||
lpc.maxcols = get_maxcols();
|
||||
|
||||
(void)xbps_callback_array_iter(xhp, rpi->repo, list_pkgs_in_dict, &lpc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,9 +82,10 @@ repo_search_pkgs_cb(struct xbps_handle *xhp,
|
||||
struct repo_search_data *rsd = arg;
|
||||
(void)done;
|
||||
|
||||
rsd->maxcols = get_maxcols();
|
||||
rsd->pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
||||
|
||||
printf("From %s repository ...\n", rpi->uri);
|
||||
(void)xbps_callback_array_iter(xhp, rpi->repo, show_pkg_namedesc, rsd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ show_pkg_namedesc(struct xbps_handle *xhp,
|
||||
bool *loop_done)
|
||||
{
|
||||
struct repo_search_data *rsd = arg;
|
||||
const char *pkgver, *pkgname, *desc, *arch;
|
||||
char *tmp = NULL;
|
||||
size_t i, x;
|
||||
const char *pkgver, *pkgname, *desc, *arch, *inststr;
|
||||
char *tmp = NULL, *out = NULL;
|
||||
size_t i, x, len;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
@@ -129,11 +129,22 @@ show_pkg_namedesc(struct xbps_handle *xhp,
|
||||
|
||||
tmp[x] = '\0';
|
||||
if (xbps_pkgdb_get_pkgd_by_pkgver(xhp, pkgver))
|
||||
printf(" * ");
|
||||
inststr = "[*] ";
|
||||
else
|
||||
printf(" ");
|
||||
printf("%s %s\n", tmp, desc);
|
||||
free(tmp);
|
||||
inststr = "[ ] ";
|
||||
|
||||
len = strlen(inststr) + strlen(tmp) + strlen(desc) + 1;
|
||||
if (len > rsd->maxcols) {
|
||||
out = malloc(rsd->maxcols);
|
||||
assert(out);
|
||||
snprintf(out, rsd->maxcols-2, "%s%s %s",
|
||||
inststr, tmp, desc);
|
||||
strncat(out, "...", rsd->maxcols);
|
||||
printf("%s\n", out);
|
||||
free(out);
|
||||
} else {
|
||||
printf("%s%s %s\n", inststr, tmp, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user