From bfd53b59d2e62e17e95df3f3d2948d2bb806db71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Fri, 9 Sep 2011 20:06:10 +0300 Subject: print: minor cleanup to indented writer --- src/print.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/print.c') 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; } -- cgit v1.2.3