diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-03-30 17:15:25 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-03-30 17:19:19 -0500 |
| commit | ed0ef472c76ac0d2a3d7a138e4f3b7ad950a56bc (patch) | |
| tree | 0b409592d759b43f583b44d2d854d8c44199bcee /src/dutil/apuputil.cpp | |
| parent | 10ebf674da5df9224e4eddd3545518434c5b455b (diff) | |
| download | wix-ed0ef472c76ac0d2a3d7a138e4f3b7ad950a56bc.tar.gz wix-ed0ef472c76ac0d2a3d7a138e4f3b7ad950a56bc.tar.bz2 wix-ed0ef472c76ac0d2a3d7a138e4f3b7ad950a56bc.zip | |
Add test for apuputil and fix descending sorting.
Diffstat (limited to 'src/dutil/apuputil.cpp')
| -rw-r--r-- | src/dutil/apuputil.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/dutil/apuputil.cpp b/src/dutil/apuputil.cpp index 07d591a7..6f5825bb 100644 --- a/src/dutil/apuputil.cpp +++ b/src/dutil/apuputil.cpp | |||
| @@ -208,7 +208,6 @@ static HRESULT ProcessEntry( | |||
| 208 | ) | 208 | ) |
| 209 | { | 209 | { |
| 210 | HRESULT hr = S_OK; | 210 | HRESULT hr = S_OK; |
| 211 | BOOL fVersionFound = FALSE; | ||
| 212 | int nCompareResult = 0; | 211 | int nCompareResult = 0; |
| 213 | 212 | ||
| 214 | // First search the ATOM entry's custom elements to try and find the application update information. | 213 | // First search the ATOM entry's custom elements to try and find the application update information. |
| @@ -255,25 +254,26 @@ static HRESULT ProcessEntry( | |||
| 255 | { | 254 | { |
| 256 | hr = VerParseVersion(pElement->wzValue, 0, FALSE, &pApupEntry->pVersion); | 255 | hr = VerParseVersion(pElement->wzValue, 0, FALSE, &pApupEntry->pVersion); |
| 257 | ApupExitOnFailure(hr, "Failed to parse version string '%ls' from ATOM entry.", pElement->wzValue); | 256 | ApupExitOnFailure(hr, "Failed to parse version string '%ls' from ATOM entry.", pElement->wzValue); |
| 258 | |||
| 259 | fVersionFound = TRUE; | ||
| 260 | } | 257 | } |
| 261 | } | 258 | } |
| 262 | } | 259 | } |
| 263 | 260 | ||
| 264 | // If there is no application identity or no version, skip the whole thing. | 261 | // If there is no application identity or no version, skip the whole thing. |
| 265 | if ((!pApupEntry->wzApplicationId && !wzDefaultAppId) || !fVersionFound) | 262 | if ((!pApupEntry->wzApplicationId && !wzDefaultAppId) || !pApupEntry->pVersion) |
| 266 | { | 263 | { |
| 267 | ExitFunction1(hr = S_FALSE); // skip this update since it has no application id or version. | 264 | ExitFunction1(hr = S_FALSE); // skip this update since it has no application id or version. |
| 268 | } | 265 | } |
| 269 | 266 | ||
| 270 | hr = VerCompareParsedVersions(pApupEntry->pUpgradeVersion, pApupEntry->pVersion, &nCompareResult); | 267 | if (pApupEntry->pUpgradeVersion) |
| 271 | ApupExitOnFailure(hr, "Failed to compare version to upgrade version."); | ||
| 272 | |||
| 273 | if (nCompareResult >= 0) | ||
| 274 | { | 268 | { |
| 275 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); | 269 | hr = VerCompareParsedVersions(pApupEntry->pUpgradeVersion, pApupEntry->pVersion, &nCompareResult); |
| 276 | ApupExitOnRootFailure(hr, "Upgrade version is greater than or equal to application version."); | 270 | ApupExitOnFailure(hr, "Failed to compare version to upgrade version."); |
| 271 | |||
| 272 | if (nCompareResult >= 0) | ||
| 273 | { | ||
| 274 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); | ||
| 275 | ApupExitOnRootFailure(hr, "Upgrade version is greater than or equal to application version."); | ||
| 276 | } | ||
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | if (pAtomEntry->wzTitle) | 279 | if (pAtomEntry->wzTitle) |
| @@ -443,11 +443,14 @@ static __callback int __cdecl CompareEntries( | |||
| 443 | VerCompareParsedVersions(pEntryLeft->pUpgradeVersion, pEntryRight->pUpgradeVersion, &ret); | 443 | VerCompareParsedVersions(pEntryLeft->pUpgradeVersion, pEntryRight->pUpgradeVersion, &ret); |
| 444 | if (0 == ret) | 444 | if (0 == ret) |
| 445 | { | 445 | { |
| 446 | ret = (pEntryRight->dw64TotalSize < pEntryLeft->dw64TotalSize) ? -1 : | 446 | ret = (pEntryLeft->dw64TotalSize < pEntryRight->dw64TotalSize) ? -1 : |
| 447 | (pEntryRight->dw64TotalSize > pEntryLeft->dw64TotalSize) ? 1 : 0; | 447 | (pEntryLeft->dw64TotalSize > pEntryRight->dw64TotalSize) ? 1 : 0; |
| 448 | } | 448 | } |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | // Sort descending. | ||
| 452 | ret = -ret; | ||
| 453 | |||
| 451 | return ret; | 454 | return ret; |
| 452 | } | 455 | } |
| 453 | 456 | ||
