ICU-1294 collation data version number bumped up, udata structures moved to ucol_imp.h, isAcceptable functions now use data in these structs to validate the data

X-SVN-Rev: 6401
This commit is contained in:
Vladimir Weinstein 2001-10-23 21:48:14 +00:00
parent 803653ae79
commit ef1a552319
5 changed files with 57 additions and 51 deletions

View File

@ -66,15 +66,18 @@ isAcceptableUCA(void * /*context*/,
if( pInfo->size>=20 &&
pInfo->isBigEndian==U_IS_BIG_ENDIAN &&
pInfo->charsetFamily==U_CHARSET_FAMILY &&
pInfo->dataFormat[0]==0x55 && /* dataFormat="UCol" */
pInfo->dataFormat[1]==0x43 &&
pInfo->dataFormat[2]==0x6f &&
pInfo->dataFormat[3]==0x6c &&
pInfo->formatVersion[0]==1 &&
pInfo->dataVersion[0]==3 &&
pInfo->dataVersion[1]==0 &&
pInfo->dataVersion[2]==0 &&
pInfo->dataVersion[3]==0) {
pInfo->dataFormat[0]==ucaDataInfo.dataFormat[0] && /* dataFormat="UCol" */
pInfo->dataFormat[1]==ucaDataInfo.dataFormat[1] &&
pInfo->dataFormat[2]==ucaDataInfo.dataFormat[2] &&
pInfo->dataFormat[3]==ucaDataInfo.dataFormat[3] &&
pInfo->formatVersion[0]==ucaDataInfo.formatVersion[0] &&
pInfo->formatVersion[1]==ucaDataInfo.formatVersion[1] &&
pInfo->formatVersion[2]==ucaDataInfo.formatVersion[2] &&
pInfo->formatVersion[3]==ucaDataInfo.formatVersion[3] &&
pInfo->dataVersion[0]==ucaDataInfo.dataVersion[0] &&
pInfo->dataVersion[1]==ucaDataInfo.dataVersion[1] &&
pInfo->dataVersion[2]==ucaDataInfo.dataVersion[2] &&
pInfo->dataVersion[3]==ucaDataInfo.dataVersion[3]) {
return TRUE;
} else {
return FALSE;

View File

@ -33,15 +33,18 @@ isAcceptableInvUCA(void * /*context*/,
if( pInfo->size>=20 &&
pInfo->isBigEndian==U_IS_BIG_ENDIAN &&
pInfo->charsetFamily==U_CHARSET_FAMILY &&
pInfo->dataFormat[0]==0x49 && /* dataFormat="InvC" */
pInfo->dataFormat[1]==0x6e &&
pInfo->dataFormat[2]==0x76 &&
pInfo->dataFormat[3]==0x43 &&
pInfo->formatVersion[0]==1 &&
pInfo->dataVersion[0]==3 &&
pInfo->dataVersion[1]==0 &&
pInfo->dataVersion[2]==0 &&
pInfo->dataVersion[3]==0) {
pInfo->dataFormat[0]==invUcaDataInfo.dataFormat[0] && /* dataFormat="InvC" */
pInfo->dataFormat[1]==invUcaDataInfo.dataFormat[1] &&
pInfo->dataFormat[2]==invUcaDataInfo.dataFormat[2] &&
pInfo->dataFormat[3]==invUcaDataInfo.dataFormat[3] &&
pInfo->formatVersion[0]==ucaDataInfo.formatVersion[0] &&
pInfo->formatVersion[1]==ucaDataInfo.formatVersion[1] &&
pInfo->formatVersion[2]==ucaDataInfo.formatVersion[2] &&
pInfo->formatVersion[3]==ucaDataInfo.formatVersion[3] &&
pInfo->dataVersion[0]==invUcaDataInfo.dataVersion[0] &&
pInfo->dataVersion[1]==invUcaDataInfo.dataVersion[1] &&
pInfo->dataVersion[2]==invUcaDataInfo.dataVersion[2] &&
pInfo->dataVersion[3]==invUcaDataInfo.dataVersion[3]) {
return TRUE;
} else {
return FALSE;

View File

@ -31,6 +31,36 @@
#include "unicode/ures.h"
#include "unicode/udata.h"
/* UDataInfo for UCA mapping table */
static const UDataInfo ucaDataInfo={
sizeof(UDataInfo),
0,
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
sizeof(UChar),
0,
{0x55, 0x43, 0x6f, 0x6c}, /* dataFormat="UCol" */
{1, 1, 0, 0}, /* formatVersion */
{3, 0, 0, 0} /* dataVersion = Unicode Version*/
};
/* UDataInfo for inverse UCA table */
static const UDataInfo invUcaDataInfo={
sizeof(UDataInfo),
0,
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
sizeof(UChar),
0,
{0x49, 0x6E, 0x76, 0x43}, /* dataFormat="InvC" */
{1, 1, 0, 0}, /* formatVersion */
{3, 0, 0, 0} /* dataVersion = Unicode Version*/
};
/* This is the size of the stack allocated buffer for sortkey generation and similar operations */
/* if it is too small, heap allocation will occur.*/
/* you can change this value if you need memory - it will affect the performance, though, since we're going to malloc */

View File

@ -302,7 +302,7 @@ static void writeOutInverseData(InverseTableHeader *data,
long dataLength;
pData=udata_create(outputDir, INVC_DATA_TYPE, INVC_DATA_NAME, &invDataInfo,
pData=udata_create(outputDir, INVC_DATA_TYPE, INVC_DATA_NAME, &invUcaDataInfo,
copyright, status);
if(U_FAILURE(*status)) {
@ -538,7 +538,7 @@ void writeOutData(UCATableHeader *data,
long dataLength;
pData=udata_create(outputDir, UCA_DATA_TYPE, UCA_DATA_NAME, &dataInfo,
pData=udata_create(outputDir, UCA_DATA_TYPE, UCA_DATA_NAME, &ucaDataInfo,
copyright, status);
if(U_FAILURE(*status)) {
@ -735,7 +735,7 @@ int main(int argc, char* argv[]) {
if(options[3].doesOccur) {
fprintf(stdout, "genuca version %hu.%hu, ICU tool to read UCA text data and create UCA data tables for collation.\n",
dataInfo.formatVersion[0], dataInfo.formatVersion[1]);
ucaDataInfo.formatVersion[0], ucaDataInfo.formatVersion[1]);
fprintf(stdout, "Copyright (C) 2000-2001, International Business Machines\n");
fprintf(stdout, "Corporation and others. All Rights Reserved.\n");
exit(0);

View File

@ -32,36 +32,6 @@
#include "umemstrm.h"
#include "unewdata.h"
/* UDataInfo for UCA mapping table */
static const UDataInfo dataInfo={
sizeof(UDataInfo),
0,
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
sizeof(UChar),
0,
{0x55, 0x43, 0x6f, 0x6c}, /* dataFormat="UCol" */
{1, 0, 0, 0}, /* formatVersion */
{3, 0, 0, 0} /* dataVersion = Unicode Version*/
};
/* UDataInfo for inverse UCA table */
static const UDataInfo invDataInfo={
sizeof(UDataInfo),
0,
U_IS_BIG_ENDIAN,
U_CHARSET_FAMILY,
sizeof(UChar),
0,
{0x49, 0x6E, 0x76, 0x43}, /* dataFormat="InvC" */
{1, 0, 0, 0}, /* formatVersion */
{3, 0, 0, 0} /* dataVersion = Unicode Version*/
};
void deleteElement(void *element);
int32_t readElement(char **from, char *to, char separator, UErrorCode *status);