ICU-397 make u_versionFrom/ToString() public
X-SVN-Rev: 1437
This commit is contained in:
parent
7e85fb6dae
commit
aca0c53ac2
@ -1645,7 +1645,6 @@ u_UCharsToChars(const UChar *us, char *cs, UTextOffset length) {
|
||||
}
|
||||
}
|
||||
|
||||
/* this function will become public */
|
||||
U_CFUNC void
|
||||
u_versionFromString(UVersionInfo versionArray, const char *versionString) {
|
||||
char *end;
|
||||
@ -1670,11 +1669,58 @@ u_versionFromString(UVersionInfo versionArray, const char *versionString) {
|
||||
}
|
||||
}
|
||||
|
||||
/* also, need
|
||||
U_CAPI void U_EXPORT2
|
||||
u_versionToString(UVersionInfo versionArray, char *versionString) {
|
||||
uint16_t count, part;
|
||||
uint8_t field;
|
||||
|
||||
if(versionString==NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(versionArray==NULL) {
|
||||
versionString[0]=0;
|
||||
}
|
||||
|
||||
/* count how many fields need to be written */
|
||||
for(count=4; count>0 && versionArray[count-1]==0; --count) {}
|
||||
|
||||
if(count>0) {
|
||||
/* write the first part */
|
||||
/* write the decimal field value */
|
||||
field=versionArray[0];
|
||||
if(field>=100) {
|
||||
*versionString++='0'+field/100;
|
||||
field%=100;
|
||||
}
|
||||
if(field>=10) {
|
||||
*versionString++='0'+field/10;
|
||||
field%=10;
|
||||
}
|
||||
*versionString++='0'+field;
|
||||
|
||||
/* write the following parts */
|
||||
for(part=1; part<count; ++part) {
|
||||
/* write a dot first */
|
||||
*versionString++=U_VERSION_DELIMITER;
|
||||
|
||||
/* write the decimal field value */
|
||||
field=versionArray[part];
|
||||
if(field>=100) {
|
||||
*versionString++='0'+field/100;
|
||||
field%=100;
|
||||
}
|
||||
if(field>=10) {
|
||||
*versionString++='0'+field/10;
|
||||
field%=10;
|
||||
}
|
||||
*versionString++='0'+field;
|
||||
}
|
||||
}
|
||||
|
||||
/* NUL-terminate */
|
||||
*versionString=0;
|
||||
}
|
||||
*/
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
u_getVersion(UVersionInfo versionArray) {
|
||||
|
@ -878,10 +878,6 @@ u_charCellWidth(UChar32 ch)
|
||||
}
|
||||
}
|
||||
|
||||
/* ### this function will become public */
|
||||
U_CFUNC void
|
||||
u_versionFromString(UVersionInfo versionArray, const char *versionString);
|
||||
|
||||
void u_getUnicodeVersion(UVersionInfo versionArray) {
|
||||
if(versionArray!=NULL) {
|
||||
uprv_memcpy(versionArray, dataVersion, U_MAX_VERSION_LENGTH);
|
||||
|
@ -229,7 +229,7 @@ void TestMisc()
|
||||
FULL_WIDTH,
|
||||
NEUTRAL};
|
||||
int i;
|
||||
char icuVersion[U_MAX_VERSION_STRING_LENGTH], temp[U_MAX_VERSION_LENGTH];
|
||||
char icuVersion[U_MAX_VERSION_STRING_LENGTH];
|
||||
UVersionInfo realVersion;
|
||||
|
||||
memset(icuVersion, 0, U_MAX_VERSION_STRING_LENGTH);
|
||||
@ -274,18 +274,7 @@ void TestMisc()
|
||||
}
|
||||
/* Tests the ICU version #*/
|
||||
u_getVersion(realVersion);
|
||||
for (i = 0; i < U_MAX_VERSION_LENGTH; i++ )
|
||||
{
|
||||
int len = 0;
|
||||
T_CString_integerToString(temp, realVersion[i], 10);
|
||||
strcat(icuVersion, temp);
|
||||
len = strlen(icuVersion);
|
||||
if (i != U_MAX_VERSION_LENGTH-1)
|
||||
{
|
||||
icuVersion[len] = U_VERSION_DELIMITER;
|
||||
icuVersion[len + 1] = 0;
|
||||
}
|
||||
}
|
||||
u_versionToString(realVersion, icuVersion);
|
||||
if (strncmp(icuVersion, U_ICU_VERSION, MIN(strlen(icuVersion), strlen(U_ICU_VERSION))) != 0)
|
||||
{
|
||||
log_err("ICU version test failed. Header says=%s, got=%s \n", U_ICU_VERSION, icuVersion);
|
||||
@ -387,7 +376,7 @@ void TestUnicodeData()
|
||||
const char *expectVersion = U_UNICODE_VERSION; /* NOTE: this purposely breaks to force the tests to stay in sync with the unicodedata */
|
||||
/* expectVersionArray must be filled from u_versionFromString(expectVersionArray, U_UNICODE_VERSION)
|
||||
once this function is public. */
|
||||
UVersionInfo expectVersionArray = {0x03, 0x00, 0x00, 0x00};
|
||||
UVersionInfo expectVersionArray;
|
||||
UVersionInfo versionArray;
|
||||
char expectString[256];
|
||||
|
||||
@ -396,6 +385,7 @@ void TestUnicodeData()
|
||||
strcat(newPath, expectVersion);
|
||||
strcat(newPath, ".txt");
|
||||
|
||||
u_versionFromString(expectVersionArray, expectVersion);
|
||||
strcpy(expectString, "Unicode Version ");
|
||||
strcat(expectString, expectVersion);
|
||||
u_getUnicodeVersion(versionArray);
|
||||
|
Loading…
Reference in New Issue
Block a user