12#if defined(_WIN32) && !defined(UPDATER_NO_STRING_GLUE_STL)
19template <
class T>
inline const T& XPCOM_MIN(
const T& aA,
const T& aB) {
return aB < aA ? aB : aA; }
58 aResult.
strB =
nullptr;
68 dot = strchr(aPart,
'.');
74 if (aPart[0] ==
'*' && aPart[1] ==
'\0')
76 aResult.
numA = INT32_MAX;
81 aResult.
numA = strtol(aPart,
const_cast<char**
>(&aResult.
strB), 10);
86 aResult.
strB =
nullptr;
91 if (aResult.
strB[0] ==
'+')
93 static const char kPre[] =
"pre";
97 aResult.
strBlen =
sizeof(kPre) - 1;
101 const char* numstart = strpbrk(aResult.
strB,
"0123456789+-");
110 aResult.
numC = strtol(numstart, &aResult.
extraD, 10);
138static wchar_t*
ParseVP(
wchar_t* aPart, VersionPartW& aResult)
143 aResult.strB =
nullptr;
146 aResult.extraD =
nullptr;
153 dot = wcschr(aPart,
'.');
159 if (aPart[0] ==
'*' && aPart[1] ==
'\0')
161 aResult.numA = INT32_MAX;
166 aResult.numA = wcstol(aPart,
const_cast<wchar_t**
>(&aResult.strB), 10);
171 aResult.strB =
nullptr;
176 if (aResult.strB[0] ==
'+')
178 static wchar_t kPre[] = L
"pre";
182 aResult.strBlen =
sizeof(kPre) - 1;
186 const wchar_t* numstart = wcspbrk(aResult.strB, L
"0123456789+-");
189 aResult.strBlen = wcslen(aResult.strB);
193 aResult.strBlen = numstart - aResult.strB;
195 aResult.numC = wcstol(numstart, &aResult.extraD, 10);
196 if (!*aResult.extraD)
198 aResult.extraD =
nullptr;
219static int32_t
ns_strcmp(
const char* aStr1,
const char* aStr2)
232 return strcmp(aStr1, aStr2);
236static int32_t
ns_strnncmp(
const char* aStr1, uint32_t aLen1,
const char* aStr2, uint32_t aLen2)
249 for (; aLen1 && aLen2; --aLen1, --aLen2, ++aStr1, ++aStr2)
264 return aLen2 == 0 ? 0 : -1;
271static int32_t
ns_cmp(int32_t aNum1, int32_t aNum2)
278 return aNum1 != aNum2;
311static int32_t
CompareVP(VersionPartW& aVer1, VersionPartW& aVer2)
313 int32_t r =
ns_cmp(aVer1.numA, aVer2.numA);
319 r = wcsncmp(aVer1.strB, aVer2.strB, XPCOM_MIN(aVer1.strBlen, aVer2.strBlen));
325 r =
ns_cmp(aVer1.numC, aVer2.numC);
333 return aVer2.extraD != 0;
341 return wcscmp(aVer1.extraD, aVer2.extraD);
350 wchar_t* A2 = wcsdup(aStrA);
356 wchar_t* B2 = wcsdup(aStrB);
391 char* A2 = strdup(aStrA);
397 char* B2 = strdup(aStrB);
Compares two VersionParts.
int32_t CompareVersions(const char *aStrA, const char *aStrB)
static int32_t ns_strcmp(const char *aStr1, const char *aStr2)
Parse a version part into a number and "extra text".
static int32_t CompareVP(VersionPart &aVer1, VersionPart &aVer2)
Compares two VersionParts.
static char * ParseVP(char *aPart, VersionPart &aResult)
Parse a version part into a number and "extra text".
static int32_t ns_strnncmp(const char *aStr1, uint32_t aLen1, const char *aStr2, uint32_t aLen2)
static int32_t ns_cmp(int32_t aNum1, int32_t aNum2)