ICU-2314 add fromUBytesLength to .cnv file structure
X-SVN-Rev: 10203
This commit is contained in:
parent
dd1b7cb1a4
commit
5e4e604d8c
@ -55,9 +55,13 @@
|
||||
#define MBCS_UNROLL_SINGLE_FROM_BMP 0
|
||||
|
||||
/*
|
||||
* _MBCSHeader versions 4
|
||||
* _MBCSHeader versions 4.1
|
||||
* (Note that the _MBCSHeader version is in addition to the converter formatVersion.)
|
||||
*
|
||||
* Change from version 4.0:
|
||||
* - Replace header.reserved with header.fromUBytesLength so that all
|
||||
* fields in the data have length.
|
||||
*
|
||||
* Changes from version 3 (for performance improvements):
|
||||
* - new bit distribution for state table entries
|
||||
* - reordered action codes
|
||||
@ -364,12 +368,21 @@ gb18030Ranges[13][4]={
|
||||
|
||||
static uint32_t
|
||||
_MBCSSizeofFromUBytes(UConverterMBCSTable *mbcsTable) {
|
||||
/* ### TODO markus 20020911 Use _MBCSHeader.reserved to store size of fromUBytes[] */
|
||||
const uint16_t *table;
|
||||
|
||||
uint32_t st3, maxStage3;
|
||||
uint16_t st1, maxStage1, st2;
|
||||
|
||||
if(mbcsTable->fromUBytesLength>0) {
|
||||
/*
|
||||
* We _know_ the number of bytes in the fromUnicodeBytes array
|
||||
* starting with header.version 4.1.
|
||||
* Otherwise, below, we need to enumerate the fromUnicode
|
||||
* trie and find the highest entry.
|
||||
*/
|
||||
return mbcsTable->fromUBytesLength;
|
||||
}
|
||||
|
||||
/* Enumerate the from-Unicode trie table to find the highest stage 3 index. */
|
||||
table=mbcsTable->fromUnicodeTable;
|
||||
maxStage3=0;
|
||||
@ -621,6 +634,7 @@ _MBCSLoad(UConverterSharedData *sharedData,
|
||||
|
||||
mbcsTable->fromUnicodeTable=(const uint16_t *)(raw+header->offsetFromUTable);
|
||||
mbcsTable->fromUnicodeBytes=(const uint8_t *)(raw+header->offsetFromUBytes);
|
||||
mbcsTable->fromUBytesLength=header->fromUBytesLength;
|
||||
mbcsTable->outputType=(uint8_t)header->flags;
|
||||
|
||||
/* make sure that the output type is known */
|
||||
|
@ -128,6 +128,7 @@ typedef struct UConverterMBCSTable {
|
||||
const uint16_t *fromUnicodeTable;
|
||||
const uint8_t *fromUnicodeBytes;
|
||||
uint8_t *swapLFNLFromUnicodeBytes; /* for swaplfnl */
|
||||
uint32_t fromUBytesLength;
|
||||
uint8_t outputType, unicodeMask;
|
||||
|
||||
/* converter name for swaplfnl */
|
||||
@ -147,7 +148,7 @@ typedef struct UConverterMBCSTable {
|
||||
* 6 flags, bits:
|
||||
* 31.. 8 reserved
|
||||
* 7.. 0 outputType
|
||||
* 7 reserved
|
||||
* 7 fromUBytesLength -- header.version 4.1 (ICU 2.4) and higher
|
||||
*
|
||||
* stateTable[countStates][256];
|
||||
*
|
||||
@ -170,7 +171,7 @@ typedef struct {
|
||||
offsetFromUTable,
|
||||
offsetFromUBytes,
|
||||
flags,
|
||||
reserved;
|
||||
fromUBytesLength;
|
||||
} _MBCSHeader;
|
||||
|
||||
/**
|
||||
|
@ -123,6 +123,7 @@ MBCSInit(MBCSData *mbcsData, uint8_t maxCharLength) {
|
||||
mbcsData->newConverter.write=MBCSWrite;
|
||||
|
||||
mbcsData->header.version[0]=4;
|
||||
mbcsData->header.version[1]=1;
|
||||
mbcsData->stateFlags[0]=MBCS_STATE_FLAG_DIRECT;
|
||||
mbcsData->stage2Top=MBCS_STAGE_2_FIRST_ASSIGNED; /* after stage 1 and one all-unassigned stage 2 block */
|
||||
mbcsData->stage3Top=16*maxCharLength; /* after one all-unassigned stage 3 block */
|
||||
@ -1715,6 +1716,7 @@ MBCSWrite(NewConverter *cnvData, const UConverterStaticData *staticData, UNewDat
|
||||
mbcsData->header.offsetFromUTable+
|
||||
stage1Top*2+
|
||||
mbcsData->stage2Top;
|
||||
mbcsData->header.fromUBytesLength=mbcsData->stage3Top;
|
||||
|
||||
/* write the MBCS data */
|
||||
udata_writeBlock(pData, &mbcsData->header, sizeof(_MBCSHeader));
|
||||
@ -1730,5 +1732,5 @@ MBCSWrite(NewConverter *cnvData, const UConverterStaticData *staticData, UNewDat
|
||||
udata_writeBlock(pData, mbcsData->fromUBytes, mbcsData->stage3Top);
|
||||
|
||||
/* return the number of bytes that should have been written */
|
||||
return mbcsData->header.offsetFromUBytes+mbcsData->stage3Top;
|
||||
return mbcsData->header.offsetFromUBytes+mbcsData->header.fromUBytesLength;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user