ICU-841 ucol_getVersion implementation version 2
X-SVN-Rev: 3794
This commit is contained in:
parent
0b37173291
commit
7f0d1775f7
@ -296,7 +296,7 @@ ucol_open( const char *loc,
|
||||
/* first take on tailoring version: */
|
||||
/* get CollationElements -> Version */
|
||||
UResourceBundle *binary = ures_getByKey(b, "%%CollationNew", NULL, status);
|
||||
UResourceBundle* resB;
|
||||
|
||||
const UChar* trDataVersion;
|
||||
|
||||
if(*status == U_MISSING_RESOURCE_ERROR) { /* if we don't find tailoring, we'll fallback to UCA */
|
||||
@ -316,17 +316,6 @@ ucol_open( const char *loc,
|
||||
result->hasRealData = FALSE;
|
||||
}
|
||||
result->rb = b;
|
||||
|
||||
resB = ures_getByKey(result->rb,"CollationElements",NULL,status);
|
||||
trDataVersion=ures_get(resB,"Version",status);
|
||||
if(trDataVersion){
|
||||
char tVer[10]={'\0'};
|
||||
UVersionInfo trVInfo;
|
||||
u_UCharsToChars(trDataVersion, tVer, 10);
|
||||
u_versionFromString(trVInfo,tVer );
|
||||
result->trVersion=(uint8_t)trVInfo[0];
|
||||
}
|
||||
ures_close(resB);
|
||||
} else { /* There is another error, and we're just gonna clean up */
|
||||
ures_close(b);
|
||||
return NULL;
|
||||
@ -1227,6 +1216,9 @@ UCollator* ucol_initCollator(const UCATableHeader *image, UCollator *fillIn, UEr
|
||||
|
||||
result->zero = 0;
|
||||
result->rules = NULL;
|
||||
/* get the version info form UCATableHeader and populate the Collator struct*/
|
||||
result->dataInfo.dataVersion[0] = result->image->version[0]; /* UCA Builder version*/
|
||||
result->dataInfo.dataVersion[1] = result->image->version[1]; /* UCA Tailoring rules version*/
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -3153,10 +3145,6 @@ ucol_countAvailable()
|
||||
return uloc_countAvailable();
|
||||
}
|
||||
|
||||
/* temp Defines */
|
||||
#define UCOL_RUNTIME_VERSION 1
|
||||
#define UCOL_BUILDER_VERSION 1
|
||||
|
||||
U_CAPI void
|
||||
ucol_getVersion(const UCollator* coll,
|
||||
UVersionInfo versionInfo)
|
||||
@ -3164,12 +3152,9 @@ ucol_getVersion(const UCollator* coll,
|
||||
UErrorCode status =U_ZERO_ERROR;
|
||||
/* RunTime version */
|
||||
uint8_t rtVersion = UCOL_RUNTIME_VERSION;
|
||||
/* Builder version
|
||||
* Vladimir said this would be a #define but
|
||||
* I am of the opinion that the builder populates
|
||||
* the built CEs with version
|
||||
*/
|
||||
uint8_t bdVersion = UCOL_BUILDER_VERSION;
|
||||
/* Builder version*/
|
||||
uint8_t bdVersion = coll->dataInfo.dataVersion[0];
|
||||
|
||||
/* Charset Version. Need to get the version from cnv files
|
||||
* makeconv should populate cnv files with version and
|
||||
* an api has to be provided in ucnv.h to obtain this version
|
||||
@ -3180,16 +3165,14 @@ ucol_getVersion(const UCollator* coll,
|
||||
uint16_t cmbVersion = (rtVersion<<11) | (bdVersion<<6) | (csVersion);
|
||||
|
||||
/* UCA table version info */
|
||||
uint8_t* ucaDataVersion = (uint8_t*) coll->dataInfo.dataVersion;
|
||||
uint8_t ucaVersion =ucaDataVersion[0];
|
||||
uint8_t ucaVersion = UCA->dataInfo.dataVersion[0];
|
||||
|
||||
/* Tailoring rules
|
||||
* Is this the resource bundle version????
|
||||
*/
|
||||
/* Tailoring rules */
|
||||
versionInfo[0] = cmbVersion>>8;
|
||||
versionInfo[1] = (uint8_t)cmbVersion;
|
||||
versionInfo[2] = (uint8_t)(coll->trVersion | ucaVersion | rtVersion);
|
||||
versionInfo[3] = (uint8_t)ucaVersion;
|
||||
versionInfo[2] = coll->dataInfo.dataVersion[1];
|
||||
versionInfo[3] = UCA->dataInfo.dataVersion[1];
|
||||
|
||||
|
||||
}
|
||||
/****************************************************************************/
|
||||
|
@ -53,6 +53,10 @@
|
||||
/* This is the longest expansion sequence we can handle without bombing out */
|
||||
#define UCOL_EXPAND_CE_BUFFER_SIZE 64
|
||||
|
||||
|
||||
#define UCOL_RUNTIME_VERSION 1
|
||||
#define UCOL_BUILDER_VERSION 1
|
||||
|
||||
struct collIterate {
|
||||
UChar *string; /* Original string */
|
||||
UChar *len; /* Original string length */
|
||||
|
@ -278,7 +278,8 @@ parse(FileStream *f, const char *cp, const char *inputDir,
|
||||
|
||||
/* iterate through the stream */
|
||||
for(;;) {
|
||||
|
||||
/* Collation tailoring rules version */
|
||||
UVersionInfo version;
|
||||
/* get next token from stream */
|
||||
type = getNextToken(file, &token, status);
|
||||
if(U_FAILURE(*status)) {
|
||||
@ -606,6 +607,7 @@ parse(FileStream *f, const char *cp, const char *inputDir,
|
||||
temp1 = string_open(bundle, cSubTag, token.fChars, token.fLength, status);
|
||||
table_add(temp, temp1, status);
|
||||
temp1 = NULL;
|
||||
|
||||
if(U_FAILURE(*status)) {
|
||||
goto finish;
|
||||
}
|
||||
@ -619,6 +621,15 @@ parse(FileStream *f, const char *cp, const char *inputDir,
|
||||
colOverride = FALSE;
|
||||
}
|
||||
}
|
||||
if(colEl && (uprv_strcmp(cSubTag, "Version") == 0)){
|
||||
char tVer[40];
|
||||
int32_t length=u_strlen(token.fChars);
|
||||
if(length>=(int32_t)sizeof(tVer)) {
|
||||
length=(int32_t)sizeof(tVer)-1;
|
||||
}
|
||||
u_UCharsToChars(token.fChars, tVer, length);
|
||||
u_versionFromString(version,tVer);
|
||||
}
|
||||
if (colEl && (uprv_strcmp(cSubTag, "Sequence") == 0))
|
||||
{
|
||||
UErrorCode intStatus = U_ZERO_ERROR;
|
||||
@ -635,6 +646,8 @@ parse(FileStream *f, const char *cp, const char *inputDir,
|
||||
if(U_SUCCESS(intStatus) && coll !=NULL) {
|
||||
ucol_setNormalization(coll, UCOL_NO_NORMALIZATION);
|
||||
binColData = ucol_cloneRuleData(coll, &len, &intStatus);
|
||||
coll->dataInfo.dataVersion[0] = UCOL_BUILDER_VERSION; /* builder version */
|
||||
coll->dataInfo.dataVersion[1] = version[0]; /*tailoring rules version*/
|
||||
if(U_SUCCESS(*status) && data != NULL) {
|
||||
temp1 = bin_open(bundle, "%%CollationNew", len, binColData, status);
|
||||
table_add(rootTable, temp1, status);
|
||||
@ -661,7 +674,7 @@ parse(FileStream *f, const char *cp, const char *inputDir,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
/* Record the last string as the subtag */
|
||||
case eSubtag:
|
||||
u_UCharsToChars(token.fChars, cSubTag, u_strlen(token.fChars)+1);
|
||||
|
@ -568,6 +568,10 @@ write_uca_table(const char *filename,
|
||||
myD->caseFirst = UCOL_LOWER_FIRST; /* who goes first, lower case or uppercase */
|
||||
myD->caseLevel = UCOL_OFF; /* do we have an extra case level */
|
||||
myD->normalizationMode = UCOL_ON; /* attribute for normalization */
|
||||
/* populate the version info struct with version info*/
|
||||
myD->version[0] = UCA_BUILDER_VERSION;
|
||||
/*TODO:The fractional rules version should be taken from FractionalUCA.txt*/
|
||||
myD->version[1] = UCA_TAILORING_RULES_VERSION;
|
||||
|
||||
tempUCATable *t = uprv_uca_initTempTable(myD, status);
|
||||
|
||||
|
@ -34,6 +34,10 @@
|
||||
#include "umemstrm.h"
|
||||
#include "unewdata.h"
|
||||
|
||||
/* This is the version of FractionalUCA.txt tailoring rules*/
|
||||
#define UCA_TAILORING_RULES_VERSION 1
|
||||
/* Version of genuca */
|
||||
#define UCA_BUILDER_VERSION 1
|
||||
|
||||
/* UDataInfo for UCA mapping table */
|
||||
static const UDataInfo dataInfo={
|
||||
|
Loading…
Reference in New Issue
Block a user