diff --git a/qpkg/prereq.c b/qpkg/prereq.c index 6dc98d4..b5962e6 100644 --- a/qpkg/prereq.c +++ b/qpkg/prereq.c @@ -171,6 +171,28 @@ static int conflicts(const struct pkg *pkg, const struct list *conf) } +static void print_debug(const struct pkg *pkg, const struct stack *top, + int level) +{ + const struct stack *p; + + fprintf(stderr, "%*s", level, ""); + fprintf(stderr, "%.*s %p", ID2PF(pkg->id), pkg); + if (pkg->version) + fprintf(stderr, " %.*s", ID2PF(pkg->version)); + fprintf(stderr, " ("); + for (p = top; p; p = p->next) + fprintf(stderr, "%s%.*s", + p == top ? "" : " ", ID2PF(p->pkg->id)); + fprintf(stderr, ")"); + if (pkg->mark) + fprintf(stderr, " +"); + if (pkg->flags & QPKG_INSTALLED) + fprintf(stderr, " ***"); + fprintf(stderr, "\n"); +} + + static void resolve(struct list *next_dep, const struct ref *dep, struct stack *top, struct list *conf) { @@ -196,24 +218,8 @@ static void resolve(struct list *next_dep, const struct ref *dep, for (pkg = dep->pkg->jrb->val; pkg; pkg = pkg->more) { if (best && n_install == n_best) return; - if (debug) { - struct stack *p; - - fprintf(stderr, "%*s", level, ""); - fprintf(stderr, "%.*s %p", ID2PF(pkg->id), pkg); - if (pkg->version) - fprintf(stderr, " %.*s", ID2PF(pkg->version)); - fprintf(stderr, " ("); - for (p = top; p; p = p->next) - fprintf(stderr, "%s%.*s", - p == top ? "" : " ", ID2PF(p->pkg->id)); - fprintf(stderr, ")"); - if (pkg->mark) - fprintf(stderr, " +"); - if (pkg->flags & QPKG_INSTALLED) - fprintf(stderr, " ***"); - fprintf(stderr, "\n"); - } + if (debug) + print_debug(pkg, top, level); if (!satisfies(pkg, dep)) continue; if (pkg->flags & QPKG_ADDING) {