Changeset 25031 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Nov 26, 2009 9:22:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strversion.cpp
r25029 r25031 75 75 while (*psz && RT_C_IS_DIGIT(*psz)); 76 76 77 char *pszNext; 78 int rc = RTStrToInt32Ex(*ppszVer, &pszNext, 10, pi32Value); 79 AssertRC(rc); 80 Assert(pszNext == psz); 77 int rc = RTStrToInt32Ex(*ppszVer, NULL, 10, pi32Value); 81 78 if (RT_FAILURE(rc) || rc == VWRN_NUMBER_TOO_BIG) 82 79 { 80 AssertRC(rc); 83 81 fNumeric = false; 84 82 *pi32Value = 0; 85 83 } 86 *pcchBlock = psz - *ppszVer;87 84 } 88 85 else … … 91 88 psz++; 92 89 while (*psz && !RT_C_IS_DIGIT(*psz) && !RTSTRVER_IS_PUNCTUACTION(*psz)); 93 *pcchBlock = psz - *ppszVer;90 size_t cchBlock = psz - *ppszVer; 94 91 95 92 /* Translate standard pre release terms to negative values. */ 96 if ( *pcchBlock == 2 97 && !RTStrNICmp(*ppszVer, "RC", 4)) 98 *pi32Value = -100; 99 else if ( *pcchBlock == 3 100 && !RTStrNICmp(*ppszVer, "PRE", 3)) 101 *pi32Value = -200; 102 else if ( *pcchBlock == 5 103 && !RTStrNICmp(*ppszVer, "GAMMA", 5)) 104 *pi32Value = -300; 105 else if ( *pcchBlock == 4 106 && !RTStrNICmp(*ppszVer, "BETA", 4)) 107 *pi32Value = -400; 108 else if ( *pcchBlock == 5 109 && !RTStrNICmp(*ppszVer, "ALPHA", 4)) 110 *pi32Value = -500; 93 uint32_t iVal1; 94 if ( cchBlock == 2 && !RTStrNICmp(*ppszVer, "RC", 2)) 95 iVal1 = -100000; 96 else if (cchBlock == 3 && !RTStrNICmp(*ppszVer, "PRE", 3)) 97 iVal1 = -200000; 98 else if (cchBlock == 5 && !RTStrNICmp(*ppszVer, "GAMMA", 5)) 99 iVal1 = -300000; 100 else if (cchBlock == 4 && !RTStrNICmp(*ppszVer, "BETA", 4)) 101 iVal1 = -400000; 102 else if (cchBlock == 5 && !RTStrNICmp(*ppszVer, "ALPHA", 5)) 103 iVal1 = -500000; 111 104 else 112 *pi32Value= 0;113 if ( *pi32Value <0)105 iVal1 = 0; 106 if (iVal1 != 0) 114 107 { 115 /* Trailing number, if so add it? */ 108 /* Trailing number? Add it assuming BETA == BETA1. */ 109 if (RT_C_IS_DIGIT(*psz)) 110 { 111 const char *psz2 = psz; 112 do 113 psz++; 114 while (*psz && !RT_C_IS_DIGIT(*psz) && !RTSTRVER_IS_PUNCTUACTION(*psz)); 115 116 int rc = RTStrToInt32Ex(psz2, NULL, 10, pi32Value); 117 if (RT_SUCCESS(rc) && rc != VWRN_NUMBER_TOO_BIG && *pi32Value) 118 iVal1 += *pi32Value - 1; 119 else 120 { 121 AssertRC(rc); 122 psz = psz2; 123 } 124 } 125 fNumeric = true; 116 126 } 127 *pi32Value = iVal1; 117 128 } 129 *pcchBlock = psz - *ppszVer; 118 130 119 131 /* skip punctuation */ … … 151 163 return iVal1 < iVal2 ? -1 : 1; 152 164 } 153 else if ( !fNumeric1 && fNumeric2 && iVal2 <= 0 && cchBlock1 == 0 154 || !fNumeric2 && fNumeric1 && iVal1 <= 0 && cchBlock2 == 0 165 else if ( fNumeric1 != fNumeric2 166 && ( fNumeric1 167 ? iVal1 == 0 && cchBlock2 == 0 168 : iVal2 == 0 && cchBlock1 == 0) 155 169 ) 156 170 { 157 /* 1.0 == 1.0.0.0.0. */; 171 /*else: 1.0 == 1.0.0.0.0. */; 172 } 173 else if ( fNumeric1 != fNumeric2 174 && (fNumeric1 ? iVal1 : iVal2) < 0) 175 { 176 /* Pre-release indicators are smaller than all other strings. */ 177 return fNumeric1 ? -1 : 1; 158 178 } 159 179 else … … 163 183 iDiff = cchBlock1 < cchBlock2 ? -1 : 1; 164 184 if (iDiff) 165 {166 /*167 * Special hacks for dealing with 3.1.0_BETA1-r99 vs 3.1.0r99.168 * Note that 3.1.0_BETA1 vs 3.0.1 is handled above with help of169 * negative values returned by the parser.170 */171 /** @todo finish at home */172 173 185 return iDiff < 0 ? -1 : 1; 174 }175 186 } 176 187 }
Note:
See TracChangeset
for help on using the changeset viewer.