Procházet zdrojové kódy

Use consistent naming for linked lists members

Use next/prev instead of next/back (which would complement forward).
Also move next to the end of member names and seprate it with an
underscore, to simulate it being a sub struct member.
Guillem Jover před 16 roky
rodič
revize
b8799d9f10

+ 0 - 1
TODO

@@ -35,7 +35,6 @@ TODO
    - Cleanup status chars -> strings hardcoded mappings all over the place.
      (Fix tied field enum with its dselect description (pkgdisplay.cc))
    - Refactor src/processarc.c.
-   - Fix naming consistency of next/prev members.
    - Split dpkg.h into independent headers.
    - Do more unused header include removal.
    - Add needed includes to all header files.

+ 1 - 1
dselect/method.h

@@ -37,7 +37,7 @@
 #define OPTIONINDEXMAXLEN	5
 
 struct method {
-  struct method *next, *back;
+  struct method *next, *prev;
   char *name, *path, *pathinmeth;
 };
 

+ 3 - 2
dselect/methparse.cc

@@ -130,8 +130,9 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) {
     strcpy(meth->path+baselen+1+methodlen,"/");
     meth->pathinmeth= meth->path+baselen+1+methodlen+1;
     meth->next= methods;
-    meth->back= 0;
-    if (methods) methods->back= meth;
+    meth->prev = 0;
+    if (methods)
+      methods->prev = meth;
     methods= meth;
     if (debug) fprintf(debug," readmethods(`%s',...) new method"
                        " name=`%s' path=`%s' pathinmeth=`%s'\n",

+ 6 - 6
dselect/pkgdepcon.cc

@@ -60,12 +60,12 @@ pkginfoperfile *packagelist::findinfo(pkginfo *pkg) {
 int packagelist::checkdependers(pkginfo *pkg, int changemade) {
   struct deppossi *possi;
   
-  for (possi = pkg->available.depended; possi; possi = possi->nextrev) {
+  for (possi = pkg->available.depended; possi; possi = possi->rev_next) {
     if (!useavailable(possi->up->up))
       continue;
     changemade = max(changemade, resolvedepcon(possi->up));
   }
-  for (possi = pkg->installed.depended; possi; possi = possi->nextrev) {
+  for (possi = pkg->installed.depended; possi; possi = possi->rev_next) {
     if (useavailable(possi->up->up))
       continue;
     changemade = max(changemade, resolvedepcon(possi->up));
@@ -274,7 +274,7 @@ int packagelist::resolvedepcon(dependency *depends) {
         if (dep_update_best_to_change_stop(best, possi->ed)) goto mustdeselect;
         for (provider = possi->ed->available.depended;
              provider;
-             provider= provider->nextrev) {
+             provider = provider->rev_next) {
           if (provider->up->type != dep_provides) continue;
           if (provider->up->up->clientdata) foundany= 1;
           if (dep_update_best_to_change_stop(best, provider->up->up)) goto mustdeselect;
@@ -340,7 +340,7 @@ int packagelist::resolvedepcon(dependency *depends) {
     }
     for (provider = depends->list->ed->available.depended;
          provider;
-         provider= provider->nextrev) {
+         provider = provider->rev_next) {
       if (provider->up->type != dep_provides) continue;
       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;
@@ -398,7 +398,7 @@ packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade)
 
   for (provider = possi->ed->installed.depended;
        provider;
-       provider = provider->nextrev) {
+       provider = provider->rev_next) {
     if (provider->up->type == dep_provides &&
         provider->up->up->clientdata &&
         !useavailable(provider->up->up) &&
@@ -408,7 +408,7 @@ packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade)
   }
   for (provider = possi->ed->available.depended;
        provider;
-       provider = provider->nextrev) {
+       provider = provider->rev_next) {
     if (provider->up->type != dep_provides ||
         !provider->up->up->clientdata ||
         !would_like_to_install(provider->up->up->clientdata->selected,

+ 1 - 1
dselect/pkgsublist.cc

@@ -151,7 +151,7 @@ packagelist::add(dependency *depends, showpriority displayimportance)
       deppossi *provider;
       for (provider = possi->ed->available.depended;
            provider;
-           provider=provider->nextrev) {
+           provider = provider->rev_next) {
         if (provider->up->type != dep_provides) continue;
         add(provider->up->up,info.string(),displayimportance);
         add(provider->up,displayimportance);

+ 9 - 9
lib/dpkg/dlist.h

@@ -21,24 +21,24 @@
 #define ADNS_DLIST_H_INCLUDED
 
 #define LIST_INIT(list) ((list).head = (list).tail = NULL)
-#define LINK_INIT(link) ((link).next = (link).back = NULL)
+#define LINK_INIT(link) ((link).next = (link).prev = NULL)
 
 #define LIST_UNLINK_PART(list, node, part)				\
   do {									\
-    if ((node)->part back) \
-      (node)->part back->part next = (node)->part next; \
+    if ((node)->part prev) \
+      (node)->part prev->part next = (node)->part next; \
     else \
       (list).head = (node)->part next; \
     if ((node)->part next) \
-      (node)->part next->part back = (node)->part back; \
+      (node)->part next->part prev = (node)->part prev; \
     else \
-      (list).tail = (node)->part back; \
+      (list).tail = (node)->part prev; \
   } while (0)
 
 #define LIST_LINK_TAIL_PART(list, node, part)		\
   do {							\
     (node)->part next = NULL;				\
-    (node)->part back = (list).tail;			\
+    (node)->part prev = (list).tail;			\
     if ((list).tail) \
       (list).tail->part next = (node);	\
     else (list).head = (node);				\
@@ -49,11 +49,11 @@
 #define LIST_CHECKNODE_PART(list, node, part)				\
   do {									\
     if ((node)->next) \
-      assert((node)->part next->part back == (node));	\
+      assert((node)->part next->part prev == (node));	\
     else \
       assert((node) == (list).tail);					\
-    if ((node)->back) \
-      assert((node)->part back->part next == (node));	\
+    if ((node)->prev) \
+      assert((node)->part prev->part next == (node));	\
     else \
       assert((node) == (list).head);					\
   } while (0)

+ 3 - 3
lib/dpkg/dpkg-db.h

@@ -74,7 +74,7 @@ struct dependency {
 struct deppossi {
   struct dependency *up;
   struct pkginfo *ed;
-  struct deppossi *next, *nextrev, *backrev;
+  struct deppossi *next, *rev_next, *rev_prev;
   struct versionrevision version;
   enum depverrel verrel;
   bool cyclebreak;
@@ -130,9 +130,9 @@ struct trigpend {
 struct trigaw {
   /* Node indicates that aw's Triggers-Awaited mentions pend. */
   struct pkginfo *aw, *pend;
-  struct trigaw *nextsamepend;
+  struct trigaw *samepend_next;
   struct {
-    struct trigaw *next, *back;
+    struct trigaw *next, *prev;
   } sameaw;
 };
 

+ 10 - 7
lib/dpkg/fields.c

@@ -341,13 +341,16 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
       dop->up= dyp;
       dop->ed = findpackage(depname.buf);
       dop->next= NULL; *ldopp= dop; ldopp= &dop->next;
-      dop->nextrev= NULL; /* Don't link this (which is after all only `newpig' from */
-      dop->backrev= NULL; /* the main parsing loop in parsedb) into the depended on
-                        * packages' lists yet.  This will be done later when we
-                        * install this (in parse.c).  For the moment we do the
-                        * `forward' links in deppossi (`ed') only, and the backward
-                        * links from the depended on packages to dop are left undone.
-                        */
+
+      /* Don't link this (which is after all only ‘newpig’ from
+       * the main parsing loop in parsedb) into the depended on
+       * packages' lists yet. This will be done later when we
+       * install this (in parse.c). For the moment we do the
+       * ‘forward’ links in deppossi (‘ed’) only, and the ‘backward’
+       * links from the depended on packages to dop are left undone. */
+      dop->rev_next = NULL;
+      dop->rev_prev = NULL;
+
       dop->cyclebreak = false;
 /* skip whitespace after packagename */
       while (isspace(*p)) p++;

+ 9 - 9
lib/dpkg/parse.c

@@ -439,15 +439,15 @@ void copy_dependency_links(struct pkginfo *pkg,
    */
   for (dyp= *updateme; dyp; dyp= dyp->next) {
     for (dop= dyp->list; dop; dop= dop->next) {
-      if (dop->backrev)
-        dop->backrev->nextrev= dop->nextrev;
+      if (dop->rev_prev)
+        dop->rev_prev->rev_next = dop->rev_next;
       else
         if (available)
-          dop->ed->available.depended= dop->nextrev;
+          dop->ed->available.depended = dop->rev_next;
         else
-          dop->ed->installed.depended= dop->nextrev;
-      if (dop->nextrev)
-        dop->nextrev->backrev= dop->backrev;
+          dop->ed->installed.depended = dop->rev_next;
+      if (dop->rev_next)
+        dop->rev_next->rev_prev = dop->rev_prev;
     }
   }
   /* Now fill in new `ed' links from other packages to dependencies listed
@@ -457,10 +457,10 @@ void copy_dependency_links(struct pkginfo *pkg,
     dyp->up= pkg;
     for (dop= dyp->list; dop; dop= dop->next) {
       addtopifp= available ? &dop->ed->available : &dop->ed->installed;
-      dop->nextrev= addtopifp->depended;
-      dop->backrev= NULL;
+      dop->rev_next = addtopifp->depended;
+      dop->rev_prev = NULL;
       if (addtopifp->depended)
-        addtopifp->depended->backrev= dop;
+        addtopifp->depended->rev_prev = dop;
       addtopifp->depended= dop;
     }
   }

+ 2 - 2
lib/dpkg/triglib.c

@@ -169,7 +169,7 @@ trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
 	ta = nfmalloc(sizeof(*ta));
 	ta->aw = aw;
 	ta->pend = pend;
-	ta->nextsamepend = pend->othertrigaw_head;
+	ta->samepend_next = pend->othertrigaw_head;
 	pend->othertrigaw_head = ta;
 	LIST_LINK_TAIL_PART(aw->trigaw, ta, sameaw.);
 
@@ -186,7 +186,7 @@ trig_clear_awaiters(struct pkginfo *notpend)
 
 	ta = notpend->othertrigaw_head;
 	notpend->othertrigaw_head = NULL;
-	for (; ta; ta = ta->nextsamepend) {
+	for (; ta; ta = ta->samepend_next) {
 		aw = ta->aw;
 		if (!aw)
 			continue;

+ 1 - 1
lib/dpkg/triglib.h

@@ -43,7 +43,7 @@ struct trigfileint {
 	struct filenamenode *fnn;
 	struct trigfileint *samefile_next;
 	struct {
-		struct trigfileint *next, *back;
+		struct trigfileint *next, *prev;
 	} inoverall;
 };
 

+ 2 - 2
src/archives.c

@@ -1039,7 +1039,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
       } else {
         for (pdep= fixbyrm->installed.depended;
              pdep;
-             pdep= pdep->nextrev) {
+             pdep = pdep->rev_next) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
             continue;
           if (depisok(pdep->up, &removalwhy, NULL, false))
@@ -1056,7 +1056,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
             if (providecheck->type != dep_provides) continue;
             for (pdep= providecheck->list->ed->installed.depended;
                  pdep;
-                 pdep= pdep->nextrev) {
+                 pdep = pdep->rev_next) {
               if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
                 continue;
               if (depisok(pdep->up, &removalwhy, NULL, false))

+ 10 - 10
src/depcon.c

@@ -35,7 +35,7 @@
 #include "main.h"
 
 struct cyclesofarlink {
-  struct cyclesofarlink *back;
+  struct cyclesofarlink *prev;
   struct pkginfo *pkg;
   struct deppossi *possi;
 };
@@ -58,7 +58,7 @@ foundcyclebroken(struct cyclesofarlink *thislink, struct cyclesofarlink *sofar,
    * depended-on package is already one of the packages whose
    * dependencies we're searching.
    */
-  for (sol=sofar; sol && sol->pkg != dependedon; sol=sol->back);
+  for (sol = sofar; sol && sol->pkg != dependedon; sol = sol->prev);
 
   /* If not, we do a recursive search on it to see what we find. */
   if (!sol)
@@ -75,7 +75,7 @@ foundcyclebroken(struct cyclesofarlink *thislink, struct cyclesofarlink *sofar,
    * able to do something straight away when findbreakcycle returns.
    */
   sofar= thislink;
-  for (sol= sofar; !(sol != sofar && sol->pkg == dependedon); sol=sol->back) {
+  for (sol = sofar; !(sol != sofar && sol->pkg == dependedon); sol = sol->prev) {
     postinstfilename= pkgadminfile(sol->pkg,POSTINSTFILE);
     if (lstat(postinstfilename,&stab)) {
       if (errno == ENOENT) break;
@@ -111,7 +111,7 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
   if (f_debug & dbg_depcondetail) {
     struct varbuf str_pkgs = VARBUF_INIT;
 
-    for (sol = sofar; sol; sol = sol->back) {
+    for (sol = sofar; sol; sol = sol->prev) {
       varbufaddstr(&str_pkgs, " <- ");
       varbufaddstr(&str_pkgs, sol->pkg->name);
     }
@@ -121,7 +121,7 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
     varbuf_destroy(&str_pkgs);
   }
   thislink.pkg= pkg;
-  thislink.back= sofar;
+  thislink.prev = sofar;
   thislink.possi = NULL;
   for (dep= pkg->installed.depends; dep; dep= dep->next) {
     if (dep->type != dep_depends && dep->type != dep_predepends) continue;
@@ -134,7 +134,7 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
       /* Right, now we try all the providers ... */
       for (providelink= possi->ed->installed.depended;
            providelink;
-           providelink= providelink->nextrev) {
+           providelink = providelink->rev_next) {
         if (providelink->up->type != dep_provides) continue;
         provider= providelink->up->up;
         if (provider->clientdata->istobe == itb_normal) continue;
@@ -356,7 +356,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
         /* See if the package we're about to install Provides it. */
         for (provider= possi->ed->available.depended;
              provider;
-             provider= provider->nextrev) {
+             provider = provider->rev_next) {
           if (provider->up->type != dep_provides) continue;
           if (provider->up->up->clientdata->istobe == itb_installnew)
             return true;
@@ -365,7 +365,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
         /* Now look at the packages already on the system. */
         for (provider= possi->ed->installed.depended;
              provider;
-             provider= provider->nextrev) {
+             provider = provider->rev_next) {
           if (provider->up->type != dep_provides) continue;
           
           switch (provider->up->up->clientdata->istobe) {
@@ -479,7 +479,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
       /* See if the package we're about to install Provides it. */
       for (provider= possi->ed->available.depended;
            provider;
-           provider= provider->nextrev) {
+           provider = provider->rev_next) {
         if (provider->up->type != dep_provides) continue;
         if (provider->up->up->clientdata->istobe != itb_installnew) continue;
         if (provider->up->up == dep->up) continue; /* conflicts and provides the same */
@@ -495,7 +495,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
       /* Now look at the packages already on the system. */
       for (provider= possi->ed->installed.depended;
            provider;
-           provider= provider->nextrev) {
+           provider = provider->rev_next) {
         if (provider->up->type != dep_provides) continue;
           
         if (provider->up->up == dep->up) continue; /* conflicts and provides the same */

+ 2 - 2
src/packages.c

@@ -483,7 +483,7 @@ static void breaks_check_target(struct varbuf *aemsgs, int *ok,
                                 struct pkginfo *virtbroken) {
   struct deppossi *possi;
 
-  for (possi= target->installed.depended; possi; possi= possi->nextrev) {
+  for (possi = target->installed.depended; possi; possi = possi->rev_next) {
     if (possi->up->type != dep_breaks) continue;
     if (virtbroken && possi->verrel != dvr_none) continue;
     breaks_check_one(aemsgs, ok, possi, broken, possi->up->up, virtbroken);
@@ -542,7 +542,7 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
       if (found != 3 && possi->verrel == dvr_none) {
         for (provider = possi->ed->installed.depended;
              found != 3 && provider;
-             provider = provider->nextrev) {
+             provider = provider->rev_next) {
           if (provider->up->type != dep_provides)
             continue;
           debug(dbg_depcondetail, "     checking provider %s",

+ 5 - 5
src/processarc.c

@@ -294,7 +294,7 @@ void process_archive(const char *filename) {
       /* Look for things that conflict with what we provide. */
       for (psearch = dsearch->list->ed->installed.depended;
            psearch;
-           psearch = psearch->nextrev) {
+           psearch = psearch->rev_next) {
         if (psearch->up->type != dep_conflicts)
           continue;
         check_conflict(psearch->up, pkg, pfilename);
@@ -319,7 +319,7 @@ void process_archive(const char *filename) {
     }
   }
   /* Look for things that conflict with us. */
-  for (psearch= pkg->installed.depended; psearch; psearch= psearch->nextrev) {
+  for (psearch = pkg->installed.depended; psearch; psearch = psearch->rev_next) {
     if (psearch->up->type != dep_conflicts) continue;
     check_conflict(psearch->up, pkg, pfilename);
   }
@@ -960,7 +960,7 @@ void process_archive(const char *filename) {
       newpossi->up= newdep;
       newpossi->ed= possi->ed;
       newpossi->next = NULL;
-      newpossi->nextrev = newpossi->backrev = NULL;
+      newpossi->rev_next = newpossi->rev_prev = NULL;
       newpossi->verrel= possi->verrel;
       if (possi->verrel != dvr_none)
         newpossi->version= possi->version;
@@ -1053,7 +1053,7 @@ void process_archive(const char *filename) {
     debug(dbg_veryverbose, "process_archive disappear checking dependencies");
     for (pdep= otherpkg->installed.depended;
          pdep;
-         pdep= pdep->nextrev) {
+         pdep = pdep->rev_next) {
       if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
           pdep->up->type != dep_recommends) continue;
       if (depisok(pdep->up, &depprobwhy, NULL, false))
@@ -1070,7 +1070,7 @@ void process_archive(const char *filename) {
         if (providecheck->type != dep_provides) continue;
         for (pdep= providecheck->list->ed->installed.depended;
              pdep;
-             pdep= pdep->nextrev) {
+             pdep = pdep->rev_next) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
               pdep->up->type != dep_recommends)
             continue;

+ 1 - 1
src/remove.c

@@ -51,7 +51,7 @@ static void checkforremoval(struct pkginfo *pkgtoremove,
   struct pkginfo *depender;
   int before, ok;
   
-  for (possi= pkgdepcheck->installed.depended; possi; possi= possi->nextrev) {
+  for (possi = pkgdepcheck->installed.depended; possi; possi = possi->rev_next) {
     if (possi->up->type != dep_depends && possi->up->type != dep_predepends) continue;
     depender= possi->up->up;
     debug(dbg_depcon,"checking depending package `%s'",depender->name);