aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-09-09 20:06:10 +0300
committerTimo Teräs <timo.teras@iki.fi>2011-09-09 20:06:10 +0300
commitbfd53b59d2e62e17e95df3f3d2948d2bb806db71 (patch)
treefce16bd37b2b752fe1dc4fa47bcd50e0d44a63e9 /src/print.c
parent4bf13c3d9a58d4f1685401c3569abb40c5649ca3 (diff)
downloadaports-bfd53b59d2e62e17e95df3f3d2948d2bb806db71.tar.bz2
aports-bfd53b59d2e62e17e95df3f3d2948d2bb806db71.tar.xz
print: minor cleanup to indented writer
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/print.c b/src/print.c
index e673f1293a..732ede95b3 100644
--- a/src/print.c
+++ b/src/print.c
@@ -41,11 +41,12 @@ int apk_get_screen_width(void)
int apk_print_indented(struct apk_indent *i, apk_blob_t blob)
{
- if (i->x + blob.len + 1 >= apk_get_screen_width()) {
- i->x = i->indent;
- printf("\n%*s", i->indent - 1, "");
- }
- i->x += printf(" " BLOB_FMT, BLOB_PRINTF(blob));
+ if (i->x + blob.len + 1 >= apk_get_screen_width())
+ i->x = printf("\n%*s" BLOB_FMT, i->indent, "", BLOB_PRINTF(blob)) - 1;
+ else if (i->x <= i->indent)
+ i->x += printf("%*s" BLOB_FMT, i->indent - i->x, "", BLOB_PRINTF(blob));
+ else
+ i->x += printf(" " BLOB_FMT, BLOB_PRINTF(blob));
return 0;
}