From 2b352413b05fa49fbfd557f675c21a78d892260c Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Thu, 18 Sep 2003 23:18:23 +0000 Subject: [PATCH] ICU-2235 fix generation of options-only collation tailoring binaries X-SVN-Rev: 13144 --- icu4c/source/i18n/ucol.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/icu4c/source/i18n/ucol.cpp b/icu4c/source/i18n/ucol.cpp index ca1eabe7b3..949947641d 100644 --- a/icu4c/source/i18n/ucol.cpp +++ b/icu4c/source/i18n/ucol.cpp @@ -687,7 +687,37 @@ ucol_cloneRuleData(const UCollator *coll, int32_t *length, UErrorCode *status) *status = U_MEMORY_ALLOCATION_ERROR; return NULL; } - uprv_memcpy(result, UCA->image, sizeof(UCATableHeader)); + + /* build the UCATableHeader with minimal entries */ + /* do not copy the header from the UCA file because its values are wrong! */ + /* uprv_memcpy(result, UCA->image, sizeof(UCATableHeader)); */ + + /* reset everything */ + uprv_memset(result, 0, *length); + + /* set the tailoring-specific values */ + UCATableHeader *myData = (UCATableHeader *)result; + myData->size = *length; + + /* offset for the options, the only part of the data that is present after the header */ + myData->options = sizeof(UCATableHeader); + + /* need to always set the expansion value for an upper bound of the options */ + myData->expansion = myData->options + sizeof(UColOptionSet); + + myData->magic = UCOL_HEADER_MAGIC; + myData->isBigEndian = U_IS_BIG_ENDIAN; + myData->charSetFamily = U_CHARSET_FAMILY; + + /* copy UCA's version; genrb will override all but the builder version with tailoring data */ + uprv_memcpy(myData->version, coll->image->version, sizeof(UVersionInfo)); + + uprv_memcpy(myData->UCAVersion, coll->image->UCAVersion, sizeof(UVersionInfo)); + uprv_memcpy(myData->UCDVersion, coll->image->UCDVersion, sizeof(UVersionInfo)); + uprv_memcpy(myData->formatVersion, coll->image->formatVersion, sizeof(UVersionInfo)); + myData->jamoSpecial = coll->image->jamoSpecial; + + /* copy the collator options */ uprv_memcpy(result+paddedsize(sizeof(UCATableHeader)), coll->options, sizeof(UColOptionSet)); } return result;