diff options
author | dgp <dgp@users.sourceforge.net> | 2017-11-14 14:48:21 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-11-14 14:48:21 (GMT) |
commit | 2ea108ae28d6cb28d46755af67cc177af111e34c (patch) | |
tree | 4e5d83d0d9fde91b839910db8bd9817a2d714185 /generic/tclPkg.c | |
parent | eb2a9484b8c88857536ea0ea90fb97dac3f7f3b9 (diff) | |
parent | d7b5cde35f263aac98a4bdfbfa76afde358476d8 (diff) | |
download | tcl-2ea108ae28d6cb28d46755af67cc177af111e34c.zip tcl-2ea108ae28d6cb28d46755af67cc177af111e34c.tar.gz tcl-2ea108ae28d6cb28d46755af67cc177af111e34c.tar.bz2 |
[5d6de65036] [package require] with [package prefer stable] was not choosing available stable package.
Diffstat (limited to 'generic/tclPkg.c')
-rw-r--r-- | generic/tclPkg.c | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/generic/tclPkg.c b/generic/tclPkg.c index eb4dc9b..ea95320 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -418,7 +418,7 @@ PkgRequireCore( Interp *iPtr = (Interp *) interp; Package *pkgPtr; PkgAvail *availPtr, *bestPtr, *bestStablePtr; - char *availVersion, *bestVersion; + char *availVersion, *bestVersion, *bestStableVersion; /* Internal rep. of versions */ int availStable, code, satisfies, pass; char *script, *pkgVersionI; @@ -466,6 +466,7 @@ PkgRequireCore( bestPtr = NULL; bestStablePtr = NULL; bestVersion = NULL; + bestStableVersion = NULL; for (availPtr = pkgPtr->availPtr; availPtr != NULL; availPtr = availPtr->nextPtr) { @@ -479,60 +480,82 @@ PkgRequireCore( continue; } - + + /* Check satisfaction of requirements before considering the current version further. */ + if (reqc > 0) { + satisfies = SomeRequirementSatisfied(availVersion, reqc, reqv); + if (!satisfies) { + ckfree(availVersion); + availVersion = NULL; + continue; + } + } + if (bestPtr != NULL) { int res = CompareVersions(availVersion, bestVersion, NULL); /* - * Note: Use internal reps! + * Note: Used internal reps in the comparison! */ - if (res <= 0) { + if (res > 0) { /* - * The version of the package sought is not as good as the - * currently selected version. Ignore it. + * The version of the package sought is better than the + * currently selected version. */ - - ckfree(availVersion); - availVersion = NULL; - continue; + goto newbest; } - } - - /* - * We have found a version which is better than our max. - */ - - if (reqc > 0) { - /* Check satisfaction of requirements. */ + } else { + newbest: + /* We have found a version which is better than our max. */ - satisfies = SomeRequirementSatisfied(availVersion, reqc, reqv); - if (!satisfies) { - ckfree(availVersion); - availVersion = NULL; - continue; - } + bestPtr = availPtr; + CheckVersionAndConvert(interp, bestPtr->version, &bestVersion, NULL); } - bestPtr = availPtr; - - if (bestVersion != NULL) { - ckfree(bestVersion); + if (!availStable) { + ckfree(availVersion); + availVersion = NULL; + continue; } - bestVersion = availVersion; - /* - * If this new best version is stable then it also has to be - * better than the max stable version found so far. - */ + if (bestStablePtr != NULL) { + int res = CompareVersions(availVersion, bestStableVersion, NULL); + + /* + * Note: Used internal reps in the comparison! + */ - if (availStable) { + if (res > 0) { + /* + * This stable version of the package sought is better + * than the currently selected stable version. + */ + goto newstable; + } + } else { + newstable: + /* We have found a stable version which is better than our max stable. */ bestStablePtr = availPtr; + CheckVersionAndConvert(interp, bestStablePtr->version, &bestStableVersion, NULL); } - } + ckfree(availVersion); + availVersion = NULL; + } /* end for */ + + /* + * Clean up memorized internal reps, if any. + */ + if (bestVersion != NULL) { ckfree(bestVersion); + bestVersion = NULL; + } + + if (bestStableVersion != NULL) { + ckfree(bestStableVersion); + bestStableVersion = NULL; } /* |