xbps-query: in search mode also count blanks for the output string.

This commit is contained in:
Juan RP 2013-02-28 16:07:11 +01:00
parent 8b5f6d7b65
commit 7e171b67cf

View File

@ -79,13 +79,13 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
else else
inststr = "[-]"; inststr = "[-]";
len = strlen(inststr) + strlen(tmp) + strlen(desc) + 1; len = strlen(inststr) + strlen(tmp) + strlen(desc) + 3;
if (len > sd->maxcols) { if (len > sd->maxcols) {
out = malloc(sd->maxcols+1); out = malloc(sd->maxcols+1);
assert(out); assert(out);
snprintf(out, sd->maxcols, "%s %s %s", snprintf(out, sd->maxcols-3, "%s %s %s",
inststr, tmp, desc); inststr, tmp, desc);
strncat(out, "...\n", sd->maxcols - 4); strncat(out, "...\n", sd->maxcols);
printf("%s", out); printf("%s", out);
free(out); free(out);
} else { } else {