The following commit has been merged in the master branch:
commit 1baad8809039eb52113f2e647800cccf77168349
Author: Guillem Jover <[email protected]>
Date:   Fri Feb 4 05:50:43 2011 +0100

    dselect: Switch to use libdpkg debug support

diff --git a/dselect/basecmds.cc b/dselect/basecmds.cc
index f14e38c..d973f8c 100644
--- a/dselect/basecmds.cc
+++ b/dselect/basecmds.cc
@@ -85,7 +85,7 @@ void baselist::kd_redraw() {
 //  RFSH(whatinfowin); /* FIXME: why does ncurses need this? */
   clearok(curscr,TRUE);
   redrawall();
-  if (debug) fprintf(debug,"baselist[%p]::kd_redraw() done\n",this);
+  debug(dbg_general, "baselist[%p]::kd_redraw() done", this);
 }
 
 void baselist::kd_searchagain() {
diff --git a/dselect/baselist.cc b/dselect/baselist.cc
index e833f7b..d272c10 100644
--- a/dselect/baselist.cc
+++ b/dselect/baselist.cc
@@ -50,7 +50,7 @@ void mywerase(WINDOW *win) {
 baselist *baselist::signallist= 0;
 void baselist::sigwinchhandler(int) {
   struct winsize size;
-  if (debug) fprintf(debug,"baselist::sigwinchhandler(), 
signallist=%p\n",signallist);
+  debug(dbg_general, "baselist::sigwinchhandler(), signallist=%p", signallist);
   baselist *p= signallist;
   p->enddisplay();
   endwin(); initscr();
@@ -113,7 +113,7 @@ void baselist::setheights() {
 }
 
 void baselist::startdisplay() {
-  if (debug) fprintf(debug,"baselist[%p]::startdisplay()\n",this);
+  debug(dbg_general, "baselist[%p]::startdisplay()", this);
   cbreak(); noecho(); nonl(); keypad(stdscr,TRUE);
   clear(); wnoutrefresh(stdscr);
 
@@ -199,20 +199,16 @@ void baselist::startdisplay() {
 
   redrawall();
 
-  if (debug)
-    fprintf(debug,
-            "baselist::startdisplay() done ...\n\n"
-            " xmax=%d, ymax=%d;\n\n"
-            " title_height=%d, colheads_height=%d, list_height=%d;\n"
-            " thisstate_height=%d, info_height=%d, whatinfo_height=%d;\n\n"
-            " colheads_row=%d, thisstate_row=%d, info_row=%d;\n"
-            " whatinfo_row=%d, list_row=%d;\n\n",
-            xmax, ymax,
-            title_height, colheads_height, list_height,
-            thisstate_height, info_height, whatinfo_height,
-            colheads_row, thisstate_row, info_row,
-            whatinfo_row, list_row);
-
+  debug(dbg_general,
+        "baselist::startdisplay() done ...\n\n"
+        " xmax=%d, ymax=%d;\n\n"
+        " title_height=%d, colheads_height=%d, list_height=%d;\n"
+        " thisstate_height=%d, info_height=%d, whatinfo_height=%d;\n\n"
+        " colheads_row=%d, thisstate_row=%d, info_row=%d;\n"
+        " whatinfo_row=%d, list_row=%d;\n\n",
+        xmax, ymax, title_height, colheads_height, list_height,
+        thisstate_height, info_height, whatinfo_height,
+        colheads_row, thisstate_row, info_row, whatinfo_row, list_row);
 }
 
 void baselist::enddisplay() {
@@ -241,8 +237,7 @@ void baselist::redraw1item(int index) {
 }
 
 baselist::baselist(keybindings *kb) {
-  if (debug)
-    fprintf(debug,"baselist[%p]::baselist()\n",this);
+  debug(dbg_general, "baselist[%p]::baselist()", this);
 
   bindings= kb;
   nitems= 0;
@@ -279,8 +274,8 @@ void baselist::itd_keys() {
 
 void baselist::dosearch() {
   int offset, index;
-  if (debug) fprintf(debug,"baselist[%p]::dosearch(); searchstring=`%s'\n",
-                     this,searchstring);
+  debug(dbg_general, "baselist[%p]::dosearch(); searchstring='%s'",
+        this, searchstring);
   for (offset = 1, index = max(topofscreen, cursorline + 1);
        offset<nitems;
        offset++, index++) {
@@ -321,7 +316,7 @@ void baselist::refreshinfo() {
 
 void baselist::wordwrapinfo(int offset, const char *m) {
   int usemax= xmax-5;
-  if (debug) fprintf(debug,"baselist[%p]::wordwrapinfo(%d, 
`%s')\n",this,offset,m);
+  debug(dbg_general, "baselist[%p]::wordwrapinfo(%d, '%s')", this, offset, m);
   int wrapping=0;
   for (;;) {
     int offleft=offset; while (*m == ' ' && offleft>0) { m++; offleft--; }
@@ -372,7 +367,7 @@ void baselist::wordwrapinfo(int offset, const char *m) {
     }
     m= ++p;
   }
-  if (debug) fprintf(debug,"baselist[%p]::wordwrapinfo() done\n",this);
+  debug(dbg_general, "baselist[%p]::wordwrapinfo() done", this);
 }
 
 baselist::~baselist() { }
diff --git a/dselect/dselect.h b/dselect/dselect.h
index e4434e6..6667d65 100644
--- a/dselect/dselect.h
+++ b/dselect/dselect.h
@@ -29,6 +29,8 @@
 using std::min;
 using std::max;
 
+#include <dpkg/debug.h>
+
 #include "dselect-curses.h"
 
 #define DSELECT                "dselect"
@@ -147,7 +149,6 @@ void curseson();
 void cursesoff();
 
 extern const char *admindir;
-extern FILE *debug;
 extern int expertmode;
 
 enum screenparts {
diff --git a/dselect/main.cc b/dselect/main.cc
index 9697e80..9559155 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -62,7 +62,6 @@ const char printforhelp[]= N_("Type dselect --help for 
help.");
 
 modstatdb_rw readwrite;
 const char *admindir= ADMINDIR;
-FILE *debug;
 int expertmode= 0;
 
 static keybindings 
packagelistbindings(packagelist_kinterps,packagelist_korgbindings);
@@ -227,9 +226,15 @@ usage(const struct cmdinfo *ci, const char *value)
 extern "C" {
 
   static void setdebug(const struct cmdinfo*, const char *v) {
-    debug= fopen(v,"a");
-    if (!debug) ohshite(_("couldn't open debug file `%.255s'\n"),v);
-    setvbuf(debug,0,_IONBF,0);
+    FILE *fp;
+
+    fp = fopen(v, "a");
+    if (!fp)
+      ohshite(_("couldn't open debug file `%.255s'\n"), v);
+    setvbuf(fp, 0, _IONBF, 0);
+
+    debug_set_output(fp);
+    debug_set_mask(dbg_general | dbg_depcon);
   }
 
   static void setexpert(const struct cmdinfo*, const char *v) {
diff --git a/dselect/methlist.cc b/dselect/methlist.cc
index 7096be9..c7f3abf 100644
--- a/dselect/methlist.cc
+++ b/dselect/methlist.cc
@@ -45,19 +45,19 @@ const char *methodlist::itemname(int index) {
 void methodlist::kd_abort() { }
 
 void methodlist::kd_quit() {
-  if (debug) fprintf(debug,"methodlist[%p]::kd_quit() setting coption=%p\n",
-                     this, table[cursorline]);
+  debug(dbg_general, "methodlist[%p]::kd_quit() setting coption=%p",
+        this, table[cursorline]);
   coption= table[cursorline];
 }
 
 void methodlist::setheights() {
-  if (debug) fprintf(debug,"methodlist[%p]::setheights()\n",this);
+  debug(dbg_general, "methodlist[%p]::setheights()", this);
   baselist::setheights();
   list_height++;
 }
 
 void methodlist::setwidths() {
-  if (debug) fprintf(debug,"methodlist[%p]::setwidths()\n",this);
+  debug(dbg_general, "methodlist[%p]::setwidths()", this);
 
   status_width= 1;
   gap_width= 1;
@@ -126,8 +126,7 @@ void methodlist::redrawcolheads() {
 methodlist::methodlist() : baselist(&methodlistbindings) {
   int newcursor= -1;
 
-  if (debug)
-    fprintf(debug,"methodlist[%p]::methodlist()\n",this);
+  debug(dbg_general, "methodlist[%p]::methodlist()", this);
 
   table= new struct dselect_option*[noptions];
 
@@ -141,12 +140,12 @@ methodlist::methodlist() : baselist(&methodlistbindings) {
   if (newcursor==-1) newcursor= 0;
   setcursor(newcursor);
 
-  if (debug)
-    fprintf(debug,"methodlist[%p]::methodlist done; noptions=%d\n", this, 
noptions);
+  debug(dbg_general, "methodlist[%p]::methodlist done; noptions=%d",
+        this, noptions);
 }
 
 methodlist::~methodlist() {
-  if (debug) fprintf(debug,"methodlist[%p]::~methodlist()\n",this);
+  debug(dbg_general, "methodlist[%p]::~methodlist()", this);
   delete[] table;
 }
 
@@ -154,12 +153,12 @@ quitaction methodlist::display() {
   int response;
   const keybindings::interpretation *interp;
 
-  if (debug) fprintf(debug,"methodlist[%p]::display()\n",this);
+  debug(dbg_general, "methodlist[%p]::display()", this);
 
   setupsigwinch();
   startdisplay();
 
-  if (debug) fprintf(debug,"methodlist[%p]::display() entering loop\n",this);
+  debug(dbg_general, "methodlist[%p]::display() entering loop", this);
   for (;;) {
     if (whatinfo_height) wcursyncup(whatinfowin);
     if (doupdate() == ERR) ohshite(_("doupdate failed"));
@@ -171,9 +170,8 @@ quitaction methodlist::display() {
     if (sigprocmask(SIG_BLOCK,&sigwinchset,0)) ohshite(_("failed to re-block 
SIGWINCH"));
     if (response == ERR) ohshite(_("getch failed"));
     interp= (*bindings)(response);
-    if (debug)
-      fprintf(debug,"methodlist[%p]::display() response=%d interp=%s\n",
-              this,response, interp ? interp->action : "[none]");
+    debug(dbg_general, "methodlist[%p]::display() response=%d interp=%s",
+          this, response, interp ? interp->action : "[none]");
     if (!interp) { beep(); continue; }
     (this->*(interp->mfn))();
     if (interp->qa != qa_noquit) break;
@@ -181,7 +179,7 @@ quitaction methodlist::display() {
   pop_cleanup(ehflag_normaltidy); // unset the SIGWINCH handler
   enddisplay();
 
-  if (debug) fprintf(debug,"methodlist[%p]::display() done\n",this);
+  debug(dbg_general, "methodlist[%p]::display() done", this);
 
   return interp->qa;
 }
@@ -206,7 +204,7 @@ void methodlist::redrawinfo() {
   whatinfovb.reset();
   werase(infopad); wmove(infopad,0,0);
 
-  if (debug) fprintf(debug,"methodlist[%p]::redrawinfo()\n", this);
+  debug(dbg_general, "methodlist[%p]::redrawinfo()", this);
 
   itd_description();
 
diff --git a/dselect/methparse.cc b/dselect/methparse.cc
index 1c128be..c8fd7c4 100644
--- a/dselect/methparse.cc
+++ b/dselect/methparse.cc
@@ -90,12 +90,12 @@ void readmethods(const char *pathbase, dselect_option 
**optionspp, int *nread) {
     ohshite(_("unable to read `%.250s' directory for reading 
methods"),pathbuf);
   }
 
-  if (debug) fprintf(debug,"readmethods(`%s',...) directory open\n", pathbase);
+  debug(dbg_general, "readmethods('%s',...) directory open", pathbase);
 
   while ((dent= readdir(dir)) != 0) {
     c= dent->d_name[0];
-    if (debug) fprintf(debug,"readmethods(`%s',...) considering `%s' ...\n",
-                       pathbase,dent->d_name);
+    debug(dbg_general, "readmethods('%s',...) considering '%s' ...",
+          pathbase, dent->d_name);
     if (c != '_' && !isalpha(c)) continue;
     char *p = dent->d_name + 1;
     while ((c = *p) != 0 && isalnum(c) && c != '_')
@@ -116,7 +116,7 @@ void readmethods(const char *pathbase, dselect_option 
**optionspp, int *nread) {
       if (access(pathbuf,R_OK|X_OK))
         ohshite(_("unable to access method script `%.250s'"),pathbuf);
     }
-    if (debug) fprintf(debug," readmethods(`%s',...) scripts ok\n", pathbase);
+    debug(dbg_general, " readmethods('%s',...) scripts ok", pathbase);
 
     strcpy(pathinmeth,METHODOPTIONSFILE);
     names= fopen(pathbuf,"r");
@@ -134,9 +134,9 @@ void readmethods(const char *pathbase, dselect_option 
**optionspp, int *nread) {
     if (methods)
       methods->prev = meth;
     methods= meth;
-    if (debug) fprintf(debug," readmethods(`%s',...) new method"
-                       " name=`%s' path=`%s' pathinmeth=`%s'\n",
-                       pathbase, meth->name, meth->path, meth->pathinmeth);
+    debug(dbg_general, " readmethods('%s',...) new method"
+                       " name='%s' path='%s' pathinmeth='%s'",
+          pathbase, meth->name, meth->path, meth->pathinmeth);
 
     while ((c= fgetc(names)) != EOF) {
       if (isspace(c)) continue;
@@ -203,15 +203,15 @@ void readmethods(const char *pathbase, dselect_option 
**optionspp, int *nread) {
       }
       strcpy(pathinmeth,METHODOPTIONSFILE);
 
-      if (debug) fprintf(debug," readmethods(`%s',...) new option"
-                         " index=`%s' name=`%s' summary=`%.20s'"
-                         " strlen(description=%s)=%ld"
-                         " method name=`%s' path=`%s' pathinmeth=`%s'\n",
-                         pathbase,
-                         opt->index, opt->name, opt->summary,
-                         opt->description ? "`...'" : "null",
-                         opt->description ? (long) strlen(opt->description) : 
-1,
-                         opt->meth->name, opt->meth->path, 
opt->meth->pathinmeth);
+      debug(dbg_general,
+            " readmethods('%s',...) new option index='%s' name='%s'"
+            " summary='%.20s' strlen(description=%s)=%ld method name='%s'"
+            " path='%s' pathinmeth='%s'",
+            pathbase,
+            opt->index, opt->name, opt->summary,
+            opt->description ? "'...'" : "null",
+            opt->description ? (long)strlen(opt->description) : -1,
+            opt->meth->name, opt->meth->path, opt->meth->pathinmeth);
 
       dselect_option **optinsert = optionspp;
       while (*optinsert && strcmp(opt->index, (*optinsert)->index) > 0)
@@ -225,7 +225,7 @@ void readmethods(const char *pathbase, dselect_option 
**optionspp, int *nread) {
     fclose(names);
   }
   closedir(dir);
-  if (debug) fprintf(debug,"readmethods(`%s',...) done\n", pathbase);
+  debug(dbg_general, "readmethods('%s',...) done", pathbase);
   delete[] pathbuf;
 }
 
@@ -251,30 +251,30 @@ void getcurrentopt() {
     if (errno == ENOENT) return;
     ohshite(_("unable to open current option file `%.250s'"),methoptfile);
   }
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt open\n");
+  debug(dbg_general, "getcurrentopt() cmethopt open");
   if (!fgets(methoptbuf,sizeof(methoptbuf),cmo)) { fclose(cmo); return; }
   if (fgetc(cmo) != EOF) { fclose(cmo); return; }
   if (!feof(cmo)) { fclose(cmo); return; }
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt eof\n");
+  debug(dbg_general, "getcurrentopt() cmethopt eof");
   fclose(cmo);
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt read\n");
+  debug(dbg_general, "getcurrentopt() cmethopt read");
   l= strlen(methoptbuf);  if (!l || methoptbuf[l-1] != '\n') return;
   methoptbuf[--l]= 0;
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt len and newline\n");
+  debug(dbg_general, "getcurrentopt() cmethopt len and newline");
   p= strchr(methoptbuf,' ');  if (!p) return;
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt space\n");
+  debug(dbg_general, "getcurrentopt() cmethopt space");
   *p++= 0;
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt meth name `%s'\n", 
methoptbuf);
+  debug(dbg_general, "getcurrentopt() cmethopt meth name '%s'", methoptbuf);
   method *meth = methods;
   while (meth && strcmp(methoptbuf, meth->name))
     meth = meth->next;
   if (!meth) return;
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt meth found; opt 
`%s'\n",p);
+  debug(dbg_general, "getcurrentopt() cmethopt meth found; opt '%s'", p);
   dselect_option *opt = options;
   while (opt && (opt->meth != meth || strcmp(p, opt->name)))
     opt = opt->next;
   if (!opt) return;
-  if (debug) fprintf(debug,"getcurrentopt() cmethopt opt found\n");
+  debug(dbg_general, "getcurrentopt() cmethopt opt found");
   coption= opt;
 }
 
diff --git a/dselect/pkgcmds.cc b/dselect/pkgcmds.cc
index adb700c..3601b07 100644
--- a/dselect/pkgcmds.cc
+++ b/dselect/pkgcmds.cc
@@ -143,8 +143,8 @@ void packagelist::kd_purge()    { 
setwant(pkginfo::want_purge);     }
 
 int would_like_to_install(pkginfo::pkgwant wantvalue, pkginfo *pkg) {
   /* Returns: 1 for yes, 0 for no, -1 for if they want to preserve an error 
condition. */
-  if (debug) fprintf(debug,"would_like_to_install(%d, %s) status %d\n",
-                     wantvalue,pkg->name,pkg->status);
+  debug(dbg_general, "would_like_to_install(%d, %s) status %d",
+        wantvalue, pkg->name, pkg->status);
 
   if (wantvalue == pkginfo::want_install) return 1;
   if (wantvalue != pkginfo::want_hold) return 0;
diff --git a/dselect/pkgdepcon.cc b/dselect/pkgdepcon.cc
index 1489389..71f44a0 100644
--- a/dselect/pkgdepcon.cc
+++ b/dselect/pkgdepcon.cc
@@ -31,8 +31,6 @@
 #include "dselect.h"
 #include "pkglist.h"
 
-static const int depdebug= 1;
-
 bool
 packagelist::useavailable(pkginfo *pkg)
 {
@@ -53,9 +51,8 @@ packagelist::find_pkgbin(pkginfo *pkg)
 {
   pkgbin *r;
   r= useavailable(pkg) ? &pkg->available : &pkg->installed;
-  if (debug)
-    fprintf(debug, "packagelist[%p]::find_pkgbin(%s) useavailable=%d\n",
-            this, pkg->name, useavailable(pkg));
+  debug(dbg_general, "packagelist[%p]::find_pkgbin(%s) useavailable=%d",
+        this, pkg->name, useavailable(pkg));
 
   return r;
 }
@@ -81,8 +78,7 @@ int packagelist::resolvesuggest() {
   // only change the `suggested' value if we also increase the `priority'
   // Return 2 if we made a change due to a Recommended, Depends or Conficts,
   // or 1 if we offered or made a change because of an Optional line.
-  if (debug)
-    fprintf(debug,"packagelist[%p]::resolvesuggest()\n",this);
+  debug(dbg_general, "packagelist[%p]::resolvesuggest()", this);
   int changemade, maxchangemade;
   maxchangemade= 0;
   for (;;) {
@@ -90,9 +86,8 @@ int packagelist::resolvesuggest() {
     int index;
     for (index=0; index<nitems; index++) {
       if (!table[index]->pkg->name) continue;
-      if (depdebug && debug)
-        fprintf(debug,"packagelist[%p]::resolvesuggest() loop[%i] %s / %d\n",
-                this, index, table[index]->pkg->name, changemade);
+      debug(dbg_depcon, "packagelist[%p]::resolvesuggest() loop[%i] %s / %d",
+            this, index, table[index]->pkg->name, changemade);
       dependency *depends;
       for (depends = find_pkgbin(table[index]->pkg)->depends;
            depends;
@@ -106,16 +101,14 @@ int packagelist::resolvesuggest() {
         if (depends->type != dep_provides) continue;
         changemade= checkdependers(depends->list->ed,changemade);
       }
-      if (depdebug && debug)
-        fprintf(debug,"packagelist[%p]::resolvesuggest() loop[%i] %s / -> 
%d\n",
-                this, index, table[index]->pkg->name, changemade);
+      debug(dbg_depcon, "packagelist[%p]::resolvesuggest() loop[%i] %s / -> 
%d",
+            this, index, table[index]->pkg->name, changemade);
     }
     if (!changemade) break;
     maxchangemade = max(maxchangemade, changemade);
   }
-  if (debug)
-    fprintf(debug,"packagelist[%p]::resolvesuggest() done; maxchangemade=%d\n",
-            this,maxchangemade);
+  debug(dbg_general, "packagelist[%p]::resolvesuggest() done; 
maxchangemade=%d",
+        this, maxchangemade);
   return maxchangemade;
 }
 
@@ -123,10 +116,9 @@ static int dep_update_best_to_change_stop(perpackagestate 
*& best, pkginfo *tryt
   // There's no point trying to select a pure virtual package.
   if (!trythis->clientdata) return 0;
 
-  if (depdebug && debug)
-    fprintf(debug,"update_best_to_change(best=%s{%d}, test=%s{%d});\n",
-            best ? best->pkg->name : "", best ? (int)best->spriority : -1,
-            trythis->name, trythis->clientdata->spriority);
+  debug(dbg_depcon, "update_best_to_change(best=%s{%d}, test=%s{%d});",
+        best ? best->pkg->name : "", best ? (int)best->spriority : -1,
+        trythis->name, trythis->clientdata->spriority);
 
   // If the problem is caused by us deselecting one of these packages
   // we should not try to select another one instead.
@@ -156,7 +148,7 @@ static int dep_update_best_to_change_stop(perpackagestate 
*& best, pkginfo *tryt
   return 0;
 
  yes:
-  if (depdebug && debug) fprintf(debug,"update_best_to_change(); yes\n");
+  debug(dbg_depcon, "update_best_to_change(); yes");
 
   best=trythis->clientdata; return 0;
 }
@@ -175,9 +167,9 @@ packagelist::deselect_one_of(pkginfo *per, pkginfo *ped, 
dependency *dep)
   er= per->clientdata;  // these can be changed by add
   ed= ped->clientdata;
 
-  if (depdebug && debug)
-    fprintf(debug,"packagelist[%p]::deselect_one_of(): er %s{%d} ed %s{%d} 
[%p]\n",
-            this, er->pkg->name, er->spriority, ed->pkg->name, ed->spriority, 
dep);
+  debug(dbg_depcon,
+        "packagelist[%p]::deselect_one_of(): er %s{%d} ed %s{%d} [%p]",
+        this, er->pkg->name, er->spriority, ed->pkg->name, ed->spriority, dep);
 
   perpackagestate *best;
 
@@ -195,9 +187,8 @@ packagelist::deselect_one_of(pkginfo *per, pkginfo *ped, 
dependency *dep)
     best = ed;
   else best= ed;                                      // ... failing that, the 
second
 
-  if (depdebug && debug)
-    fprintf(debug,"packagelist[%p]::deselect_one_of(): best %s{%d}\n",
-            this, best->pkg->name, best->spriority);
+  debug(dbg_depcon, "packagelist[%p]::deselect_one_of(): best %s{%d}",
+        this, best->pkg->name, best->spriority);
 
   if (best->spriority >= sp_deselecting) return 0;
   best->suggested=
@@ -214,15 +205,19 @@ int packagelist::resolvedepcon(dependency *depends) {
   deppossi *possi, *provider;
   int r, foundany;
 
-  if (depdebug && debug) {
-    fprintf(debug,"packagelist[%p]::resolvedepcon([%p] %s --%s-->",
-            this, depends, depends->up->name, relatestrings[depends->type]);
-    for (possi=depends->list; possi; possi=possi->next)
-      fprintf(debug," %s",possi->ed->name);
-    fprintf(debug,"); (ing)->want=%s\n",
-            depends->up->clientdata
-            ? wantstrings[depends->up->clientdata->suggested]
-            : "(no clientdata)");
+  if (debug_has_flag(dbg_depcon)) {
+    varbuf pkg_names;
+
+    for (possi = depends->list; possi; possi = possi->next) {
+      pkg_names(' ');
+      pkg_names(possi->ed->name);
+    }
+
+    debug(dbg_depcon,
+          "packagelist[%p]::resolvedepcon([%p] %s --%s-->%s); (ing)->want=%s",
+          this, depends, depends->up->name, relatestrings[depends->type],
+          pkg_names.string(), depends->up->clientdata ?
+          wantstrings[depends->up->clientdata->suggested] : "(no clientdata)");
   }
 
   if (!depends->up->clientdata) return 0;
@@ -246,10 +241,8 @@ int packagelist::resolvedepcon(dependency *depends) {
     possi = depends->list;
     while (possi && !deppossatisfied(possi, &fixbyupgrade))
       possi = possi->next;
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): depends found %s\n",
-              this,depends,
-              possi ? possi->ed->name : "[none]");
+    debug(dbg_depcon, "packagelist[%p]::resolvedepcon([%p]): depends found %s",
+          this, depends, possi ? possi->ed->name : "[none]");
     if (possi) return 0;
 
     // Ensures all in the recursive list; adds info strings; ups priorities
@@ -266,8 +259,9 @@ int packagelist::resolvedepcon(dependency *depends) {
     }
 
     if (fixbyupgrade) {
-      if (depdebug && debug) 
fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
-                            "fixbyupgrade %s\n", 
this,depends,fixbyupgrade->pkg->name);
+      debug(dbg_depcon,
+            "packagelist[%p]::resolvedepcon([%p]): fixbyupgrade %s",
+            this, depends, fixbyupgrade->pkg->name);
       best= fixbyupgrade;
     } else {
       best= 0;
@@ -287,14 +281,15 @@ int packagelist::resolvedepcon(dependency *depends) {
         if (!foundany) addunavailable(possi);
       }
       if (!best) {
-        if (depdebug && debug) 
fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
-                              "mustdeselect nobest\n", this,depends);
+        debug(dbg_depcon,
+              "packagelist[%p]::resolvedepcon([%p]): mustdeselect nobest",
+              this, depends);
         return r;
       }
     }
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): select 
best=%s{%d}\n",
-              this,depends, best->pkg->name, best->spriority);
+    debug(dbg_depcon,
+          "packagelist[%p]::resolvedepcon([%p]): select best=%s{%d}",
+          this, depends, best->pkg->name, best->spriority);
     if (best->spriority >= sp_selecting) return r;
     /* Always select depends. Only select recommends if we got here because
      * of a manually-initiated install request. */
@@ -306,9 +301,9 @@ int packagelist::resolvedepcon(dependency *depends) {
 
   mustdeselect:
     best= depends->up->clientdata;
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): mustdeselect 
best=%s{%d}\n",
-              this,depends, best->pkg->name, best->spriority);
+    debug(dbg_depcon,
+          "packagelist[%p]::resolvedepcon([%p]): mustdeselect best=%s{%d}",
+          this, depends, best->pkg->name, best->spriority);
 
     if (best->spriority >= sp_deselecting) return r;
     /* Always remove depends, but never remove recommends. */
@@ -322,23 +317,21 @@ int packagelist::resolvedepcon(dependency *depends) {
 
   case dep_conflicts:
   case dep_breaks:
-
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): conflict\n",
-              this,depends);
+    debug(dbg_depcon, "packagelist[%p]::resolvedepcon([%p]): conflict",
+          this, depends);
 
     if (would_like_to_install(depends->up->clientdata->selected,depends->up) 
== 0)
       return 0;
 
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): conflict installing 
1\n",
-              this,depends);
+    debug(dbg_depcon,
+          "packagelist[%p]::resolvedepcon([%p]): conflict installing 1",
+          this, depends);
 
     if (!deppossatisfied(depends->list,0)) return 0;
 
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): conflict satisfied 
- ouch\n",
-              this,depends);
+    debug(dbg_depcon,
+          "packagelist[%p]::resolvedepcon([%p]): conflict satisfied - ouch",
+          this, depends);
 
     if (depends->up != depends->list->ed) {
       r= deselect_one_of(depends->up, depends->list->ed, depends);  if (r) 
return r;
@@ -350,8 +343,8 @@ int packagelist::resolvedepcon(dependency *depends) {
       if (provider->up->up == depends->up) continue; // conflicts & provides 
same thing
       r= deselect_one_of(depends->up, provider->up->up, depends);  if (r) 
return r;
     }
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): no desel\n", 
this,depends);
+    debug(dbg_depcon, "packagelist[%p]::resolvedepcon([%p]): no desel",
+          this, depends);
     return 0;
 
   default:
diff --git a/dselect/pkgdisplay.cc b/dselect/pkgdisplay.cc
index fa45dc5..bf370a8 100644
--- a/dselect/pkgdisplay.cc
+++ b/dselect/pkgdisplay.cc
@@ -130,7 +130,7 @@ static int maximumstring(const char *const *array) {
 }
 
 void packagelist::setwidths() {
-  if (debug) fprintf(debug,"packagelist[%p]::setwidths()\n",this);
+  debug(dbg_general, "packagelist[%p]::setwidths()", this);
 
   if (verbose) {
     status_hold_width= 9;
diff --git a/dselect/pkginfo.cc b/dselect/pkginfo.cc
index cfa3354..a704d7e 100644
--- a/dselect/pkginfo.cc
+++ b/dselect/pkginfo.cc
@@ -93,8 +93,8 @@ void packagelist::itd_relations() {
   whatinfovb(_("Interrelationships"));
 
   if (table[cursorline]->pkg->name) {
-    if (debug) fprintf(debug,"packagelist[%p]::idt_relations(); `%s'\n",
-                       this,table[cursorline]->relations.string());
+    debug(dbg_general, "packagelist[%p]::idt_relations(); '%s'",
+          this, table[cursorline]->relations.string());
     waddstr(infopad,table[cursorline]->relations.string());
   } else {
     severalinfoblurb();
@@ -136,8 +136,8 @@ void packagelist::itd_statuscontrol() {
     varbuf vb;
     
varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->installed);
     vb.terminate();
-    if (debug)
-      fprintf(debug,"packagelist[%p]::idt_statuscontrol(); 
`%s'\n",this,vb.string());
+    debug(dbg_general, "packagelist[%p]::idt_statuscontrol(); '%s'",
+          this, vb.string());
     waddstr(infopad,vb.string());
   }
 }
@@ -152,8 +152,8 @@ void packagelist::itd_availablecontrol() {
     varbuf vb;
     
varbufrecord(&vb,table[cursorline]->pkg,&table[cursorline]->pkg->available);
     vb.terminate();
-    if (debug)
-      fprintf(debug,"packagelist[%p]::idt_availablecontrol(); 
`%s'\n",this,vb.string());
+    debug(dbg_general, "packagelist[%p]::idt_availablecontrol(); '%s'",
+          this, vb.string());
     waddstr(infopad,vb.string());
   }
 }
@@ -169,9 +169,8 @@ void packagelist::redrawinfo() {
   whatinfovb.reset();
   werase(infopad); wmove(infopad,0,0);
 
-  if (debug)
-    fprintf(debug,"packagelist[%p]::redrawinfo(); #=%d\n", this,
-            (int)(currentinfo - baseinfo));
+  debug(dbg_general, "packagelist[%p]::redrawinfo(); #=%d",
+        this, (int)(currentinfo - baseinfo));
 
   (this->*currentinfo->display)();
   whatinfovb.terminate();
diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc
index 0b50ae8..c93adc3 100644
--- a/dselect/pkglist.cc
+++ b/dselect/pkglist.cc
@@ -118,10 +118,10 @@ void packagelist::addheading(enum ssavailval ssavail,
     table= newtable;
   }
 
-  if (debug) fprintf(debug,"packagelist[%p]::addheading(%d,%d,%d,%s,%s)\n",
-                     this,ssavail,ssstate,priority,
-                     otherpriority ? otherpriority : "<null>",
-                     section ? section : "<null>");
+  debug(dbg_general, "packagelist[%p]::addheading(%d,%d,%d,%s,%s)",
+        this, ssavail, ssstate, priority,
+        otherpriority ? otherpriority : "<null>",
+        section ? section : "<null>");
 
   struct pkginfo *newhead= new pkginfo;
   newhead->name= 0;
@@ -150,7 +150,7 @@ int qsort_compareentries(const void *a, const void *b) {
 void packagelist::sortinplace() {
   sortpackagelist= this;
 
-  if (debug) fprintf(debug,"packagelist[%p]::sortinplace()\n",this);
+  debug(dbg_general, "packagelist[%p]::sortinplace()", this);
   qsort(table, nitems, sizeof(struct pkgbin *), qsort_compareentries);
 }
 
@@ -160,21 +160,21 @@ void packagelist::ensurestatsortinfo() {
   struct pkginfo *pkg;
   int index;
 
-  if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() "
-                     "sortorder=%d nitems=%d\n",this,statsortorder,nitems);
+  debug(dbg_general,
+        "packagelist[%p]::ensurestatsortinfos() sortorder=%d nitems=%d",
+        this, statsortorder, nitems);
 
   switch (statsortorder) {
   case sso_unsorted:
-    if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() 
unsorted\n",this);
+    debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() unsorted", 
this);
     return;
   case sso_avail:
-    if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() 
calcssadone=%d\n",
-                       this,calcssadone);
+    debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() calcssadone=%d",
+          this, calcssadone);
     if (calcssadone) return;
     for (index=0; index < nitems; index++) {
-      if (debug)
-        fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s\n",
-                this,index,table[index]->pkg->name);
+      debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s",
+            this, index, table[index]->pkg->name);
       pkg= table[index]->pkg;
       switch (pkg->status) {
       case pkginfo::stat_unpacked:
@@ -212,20 +212,19 @@ void packagelist::ensurestatsortinfo() {
       default:
         internerr("unknown stat in ensurestatsortinfo sso_avail");
       }
-      if (debug)
-        fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d 
ssavail=%d\n",
-                this,index,table[index]->ssavail);
+      debug(dbg_general,
+            "packagelist[%p]::ensurestatsortinfos() i=%d ssavail=%d",
+            this, index, table[index]->ssavail);
     }
     calcssadone= 1;
     break;
   case sso_state:
-    if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() 
calcsssdone=%d\n",
-                       this,calcsssdone);
+    debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() calcsssdone=%d",
+          this, calcsssdone);
     if (calcsssdone) return;
     for (index=0; index < nitems; index++) {
-      if (debug)
-        fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s\n",
-                this,index,table[index]->pkg->name);
+      debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s",
+            this, index, table[index]->pkg->name);
       switch (table[index]->pkg->status) {
       case pkginfo::stat_unpacked:
       case pkginfo::stat_halfconfigured:
@@ -246,9 +245,9 @@ void packagelist::ensurestatsortinfo() {
       default:
         internerr("unknown stat in ensurestatsortinfo sso_state");
       }
-      if (debug)
-        fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d 
ssstate=%d\n",
-                this,index,table[index]->ssstate);
+      debug(dbg_general,
+            "packagelist[%p]::ensurestatsortinfos() i=%d ssstate=%d",
+            this, index, table[index]->ssstate);
     }
     calcsssdone= 1;
     break;
@@ -263,8 +262,9 @@ void packagelist::sortmakeheads() {
   sortinplace();
   assert(nitems);
 
-  if (debug) fprintf(debug,"packagelist[%p]::sortmakeheads() "
-                     "sortorder=%d 
statsortorder=%d\n",this,sortorder,statsortorder);
+  debug(dbg_general,
+        "packagelist[%p]::sortmakeheads() sortorder=%d statsortorder=%d",
+        this, sortorder, statsortorder);
 
   int nrealitems= nitems;
   addheading(ssa_none,sss_none,pkginfo::pri_unset,0,0);
@@ -308,20 +308,18 @@ void packagelist::sortmakeheads() {
                       strcasecmp(thispkg->section ? thispkg->section : "",
                                  lastpkg->section ? lastpkg->section : ""));
 
-    if (debug) fprintf(debug,"packagelist[%p]::sortmakeheads()"
-                       " pkg=%s  state=%d avail=%d %s  priority=%d"
-                       " otherpriority=%s %s  section=%s %s\n",
-                       this, thispkg->name,
-                       thispkg->clientdata->ssavail,
-                       thispkg->clientdata->ssstate,
-                       ssdiff ? "*diff" : "same",
-                       thispkg->priority,
-                       thispkg->priority != pkginfo::pri_other ? "<none>"
-                       : thispkg->otherpriority ? thispkg->otherpriority
-                       : "<null>",
-                       prioritydiff ? "*diff*" : "same",
-                       thispkg->section ? thispkg->section : "<null>",
-                       sectiondiff ? "*diff*" : "same");
+    debug(dbg_general,
+          "packagelist[%p]::sortmakeheads() pkg=%s  state=%d avail=%d %s  "
+          "priority=%d otherpriority=%s %s  section=%s %s",
+          this, thispkg->name,
+          thispkg->clientdata->ssavail, thispkg->clientdata->ssstate,
+          ssdiff ? "*diff" : "same",
+          thispkg->priority,
+          thispkg->priority != pkginfo::pri_other ? "<none>" :
+          thispkg->otherpriority ? thispkg->otherpriority : "<null>",
+          prioritydiff ? "*diff*" : "same",
+          thispkg->section ? thispkg->section : "<null>",
+          sectiondiff ? "*diff*" : "same");
 
     if (ssdiff)
       addheading(ssavail,ssstate,
@@ -351,8 +349,7 @@ void packagelist::sortmakeheads() {
 }
 
 void packagelist::initialsetup() {
-  if (debug)
-    fprintf(debug,"packagelist[%p]::initialsetup()\n",this);
+  debug(dbg_general, "packagelist[%p]::initialsetup()", this);
 
   int allpackages = pkg_db_count();
   datatable= new struct perpackagestate[allpackages];
@@ -372,9 +369,8 @@ void packagelist::initialsetup() {
 void packagelist::finalsetup() {
   setcursor(0);
 
-  if (debug)
-    fprintf(debug,"packagelist[%p]::finalsetup done; recursive=%d nitems=%d\n",
-            this, recursive, nitems);
+  debug(dbg_general, "packagelist[%p]::finalsetup done; recursive=%d 
nitems=%d",
+        this, recursive, nitems);
 }
 
 packagelist::packagelist(keybindings *kb) : baselist(kb) {
@@ -464,7 +460,7 @@ void perpackagestate::free(int recursive) {
 }
 
 packagelist::~packagelist() {
-  if (debug) fprintf(debug,"packagelist[%p]::~packagelist()\n",this);
+  debug(dbg_general, "packagelist[%p]::~packagelist()", this);
 
   if (searchstring[0])
     regfree(&searchfsm);
@@ -475,7 +471,7 @@ packagelist::~packagelist() {
   for (index=0; index<nitems; index++) table[index]->free(recursive);
   delete[] table;
   delete[] datatable;
-  if (debug) fprintf(debug,"packagelist[%p]::~packagelist() tables 
freed\n",this);
+  debug(dbg_general, "packagelist[%p]::~packagelist() tables freed", this);
 
   doneent *search, *next;
   for (search=depsdone; search; search=next) {
@@ -483,7 +479,7 @@ packagelist::~packagelist() {
     delete search;
   }
 
-  if (debug) fprintf(debug,"packagelist[%p]::~packagelist() done\n",this);
+  debug(dbg_general, "packagelist[%p]::~packagelist() done", this);
 }
 
 bool
@@ -561,7 +557,7 @@ pkginfo **packagelist::display() {
   const keybindings::interpretation *interp;
   pkginfo **retl;
 
-  if (debug) fprintf(debug,"packagelist[%p]::display()\n",this);
+  debug(dbg_general, "packagelist[%p]::display()", this);
 
   setupsigwinch();
   startdisplay();
@@ -569,7 +565,7 @@ pkginfo **packagelist::display() {
   if (!expertmode)
   displayhelp(helpmenulist(),'i');
 
-  if (debug) fprintf(debug,"packagelist[%p]::display() entering loop\n",this);
+  debug(dbg_general, "packagelist[%p]::display() entering loop", this);
   for (;;) {
     if (whatinfo_height) wcursyncup(whatinfowin);
     if (doupdate() == ERR)
@@ -585,9 +581,8 @@ pkginfo **packagelist::display() {
     if (response == ERR)
       ohshite(_("getch failed"));
     interp= (*bindings)(response);
-    if (debug)
-      fprintf(debug,"packagelist[%p]::display() response=%d interp=%s\n",
-              this,response, interp ? interp->action : "[none]");
+    debug(dbg_general, "packagelist[%p]::display() response=%d interp=%s",
+          this, response, interp ? interp->action : "[none]");
     if (!interp) { beep(); continue; }
     (this->*(interp->pfn))();
     if (interp->qa != qa_noquit) break;
@@ -596,7 +591,7 @@ pkginfo **packagelist::display() {
   enddisplay();
 
   if (interp->qa == qa_quitnochecksave || !readwrite) {
-    if (debug) fprintf(debug,"packagelist[%p]::display() done - 
quitNOcheck\n",this);
+    debug(dbg_general, "packagelist[%p]::display() done - quitNOcheck", this);
     return 0;
   }
 
@@ -604,7 +599,7 @@ pkginfo **packagelist::display() {
     retl= new pkginfo*[nitems+1];
     for (index=0; index<nitems; index++) retl[index]= table[index]->pkg;
     retl[nitems]= 0;
-    if (debug) fprintf(debug,"packagelist[%p]::display() done, 
retl=%p\n",this,retl);
+    debug(dbg_general, "packagelist[%p]::display() done, retl=%p", this, retl);
     return retl;
   } else {
     packagelist *sub= new packagelist(bindings,0);
@@ -612,8 +607,8 @@ pkginfo **packagelist::display() {
       if (table[index]->pkg->name)
         sub->add(table[index]->pkg);
     repeatedlydisplay(sub,dp_must);
-    if (debug)
-      fprintf(debug,"packagelist[%p]::display() done, not recursive no 
retl\n",this);
+    debug(dbg_general,
+          "packagelist[%p]::display() done, not recursive no retl", this);
     return 0;
   }
 }
diff --git a/dselect/pkgsublist.cc b/dselect/pkgsublist.cc
index d1a5f6e..e420392 100644
--- a/dselect/pkgsublist.cc
+++ b/dselect/pkgsublist.cc
@@ -33,12 +33,13 @@
 #include "bindings.h"
 
 void packagelist::add(pkginfo *pkg) {
-  if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo 
%s)\n",this,pkg->name);
+  debug(dbg_general, "packagelist[%p]::add(pkginfo %s)", this, pkg->name);
   if (!recursive ||  // never add things to top level
       !pkg->clientdata ||  // don't add pure virtual packages
       pkg->clientdata->uprec)  // don't add ones already in the recursive list
     return;
-  if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s) 
adding\n",this,pkg->name);
+  debug(dbg_general, "packagelist[%p]::add(pkginfo %s) adding",
+        this, pkg->name);
   perpackagestate *state= &datatable[nitems];
   state->pkg= pkg;
   state->direct= state->original= pkg->clientdata->selected;
@@ -52,23 +53,22 @@ void packagelist::add(pkginfo *pkg) {
 }
 
 void packagelist::add(pkginfo *pkg, pkginfo::pkgwant nw) {
-  if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s, %s)\n",
-                     this, pkg->name, wantstrings[nw]);
+  debug(dbg_general, "packagelist[%p]::add(pkginfo %s, %s)",
+        this, pkg->name, wantstrings[nw]);
   add(pkg);  if (!pkg->clientdata) return;
   pkg->clientdata->direct= nw;
   selpriority np;
   np= would_like_to_install(nw,pkg) ? sp_selecting : sp_deselecting;
   if (pkg->clientdata->spriority > np) return;
-  if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s, %s) setting\n",
-                     this, pkg->name, wantstrings[nw]);
+  debug(dbg_general, "packagelist[%p]::add(pkginfo %s, %s) setting",
+        this, pkg->name, wantstrings[nw]);
   pkg->clientdata->suggested= pkg->clientdata->selected= nw;
   pkg->clientdata->spriority= np;
 }
 
 void packagelist::add(pkginfo *pkg, const char *extrainfo, showpriority 
showimp) {
-  if (debug)
-    fprintf(debug,"packagelist[%p]::add(pkginfo %s, \"...\", showpriority 
%d)\n",
-            this,pkg->name,showimp);
+  debug(dbg_general, "packagelist[%p]::add(pkginfo %s, ..., showpriority %d)",
+        this, pkg->name, showimp);
   add(pkg);  if (!pkg->clientdata) return;
   if (pkg->clientdata->dpriority < showimp) pkg->clientdata->dpriority= 
showimp;
   pkg->clientdata->relations(extrainfo);
@@ -84,8 +84,8 @@ packagelist::alreadydone(doneent **done, void *check)
     search = search->next;
   if (search)
     return true;
-  if (debug) fprintf(debug,"packagelist[%p]::alreadydone(%p,%p) new\n",
-                     this,done,check);
+  debug(dbg_general, "packagelist[%p]::alreadydone(%p, %p) new",
+        this, done, check);
   search= new doneent;
   search->next= *done;
   search->dep= check;
@@ -94,7 +94,7 @@ packagelist::alreadydone(doneent **done, void *check)
 }
 
 void packagelist::addunavailable(deppossi *possi) {
-  if (debug) fprintf(debug,"packagelist[%p]::addunavail(%p)\n",this,possi);
+  debug(dbg_general, "packagelist[%p]::addunavail(%p)", this, possi);
 
   if (!recursive) return;
   if (alreadydone(&unavdone,possi)) return;
@@ -110,7 +110,7 @@ void packagelist::addunavailable(deppossi *possi) {
 bool
 packagelist::add(dependency *depends, showpriority displayimportance)
 {
-  if (debug) 
fprintf(debug,"packagelist[%p]::add(dependency[%p])\n",this,depends);
+  debug(dbg_general, "packagelist[%p]::add(dependency[%p])", this, depends);
 
   if (alreadydone(&depsdone, depends))
     return false;
@@ -166,30 +166,30 @@ void repeatedlydisplay(packagelist *sub,
   pkginfo **newl;
   keybindings *kb;
 
-  if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p])\n",sub);
+  debug(dbg_general, "repeatedlydisplay(packagelist[%p])", sub);
   if (sub->resolvesuggest() != 0 && sub->deletelessimp_anyleft(initial)) {
-    if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) once\n",sub);
+    debug(dbg_general, "repeatedlydisplay(packagelist[%p]) once", sub);
     if (unredisplay) unredisplay->enddisplay();
     for (;;) {
       manual_install = 0; /* Remove flag now that resolvesuggest has seen it. 
*/
       newl= sub->display();
       if (!newl) break;
-      if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) 
newl\n",sub);
+      debug(dbg_general, "repeatedlydisplay(packagelist[%p]) newl", sub);
       kb= sub->bindings; delete sub;
       sub= new packagelist(kb,newl);
       if (sub->resolvesuggest() <= 1) break;
       if (!sub->deletelessimp_anyleft(dp_must)) break;
-      if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) 
again\n",sub);
+      debug(dbg_general, "repeatedlydisplay(packagelist[%p]) again", sub);
     }
     if (unredisplay) unredisplay->startdisplay();
   }
-  if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) done\n",sub);
+  debug(dbg_general, "repeatedlydisplay(packagelist[%p]) done", sub);
   delete sub;
 }
 
 int packagelist::deletelessimp_anyleft(showpriority than) {
-  if (debug)
-    fprintf(debug,"packagelist[%p]::dli_al(%d): nitems=%d\n",this,than,nitems);
+  debug(dbg_general, "packagelist[%p]::dli_al(%d): nitems=%d",
+        this, than, nitems);
   int insat, runthr;
   for (runthr=0, insat=0;
        runthr < nitems;
@@ -202,7 +202,7 @@ int packagelist::deletelessimp_anyleft(showpriority than) {
     }
   }
   nitems= insat;
-  if (debug) fprintf(debug,"packagelist[%p]::dli_al(%d) done; nitems=%d\n",
-                     this,than,nitems);
+  debug(dbg_general, "packagelist[%p]::dli_al(%d) done; nitems=%d",
+        this, than, nitems);
   return nitems;
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to