diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index 74ff1f43417..a0e197383e6 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -84,15 +84,15 @@ isAcceptableUCA(void * /*context*/, if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && - 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[1]==ucaDataInfo.formatVersion[1] && - //pInfo->formatVersion[2]==ucaDataInfo.formatVersion[2] && // Too harsh - //pInfo->formatVersion[3]==ucaDataInfo.formatVersion[3] && // Too harsh + pInfo->dataFormat[0]==UCA_DATA_FORMAT_0 && /* dataFormat="UCol" */ + pInfo->dataFormat[1]==UCA_DATA_FORMAT_1 && + pInfo->dataFormat[2]==UCA_DATA_FORMAT_2 && + pInfo->dataFormat[3]==UCA_DATA_FORMAT_3 && + pInfo->formatVersion[0]==UCA_FORMAT_VERSION_0 && + pInfo->formatVersion[1]>=UCA_FORMAT_VERSION_1// && + //pInfo->formatVersion[1]==UCA_FORMAT_VERSION_1 && + //pInfo->formatVersion[2]==UCA_FORMAT_VERSION_2 && // Too harsh + //pInfo->formatVersion[3]==UCA_FORMAT_VERSION_3 && // Too harsh ) { UVersionInfo UCDVersion; u_getUnicodeVersion(UCDVersion); diff --git a/icu4c/source/i18n/ucol_bld.cpp b/icu4c/source/i18n/ucol_bld.cpp index b3410efc1d3..16255a1336a 100644 --- a/icu4c/source/i18n/ucol_bld.cpp +++ b/icu4c/source/i18n/ucol_bld.cpp @@ -40,15 +40,15 @@ isAcceptableInvUCA(void * /*context*/, if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && - 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]==invUcaDataInfo.formatVersion[0] && - pInfo->formatVersion[1]>=invUcaDataInfo.formatVersion[1] //&& - //pInfo->formatVersion[1]==invUcaDataInfo.formatVersion[1] && - //pInfo->formatVersion[2]==invUcaDataInfo.formatVersion[2] && - //pInfo->formatVersion[3]==invUcaDataInfo.formatVersion[3] && + pInfo->dataFormat[0]==INVUCA_DATA_FORMAT_0 && /* dataFormat="InvC" */ + pInfo->dataFormat[1]==INVUCA_DATA_FORMAT_1 && + pInfo->dataFormat[2]==INVUCA_DATA_FORMAT_2 && + pInfo->dataFormat[3]==INVUCA_DATA_FORMAT_3 && + pInfo->formatVersion[0]==INVUCA_FORMAT_VERSION_0 && + pInfo->formatVersion[1]>=INVUCA_FORMAT_VERSION_1 //&& + //pInfo->formatVersion[1]==INVUCA_FORMAT_VERSION_1 && + //pInfo->formatVersion[2]==INVUCA_FORMAT_VERSION_2 && + //pInfo->formatVersion[3]==INVUCA_FORMAT_VERSION_3 && ) { UVersionInfo UCDVersion; u_getUnicodeVersion(UCDVersion); diff --git a/icu4c/source/i18n/ucol_elm.cpp b/icu4c/source/i18n/ucol_elm.cpp index 00d248800c3..fe4a982c6f7 100644 --- a/icu4c/source/i18n/ucol_elm.cpp +++ b/icu4c/source/i18n/ucol_elm.cpp @@ -1357,7 +1357,10 @@ uprv_uca_assembleTable(tempUCATable *t, UErrorCode *status) { myData->magic = UCOL_HEADER_MAGIC; myData->isBigEndian = U_IS_BIG_ENDIAN; myData->charSetFamily = U_CHARSET_FAMILY; - uprv_memcpy(myData->formatVersion, ucaDataInfo.formatVersion, sizeof(UVersionInfo)); + myData->formatVersion[0] = UCA_FORMAT_VERSION_0; + myData->formatVersion[1] = UCA_FORMAT_VERSION_1; + myData->formatVersion[2] = UCA_FORMAT_VERSION_2; + myData->formatVersion[3] = UCA_FORMAT_VERSION_3; myData->jamoSpecial = t->image->jamoSpecial; // Don't copy stuff from UCA header! diff --git a/icu4c/source/i18n/ucol_imp.h b/icu4c/source/i18n/ucol_imp.h index d1305e9095e..41a1c36fa7b 100644 --- a/icu4c/source/i18n/ucol_imp.h +++ b/icu4c/source/i18n/ucol_imp.h @@ -170,42 +170,28 @@ #define UCOL_HEADER_MAGIC 0x20030618 /* UDataInfo for UCA mapping table */ -static const UDataInfo ucaDataInfo={ - sizeof(UDataInfo), - 0, +/* dataFormat="UCol" */ +#define UCA_DATA_FORMAT_0 ((uint8_t)0x55) +#define UCA_DATA_FORMAT_1 ((uint8_t)0x43) +#define UCA_DATA_FORMAT_2 ((uint8_t)0x6f) +#define UCA_DATA_FORMAT_3 ((uint8_t)0x6c) - U_IS_BIG_ENDIAN, - U_CHARSET_FAMILY, - sizeof(UChar), - 0, - - {0x55, 0x43, 0x6f, 0x6c}, /* dataFormat="UCol" */ - /* 03/26/2002 bumped up version since format has changed */ - /* 09/16/2002 bumped up version since we went from UColAttributeValue */ - /* to int32_t in UColOptionSet */ - /* 05/13/2003 This one also updated since we added UCA and UCD versions */ - /* to header */ - /* 09/11/2003 Adding information required by data swapper */ - {2, 3, 0, 0}, /* formatVersion */ - {3, 0, 0, 0} /* dataVersion = Unicode Version*/ -}; +#define UCA_FORMAT_VERSION_0 ((uint8_t)2) +#define UCA_FORMAT_VERSION_1 ((uint8_t)3) +#define UCA_FORMAT_VERSION_2 ((uint8_t)0) +#define UCA_FORMAT_VERSION_3 ((uint8_t)0) /* UDataInfo for inverse UCA table */ -static const UDataInfo invUcaDataInfo={ - sizeof(UDataInfo), - 0, +/* dataFormat="InvC" */ +#define INVUCA_DATA_FORMAT_0 ((uint8_t)0x49) +#define INVUCA_DATA_FORMAT_1 ((uint8_t)0x6E) +#define INVUCA_DATA_FORMAT_2 ((uint8_t)0x76) +#define INVUCA_DATA_FORMAT_3 ((uint8_t)0x43) - U_IS_BIG_ENDIAN, - U_CHARSET_FAMILY, - sizeof(UChar), - 0, - - {0x49, 0x6E, 0x76, 0x43}, /* dataFormat="InvC" */ - /* 03/26/2002 bumped up version since format has changed */ - /* 04/29/2003 2.1 format - we have added UCA version to header */ - {2, 1, 0, 0}, /* formatVersion */ - {3, 0, 0, 0} /* dataVersion = Unicode Version*/ -}; +#define INVUCA_FORMAT_VERSION_0 ((uint8_t)2) +#define INVUCA_FORMAT_VERSION_1 ((uint8_t)1) +#define INVUCA_FORMAT_VERSION_2 ((uint8_t)0) +#define INVUCA_FORMAT_VERSION_3 ((uint8_t)0) /* This is the size of the stack allocated buffer for sortkey generation and similar operations */ /* if it is too small, heap allocation will occur.*/ diff --git a/icu4c/source/tools/genuca/genuca.cpp b/icu4c/source/tools/genuca/genuca.cpp index b2cf97fd59b..b483ee5ac19 100644 --- a/icu4c/source/tools/genuca/genuca.cpp +++ b/icu4c/source/tools/genuca/genuca.cpp @@ -61,6 +61,42 @@ static UDataInfo dummyDataInfo = { #else +static const UDataInfo ucaDataInfo={ + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + sizeof(UChar), + 0, + + {UCA_DATA_FORMAT_0, UCA_DATA_FORMAT_1, UCA_DATA_FORMAT_2, UCA_DATA_FORMAT_3}, /* dataFormat="UCol" */ + /* 03/26/2002 bumped up version since format has changed */ + /* 09/16/2002 bumped up version since we went from UColAttributeValue */ + /* to int32_t in UColOptionSet */ + /* 05/13/2003 This one also updated since we added UCA and UCD versions */ + /* to header */ + /* 09/11/2003 Adding information required by data swapper */ + {UCA_FORMAT_VERSION_0, UCA_FORMAT_VERSION_1, UCA_FORMAT_VERSION_2, UCA_FORMAT_VERSION_3}, /* formatVersion */ + {0, 0, 0, 0} /* dataVersion = Unicode Version*/ +}; + +static const UDataInfo invUcaDataInfo={ + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + sizeof(UChar), + 0, + + {INVUCA_DATA_FORMAT_0, INVUCA_DATA_FORMAT_1, INVUCA_DATA_FORMAT_2, INVUCA_DATA_FORMAT_3}, /* dataFormat="InvC" */ + /* 03/26/2002 bumped up version since format has changed */ + /* 04/29/2003 2.1 format - we have added UCA version to header */ + {INVUCA_FORMAT_VERSION_0, INVUCA_FORMAT_VERSION_1, INVUCA_FORMAT_VERSION_2, INVUCA_FORMAT_VERSION_3}, /* formatVersion */ + {0, 0, 0, 0} /* dataVersion = Unicode Version*/ +}; + UCAElements le; int32_t readElement(char **from, char *to, char separator, UErrorCode *status) { @@ -1046,7 +1082,7 @@ int main(int argc, char* argv[]) { #if UCONFIG_NO_COLLATION 0, 0 #else - ucaDataInfo.formatVersion[0], ucaDataInfo.formatVersion[1] + UCA_FORMAT_VERSION_0, UCA_FORMAT_VERSION_1 #endif ); fprintf(stdout, U_COPYRIGHT_STRING"\n");