Hi! Sorry for flooding the channel; I hope you can use something from my patches. This is not a cosmetic patch only, because static variable is not good if sortbydeps called multiple times, so I removed that ugly part from IV/A. And this version doesn't stop sorting in case of dep circle just notices us (it continues sorting to get the "best" possible result (but stops always)). You can ignore IV/A, but apply IV first. ---patch-IV/B----------- diff -Naur pacman-lib/lib/libalpm/deps.c pacman-lib.new/lib/libalpm/deps.c --- pacman-lib/lib/libalpm/deps.c 2007-04-22 19:46:40.000000000 +0200 +++ pacman-lib.new/lib/libalpm/deps.c 2007-04-22 21:29:05.000000000 +0200 @@ -67,17 +67,6 @@ free(graph); } -pmgraph_t *_alpm_graph_finduntouched(alpm_list_t *vertices) -{ - alpm_list_t *i; - pmgraph_t *found = NULL; - for (i = vertices; i && !found; i = i->next) { - pmgraph_t *vertex = i->data; - if (vertex->state == 0) found = vertex; - } - return(found); -} - pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type, pmdepmod_t depmod, const char *depname, const char *depversion) @@ -142,6 +131,7 @@ alpm_list_t *newtargs = NULL; alpm_list_t *i, *j, *k; alpm_list_t *vertices = NULL; + alpm_list_t *vptr; pmgraph_t *vertex; ALPM_LOG_FUNC; @@ -158,6 +148,7 @@ vertex->data = (void *)i->data; vertices = alpm_list_add(vertices, vertex); } + vptr = vertices; /* We compute the edges */ for(i = vertices; i; i = i->next) { @@ -179,7 +170,7 @@ } vertex = vertices->data; - while(vertex) { + while(vptr) { vertex->state = -1; // we touched this vertex int found = 0; while(vertex->sonptr && !found) { @@ -192,21 +183,21 @@ } else if(nextson->state == -1) { _alpm_log(PM_LOG_WARNING, _("dependency cycle detected\n")); - /* We add remaining targets */ - for(i = targets; i; i = i->next) - if(!_alpm_pkg_find(alpm_pkg_get_name(i->data), newtargs)) - newtargs = alpm_list_add(newtargs, i->data); - goto cleanup; } } if(!found) { newtargs = alpm_list_add(newtargs, vertex->data); vertex->state = 1; //we leave this vertex vertex = vertex->father; - if(!vertex) vertex=_alpm_graph_finduntouched(vertices); + if(!vertex) { + while(vptr) { + vertex = vptr->data; + vptr = vptr->next; + if (vertex->state == 0) break; + } + } } } -cleanup: _alpm_log(PM_LOG_DEBUG, _("sorting dependencies finished")); diff -Naur pacman-lib/lib/libalpm/deps.h pacman-lib.new/lib/libalpm/deps.h --- pacman-lib/lib/libalpm/deps.h 2007-04-22 19:21:24.000000000 +0200 +++ pacman-lib.new/lib/libalpm/deps.h 2007-04-22 21:27:15.000000000 +0200 @@ -53,7 +53,6 @@ pmgraph_t *_alpm_graph_new(void); void _alpm_graph_free(pmgraph_t *graph); -pmgraph_t *_alpm_graph_finduntouched(alpm_list_t *vertices); pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type, pmdepmod_t depmod, const char *depname, -------------------------- bye, ngaba