The following commit has been merged in the master branch:
commit 08d1abf93b29b9edbedf7353b2c67761b04b3a2b
Author: Guillem Jover <[email protected]>
Date: Sun Apr 1 07:55:36 2012 +0200
dpkg: Refactor tortoise_not_in_hare() out from check_trigger_cycle()
diff --git a/src/trigproc.c b/src/trigproc.c
index 98c7fcf..59129ad 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -168,6 +168,48 @@ trigproc_reset_cycle(void)
tortoise = hare = NULL;
}
+static bool
+tortoise_not_in_hare(struct pkginfo *processing_now,
+ struct trigcycleperpkg *tortoise_pkg)
+{
+ const char *processing_now_name, *tortoise_name;
+ struct trigpend *hare_trig, *tortoise_trig;
+
+ processing_now_name = pkg_name(processing_now, pnaw_nonambig);
+ tortoise_name = pkg_name(tortoise_pkg->pkg, pnaw_nonambig);
+
+ debug(dbg_triggersdetail, "%s pnow=%s tortoise=%s", __func__,
+ processing_now_name, tortoise_name);
+ for (tortoise_trig = tortoise_pkg->then_trigs;
+ tortoise_trig;
+ tortoise_trig = tortoise_trig->next) {
+ debug(dbg_triggersdetail,
+ "%s pnow=%s tortoise=%s tortoisetrig=%s", __func__,
+ processing_now_name, tortoise_name, tortoise_trig->name);
+
+ /* hare is now so we can just look up in the actual data. */
+ for (hare_trig = tortoise_pkg->pkg->trigpend_head;
+ hare_trig;
+ hare_trig = hare_trig->next) {
+ debug(dbg_triggersstupid, "%s pnow=%s tortoise=%s"
+ " tortoisetrig=%s haretrig=%s", __func__,
+ processing_now_name, tortoise_name,
+ tortoise_trig->name, hare_trig->name);
+ if (strcmp(hare_trig->name, tortoise_trig->name) == 0)
+ break;
+ }
+
+ if (hare_trig == NULL) {
+ /* Not found in hare, yay! */
+ debug(dbg_triggersdetail, "%s pnow=%s tortoise=%s OK",
+ __func__, processing_now_name, tortoise_name);
+ return true;
+ }
+ }
+
+ return false;
+}
+
/*
* Returns package we're to give up on.
*/
@@ -176,7 +218,7 @@ check_trigger_cycle(struct pkginfo *processing_now)
{
struct trigcyclenode *tcn;
struct trigcycleperpkg *tcpp, *tortoise_pkg;
- struct trigpend *hare_trig, *tortoise_trig;
+ struct trigpend *tortoise_trig;
struct pkgiterator *it;
struct pkginfo *pkg, *giveup;
const char *sep;
@@ -221,41 +263,8 @@ check_trigger_cycle(struct pkginfo *processing_now)
for (tortoise_pkg = tortoise->pkgs;
tortoise_pkg;
tortoise_pkg = tortoise_pkg->next) {
- const char *processing_now_name, *tortoise_name;
-
- processing_now_name = pkg_name(processing_now, pnaw_nonambig);
- tortoise_name = pkg_name(tortoise_pkg->pkg, pnaw_nonambig);
-
- debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s
tortoise=%s",
- processing_now_name, tortoise_name);
- for (tortoise_trig = tortoise_pkg->then_trigs;
- tortoise_trig;
- tortoise_trig = tortoise_trig->next) {
- debug(dbg_triggersdetail,
- "check_triggers_cycle pnow=%s tortoise=%s"
- " tortoisetrig=%s",
- processing_now_name, tortoise_name,
- tortoise_trig->name);
- /* hare is now so we can just look up in the actual
- * data. */
- for (hare_trig = tortoise_pkg->pkg->trigpend_head;
- hare_trig;
- hare_trig = hare_trig->next) {
- debug(dbg_triggersstupid,
- "check_triggers_cycle pnow=%s tortoise=%s"
- " tortoisetrig=%s haretrig=%s",
- processing_now_name, tortoise_name,
- tortoise_trig->name, hare_trig->name);
- if (strcmp(hare_trig->name,
tortoise_trig->name) == 0)
- goto found_in_hare;
- }
- /* Not found in hare, yay! */
- debug(dbg_triggersdetail,
- "check_triggers_cycle pnow=%s tortoise=%s OK",
- processing_now_name, tortoise_name);
+ if (tortoise_not_in_hare(processing_now, tortoise_pkg))
return NULL;
- found_in_hare:;
- }
}
/* Oh dear. hare is a superset of tortoise. We are making no
* progress. */
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]