From d351992ad529dccb95fc1c8997cd328e9c694a92 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Mon, 27 Dec 2021 14:34:01 +0200 Subject: print: improve indented printing api - make sure all commit errors go to stderr - make it a bit more api like (cherry picked and rebased from commit a662047e2c43604bc087ec4dda9a7358368d850b) fixes #10879 --- src/app_del.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/app_del.c') diff --git a/src/app_del.c b/src/app_del.c index c8a9e36..7d3cf36 100644 --- a/src/app_del.c +++ b/src/app_del.c @@ -66,14 +66,10 @@ static void print_not_deleted_pkg(struct apk_package *pkg0, struct apk_dependenc apk_message("World updated, but the following packages are not removed due to:"); ctx->header = 1; } - if (!ctx->indent.indent) { - ctx->indent.x = printf(" %s:", ctx->name->name); - ctx->indent.indent = ctx->indent.x + 1; - } - - if (name_in_world(pkg0->name)) { + if (!ctx->indent.indent) + apk_print_indented_group(&ctx->indent, 0, " %s:", ctx->name->name); + if (name_in_world(pkg0->name)) apk_print_indented(&ctx->indent, APK_BLOB_STR(pkg0->name->name)); - } foreach_array_item(d, pkg0->provides) { if (!name_in_world(d->name)) continue; apk_print_indented(&ctx->indent, APK_BLOB_STR(d->name->name)); @@ -95,14 +91,13 @@ static void print_not_deleted_name(struct apk_database *db, const char *match, struct not_deleted_ctx *ctx = (struct not_deleted_ctx *) pctx; struct apk_provider *p; - ctx->indent.indent = 0; ctx->name = name; ctx->matches = apk_foreach_genid() | APK_FOREACH_MARKED | APK_DEP_SATISFIES; + apk_print_indented_init(&ctx->indent, 0); foreach_array_item(p, name->providers) if (p->pkg->marked) print_not_deleted_pkg(p->pkg, NULL, NULL, ctx); - if (ctx->indent.indent) - printf("\n"); + apk_print_indented_end(&ctx->indent); } static void delete_pkg(struct apk_package *pkg0, struct apk_dependency *dep0, -- cgit v1.2.3-60-g2f50