//first get the major,minor,maintenance constchar * pLast = szVersion; constchar * pCur = szVersion; //pEnd point to the position after the last character constchar * pEnd = szVersion + strlen(szVersion); // 0 = major, 1 = minor, 2 = maintenance, 3 = update int nPart = 0; // position within part beginning with 0 int nPartPos = 0; char buf[128];
//char must me a number 0 - 999 and no leading while (true)
{ if (pCur < pEnd && rtl::isAsciiDigit(static_cast<unsignedchar>(*pCur)))
{
pCur ++;
nPartPos ++;
} //if correct separator then form integer elseif (
(nPartPos != 0) // prevents: ".4.1", "..1", part must start with digit
&& ( //separators after maintenance (1.4.1_01, 1.4.1-beta, or 1.4.1)
(pCur == pEnd || *pCur == '_' || *pCur == '-')
|| //separators between major-minor and minor-maintenance (or fourth segment)
(nPart < 3 && *pCur == '.') )
&& ( //prevent 1.4.0. 1.4.0-
pCur + 1 != pEnd
|| rtl::isAsciiDigit(static_cast<unsignedchar>(*pCur))) )
{ bool afterMaint = pCur == pEnd || *pCur == '_' || *pCur == '-';
int len = pCur - pLast; if (len >= 127) returnfalse;
if (afterMaint)
nPart = 2;
nPart ++;
nPartPos = 0; if (nPart == 3) break;
//check next character if (! ( (pCur < pEnd)
&& ( (nPart < 3)
&& rtl::isAsciiDigit( static_cast<unsignedchar>(*pCur))))) returnfalse;
} else
{ returnfalse;
}
} if (pCur >= pEnd) returntrue; //We have now 1.4.1. This can be followed by _01 (or a fourth segment .1), -beta, etc. // _01 (update) According to docu must not be followed by any other //characters, but on Solaris 9 we have a 1.4.1_01a!! if (* (pCur - 1) == '_' || *(pCur - 1) == '.')
{// _01, _02 // update is the last part _01, _01a, part 0 is the digits parts and 1 the trailing alpha while (true)
{ if (pCur <= pEnd)
{ if ( ! rtl::isAsciiDigit(static_cast<unsignedchar>(*pCur)))
{ //1.8.0_102-, 1.8.0_01a,
size_t len = pCur - pLast; if (len > sizeof(buf) - 1) returnfalse; //we've got the update: 01, 02 etc
strncpy(buf, pLast, len);
buf[len] = 0;
m_arVersionParts[nPart] = atoi(buf); if (pCur == pEnd)
{ break;
} if (*pCur == 'a' && (pCur + 1) == pEnd)
{ //check if it s followed by a simple "a" (not specified)
m_nUpdateSpecial = *pCur; break;
} elseif (*pCur == '-' && pCur < pEnd)
{ //check 1.5.0_01-ea
PreRelease pr = getPreRelease(++pCur); if (pr == Rel_NONE) returnfalse; //just ignore -ea because its no official release break;
} else
{ returnfalse;
}
} if (pCur < pEnd)
pCur ++; else break;
}
}
} // 1.4.1-ea elseif (*(pCur - 1) == '-')
{
m_preRelease = getPreRelease(pCur); if (m_preRelease == Rel_NONE) returnfalse; #ifdefined(FREEBSD) if (m_preRelease == Rel_FreeBSD)
{
pCur++; //eliminate 'p' if (pCur < pEnd
&& rtl::isAsciiDigit(static_cast<unsignedchar>(*pCur)))
pCur ++; int len = pCur - pLast -1; //eliminate 'p' if (len >= 127) returnfalse;
strncpy(buf, (pLast+1), len); //eliminate 'p'
buf[len] = 0;
m_nUpdateSpecial = atoi(buf)+100; //hack for FBSD #i56953# returntrue;
} #endif
} else
{ returnfalse;
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.