Author: schubi2 Date: Tue Feb 5 10:50:40 2008 New Revision: 8465 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8465&view=rev Log: sorting installation results Modified: trunk/sat-solver/testsuite/deptestomatic.c Modified: trunk/sat-solver/testsuite/deptestomatic.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/deptestomatic.c?rev=8465&r1=8464&r2=8465&view=diff ============================================================================== --- trunk/sat-solver/testsuite/deptestomatic.c (original) +++ trunk/sat-solver/testsuite/deptestomatic.c Tue Feb 5 10:50:40 2008 @@ -40,6 +40,56 @@ #define MAXNAMELEN 100 +static Pool *decision_data; + +/*-----------------------------------------------------------------*/ + +/* + * sorting queue by name + */ + +static int +decision_sortcmp(const void *ap, const void *bp) +{ + Pool *pool = decision_data; + int r; + Id a = *(Id *)ap; + Id b = *(Id *)bp; + r = pool->solvables[a].name - pool->solvables[b].name; + if (r) + { + const char *na, *nb; + /* different names. We use real strcmp here so that the result + * is not depending on some random solvable order */ + na = id2str(pool, pool->solvables[a].name); + nb = id2str(pool, pool->solvables[b].name); + /* bring selections and patterns to the front */ + if (!strncmp(na, "pattern:", 8)) + { + if (strncmp(nb, "pattern:", 8)) + return -1; + } + else if (!strncmp(nb, "pattern:", 8)) + { + if (strncmp(na, "pattern:", 8)) + return 1; + } + if (!strncmp(na, "selection:", 10)) + { + if (strncmp(nb, "selection:", 10)) + return -1; + } + else if (!strncmp(nb, "selection:", 10)) + { + if (strncmp(na, "selection:", 10)) + return 1; + } + return strcmp(na, nb); + } + return a - b; +} + + static void err( const char *msg, ...) { @@ -1416,6 +1466,10 @@ /* print solvables to be installed */ + /* sorting */ + decision_data = solv->pool; + qsort(solv->decisionq.elements, solv->decisionq.count, sizeof(Id), decision_sortcmp); + for (i = 0; i < solv->decisionq.count; i++) { int j; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org