Changeset 25029 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Nov 26, 2009 7:39:10 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 55350
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strversion.cpp
r25014 r25029 53 53 * @returns true if numeric, false if not. 54 54 * @param ppszVer The string cursor, IN/OUT. 55 * @param p u32Value Where to return the value if numeric.55 * @param pi32Value Where to return the value if numeric. 56 56 * @param pcchBlock Where to return the block length. 57 57 */ 58 static bool rtStrVersionParseBlock(const char **ppszVer, uint32_t *pu32Value, size_t *pcchBlock)58 static bool rtStrVersionParseBlock(const char **ppszVer, int32_t *pi32Value, size_t *pcchBlock) 59 59 { 60 60 const char *psz = *ppszVer; … … 63 63 if (!*psz) 64 64 { 65 *p u32Value = 0;65 *pi32Value = 0; 66 66 *pcchBlock = 0; 67 67 return false; … … 76 76 77 77 char *pszNext; 78 int rc = RTStrTo UInt32Ex(*ppszVer, &pszNext, 10, pu32Value);78 int rc = RTStrToInt32Ex(*ppszVer, &pszNext, 10, pi32Value); 79 79 AssertRC(rc); 80 80 Assert(pszNext == psz); … … 82 82 { 83 83 fNumeric = false; 84 *p u32Value = 0;84 *pi32Value = 0; 85 85 } 86 *pcchBlock = psz - *ppszVer; 86 87 } 87 88 else … … 90 91 psz++; 91 92 while (*psz && !RT_C_IS_DIGIT(*psz) && !RTSTRVER_IS_PUNCTUACTION(*psz)); 92 *pu32Value = 0; 93 *pcchBlock = psz - *ppszVer; 94 95 /* 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; 111 else 112 *pi32Value = 0; 113 if (*pi32Value < 0) 114 { 115 /* Trailing number, if so add it? */ 116 } 93 117 } 94 *pcchBlock = psz - *ppszVer;95 118 96 119 /* skip punctuation */ … … 115 138 const char *pszBlock1 = pszVer1; 116 139 size_t cchBlock1; 117 uint32_t uVal1;118 bool fNumeric1 = rtStrVersionParseBlock(&pszVer1, & uVal1, &cchBlock1);140 int32_t iVal1; 141 bool fNumeric1 = rtStrVersionParseBlock(&pszVer1, &iVal1, &cchBlock1); 119 142 120 143 const char *pszBlock2 = pszVer2; 121 144 size_t cchBlock2; 122 uint32_t uVal2;123 bool fNumeric2 = rtStrVersionParseBlock(&pszVer2, & uVal2, &cchBlock2);145 int32_t iVal2; 146 bool fNumeric2 = rtStrVersionParseBlock(&pszVer2, &iVal2, &cchBlock2); 124 147 125 148 if (fNumeric1 && fNumeric2) 126 149 { 127 if ( uVal1 != uVal2)128 return uVal1 < uVal2 ? -1 : 1;150 if (iVal1 != iVal2) 151 return iVal1 < iVal2 ? -1 : 1; 129 152 } 130 else if ( !fNumeric1 && fNumeric2 && uVal2 == 0 && cchBlock1 == 0131 || !fNumeric2 && fNumeric1 && uVal1 == 0 && cchBlock2 == 0153 else if ( !fNumeric1 && fNumeric2 && iVal2 <= 0 && cchBlock1 == 0 154 || !fNumeric2 && fNumeric1 && iVal1 <= 0 && cchBlock2 == 0 132 155 ) 133 156 { … … 140 163 iDiff = cchBlock1 < cchBlock2 ? -1 : 1; 141 164 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 of 169 * negative values returned by the parser. 170 */ 171 /** @todo finish at home */ 172 142 173 return iDiff < 0 ? -1 : 1; 174 } 143 175 } 144 176 }
Note:
See TracChangeset
for help on using the changeset viewer.