Changeset 35076 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Dec 14, 2010 1:31:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strversion.cpp
r28800 r35076 56 56 const char *psz = *ppszVer; 57 57 58 /* Check for end-of-string. */ 58 /* 59 * Check for end-of-string. 60 */ 59 61 if (!*psz) 60 62 { … … 64 66 } 65 67 68 /* 69 * Try convert the block to a number the simple way. 70 */ 71 char ch; 66 72 bool fNumeric = RT_C_IS_DIGIT(*psz); 67 73 if (fNumeric) 68 74 { 69 75 do 70 psz++;71 while ( *psz && RT_C_IS_DIGIT(*psz));76 ch = *++psz; 77 while (ch && RT_C_IS_DIGIT(ch)); 72 78 73 79 int rc = RTStrToInt32Ex(*ppszVer, NULL, 10, pi32Value); … … 81 87 else 82 88 { 89 /* 90 * Find the end of the current string. Make a special case for SVN 91 * revision numbers that immediately follows a release tag string. 92 */ 83 93 do 84 psz++; 85 while (*psz && !RT_C_IS_DIGIT(*psz) && !RTSTRVER_IS_PUNCTUACTION(*psz)); 94 ch = *++psz; 95 while ( ch 96 && !RT_C_IS_DIGIT(ch) 97 && !RTSTRVER_IS_PUNCTUACTION(ch)); 98 86 99 size_t cchBlock = psz - *ppszVer; 87 88 /* Translate standard pre release terms to negative values. */ 89 int32_t iVal1; 90 if ( cchBlock == 2 && !RTStrNICmp(*ppszVer, "RC", 2)) 91 iVal1 = -100000; 92 else if (cchBlock == 3 && !RTStrNICmp(*ppszVer, "PRE", 3)) 93 iVal1 = -200000; 94 else if (cchBlock == 5 && !RTStrNICmp(*ppszVer, "GAMMA", 5)) 95 iVal1 = -300000; 96 else if (cchBlock == 4 && !RTStrNICmp(*ppszVer, "BETA", 4)) 97 iVal1 = -400000; 98 else if (cchBlock == 5 && !RTStrNICmp(*ppszVer, "ALPHA", 5)) 99 iVal1 = -500000; 100 else 101 iVal1 = 0; 100 if ( cchBlock > 1 101 && psz[-1] == 'r' 102 && RT_C_IS_DIGIT(*psz)) 103 { 104 psz--; 105 cchBlock--; 106 } 107 108 109 /* 110 * Translate standard pre release terms to negative values. 111 */ 112 static const struct 113 { 114 size_t cch; 115 const char *psz; 116 int32_t iValue; 117 } s_aTerms[] = 118 { 119 { 2, "RC", -100000 }, 120 { 3, "PRE", -200000 }, 121 { 5, "GAMMA", -300000 }, 122 { 4, "BETA", -400000 }, 123 { 5, "ALPHA", -500000 } 124 }; 125 126 int32_t iVal1 = 0; 127 for (unsigned i = 0; i < RT_ELEMENTS(s_aTerms); i++) 128 if ( cchBlock == s_aTerms[i].cch 129 && !RTStrNCmp(s_aTerms[i].psz, *ppszVer, cchBlock)) 130 { 131 iVal1 = s_aTerms[i].iValue; 132 break; 133 } 102 134 if (iVal1 != 0) 103 135 { 104 /* Trailing number? Add it assuming BETA == BETA1. */ 136 /* 137 * Does the prelease term have a trailing number? 138 * Add it assuming BETA == BETA1. 139 */ 105 140 if (RT_C_IS_DIGIT(*psz)) 106 141 { 107 142 const char *psz2 = psz; 108 143 do 109 psz++; 110 while (*psz && !RT_C_IS_DIGIT(*psz) && !RTSTRVER_IS_PUNCTUACTION(*psz)); 144 ch = *++psz; 145 while ( ch 146 && RT_C_IS_DIGIT(ch) 147 && !RTSTRVER_IS_PUNCTUACTION(ch)); 111 148 112 149 int rc = RTStrToInt32Ex(psz2, NULL, 10, pi32Value); … … 125 162 *pcchBlock = psz - *ppszVer; 126 163 127 /* skip punctuation */ 164 /* 165 * Skip trailing punctuation. 166 */ 128 167 if (RTSTRVER_IS_PUNCTUACTION(*psz)) 129 168 psz++;
Note:
See TracChangeset
for help on using the changeset viewer.