ICU-96 starting JamoSpecial stuff...

X-SVN-Rev: 3957
This commit is contained in:
Vladimir Weinstein 2001-03-08 00:58:36 +00:00
parent 8cd5b63e94
commit a421457a49
3 changed files with 35 additions and 17 deletions

View File

@ -90,6 +90,12 @@ tempUCATable * uprv_uca_initTempTable(UCATableHeader *image, const UCollator *UC
MaxExpansionTable *maxet = (MaxExpansionTable *)uprv_malloc(
sizeof(MaxExpansionTable));
t->image = image;
if(UCA == NULL) {
t->image->jamoSpecial = FALSE;
} else {
t->image->jamoSpecial = UCA->image->jamoSpecial;
}
t->UCA = UCA;
t->expansions = (ExpansionTable *)uprv_malloc(sizeof(ExpansionTable));
uprv_memset(t->expansions, 0, sizeof(ExpansionTable));
@ -338,6 +344,9 @@ uint32_t uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode
(uint8_t)element->noOfCEs,
t->maxExpansions,
status);
if(UCOL_ISJAMO(element->cPoints[0])) {
t->image->jamoSpecial = TRUE;
}
}
CE = ucmp32_get(mapping, element->cPoints[0]);
@ -347,6 +356,9 @@ uint32_t uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode
for (i=1; i<element->cSize; i++) { /* First add contraction chars to unsafe CP hash table */
unsafeCPSet(t->unsafeCP, element->cPoints[i]);
}
if(UCOL_ISJAMO(element->cPoints[0])) {
t->image->jamoSpecial = TRUE;
}
/* then we need to deal with it */
/* we could aready have something in table - or we might not */

View File

@ -439,7 +439,7 @@ U_CFUNC uint32_t ucol_getCEGenerator(ucolCEGenerator *g, uint32_t* lows, uint32_
#endif
if(strength > 0 && lows[fStrength*3+(strength-1)] != highs[fStrength*3+(strength-1)]) {
low = (0x02 << (32-lobytes*8));
high = (0x00 << (32-hibytes*8));
high = (0xFF << (32-hibytes*8));
#ifdef UCOL_DEBUG
fprintf(stderr, "resolved! stronger strengths do give solution: %08X != %08X!\n", lows[fStrength*3+(strength-1)], highs[fStrength*3+(strength-1)]);
#endif
@ -1697,7 +1697,7 @@ uint32_t ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UEr
//*(collationSource->CEpos) = order; /* prepare the buffer */
order = getSpecialCE(coll, order, collationSource, status); /* and try to get the special CE */
if(order == UCOL_NOT_FOUND) { /* We couldn't find a good CE in the tailoring */
order = ucol_getNextUCA(ch, collationSource, status);
order = ucol_getNextUCA(ch, collationSource, coll->image->jamoSpecial, status);
}
}
//collationSource->pos++; /* we're advancing to the next codepoint */
@ -1711,7 +1711,7 @@ uint32_t ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UEr
/* This function tries to get a CE from UCA, which should be always around */
/* UChar is passed in in order to speed things up */
/* here is also the generation of implicit CEs */
uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UErrorCode *status) {
uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UBool jamoSpecial, UErrorCode *status) {
uint32_t order;
if(ch < 0xFF) { /* so we'll try to find it in the UCA */
order = UCA->latinOneMapping[ch];
@ -1755,7 +1755,7 @@ uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UErrorCode *sta
T += TBase;
// return the first CE, but first put the rest into the expansion buffer
if (!collationSource->JamoSpecial) { // FAST PATH
if (!jamoSpecial) { // FAST PATH
*(collationSource->CEpos++) = ucmp32_get(UCA->mapping, V);
if (T != TBase) {
@ -1815,7 +1815,7 @@ uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UErrorCode *sta
* of implicit CEs
*/
uint32_t ucol_getPrevUCA(UChar ch, collIterate *collationSource,
uint32_t length, UErrorCode *status)
uint32_t length, UBool jamoSpecial, UErrorCode *status)
{
uint32_t order;
if (ch < 0xFF) {
@ -1876,7 +1876,7 @@ uint32_t ucol_getPrevUCA(UChar ch, collIterate *collationSource,
/*
return the first CE, but first put the rest into the expansion buffer
*/
if (!collationSource->JamoSpecial)
if (!jamoSpecial)
{
*(collationSource->CEpos ++) = ucmp32_get(UCA->mapping, L);
*(collationSource->CEpos ++) = ucmp32_get(UCA->mapping, V);
@ -4819,7 +4819,7 @@ int32_t ucol_getIncrementalCE(const UCollator *coll, incrementalContext *ctx, UE
if(order >= UCOL_NOT_FOUND) { /* if a CE is special */
order = ucol_getIncrementalSpecialCE(coll, order, ctx, status); /* and try to get the special CE */
if(order == UCOL_NOT_FOUND) { /* We couldn't find a good CE in the tailoring */
order = ucol_getIncrementalUCA(ch, ctx, status);
order = ucol_getIncrementalUCA(ch, ctx, coll->image->jamoSpecial, status);
}
}
}
@ -4830,7 +4830,7 @@ int32_t ucol_getIncrementalCE(const UCollator *coll, incrementalContext *ctx, UE
/* This function tries to get a CE from UCA, which should be always around */
/* UChar is passed in in order to speed things up */
/* here is also the generation of implicit CEs */
uint32_t ucol_getIncrementalUCA(UChar ch, incrementalContext *collationSource, UErrorCode *status) {
uint32_t ucol_getIncrementalUCA(UChar ch, incrementalContext *collationSource, UBool jamoSpecial, UErrorCode *status) {
uint32_t order;
if(ch < 0xFF) { /* so we'll try to find it in the UCA */
order = UCA->latinOneMapping[ch];
@ -4873,7 +4873,7 @@ uint32_t ucol_getIncrementalUCA(UChar ch, incrementalContext *collationSource, U
T += TBase;
// return the first CE, but first put the rest into the expansion buffer
if (!collationSource->JamoSpecial) { // FAST PATH
if (!jamoSpecial) { // FAST PATH
*(collationSource->CEpos++) = ucmp32_get(UCA->mapping, V);
if (T != TBase) {

View File

@ -76,7 +76,6 @@ struct collIterate {
uint32_t CEs[UCOL_EXPAND_CE_BUFFER_SIZE]; /* This is where we store CEs */
UBool isThai; /* Have we already encountered a Thai prevowel */
UBool isWritable; /* is the source buffer writable? */
UBool JamoSpecial;
UChar stackWritableBuffer[UCOL_WRITABLE_BUFFER_SIZE]; /* A writable buffer. */
UChar *writableBuffer;
};
@ -119,7 +118,6 @@ struct incrementalContext {
uint32_t *toReturn; /* This is the CE from CEs buffer that should be returned */
uint32_t *CEpos; /* This is the position to which we have stored processed CEs */
uint32_t CEs[UCOL_EXPAND_CE_BUFFER_SIZE]; /* This is where we store CEs */
UBool JamoSpecial;
UBool panic; /* can't handle it any more - we have to call the cavalry */
};
@ -206,6 +204,12 @@ struct incrementalContext {
*/
#define UCOL_ISTHAIBASECONSONANT(ch) ((uint32_t)(ch) - 0xe01) <= (0xe2e - 0xe01)
#define UCOL_ISJAMO(ch) ((((uint32_t)(ch) - 0x1100) <= (0x1112 - 0x1100)) || \
(((uint32_t)(ch) - 0x1161) <= (0x1175 - 0x1161)) || \
(((uint32_t)(ch) - 0x11A8) <= (0x11C2 - 0x11A8)))
/* initializes collIterate structure */
/* made as macro to speed up things */
#define init_collIterate(sourceString, sourceLen, s, isSourceWritable) { \
@ -215,7 +219,6 @@ struct incrementalContext {
(s)->isThai = TRUE; \
(s)->isWritable = (isSourceWritable); \
(s)->writableBuffer = (s)->stackWritableBuffer; \
(s)->JamoSpecial = FALSE; \
}
/* a macro that gets a simple CE */
@ -236,7 +239,8 @@ struct incrementalContext {
if((order) >= UCOL_NOT_FOUND) { \
(order) = getSpecialCE((coll), (order), &(collationSource), (status)); \
if((order) == UCOL_NOT_FOUND) { \
(order) = ucol_getNextUCA(ch, &(collationSource), (status)); \
(order) = ucol_getNextUCA(ch, &(collationSource), \
(coll)->image->jamoSpecial, (status)); \
} \
} \
} else { \
@ -278,7 +282,8 @@ struct incrementalContext {
(order) = getSpecialPrevCE((coll), (order), &(data), (length), \
(status)); \
if ((order) == UCOL_NOT_FOUND) { \
(order) = ucol_getPrevUCA(ch, &(data), (length), (status)); \
(order) = ucol_getPrevUCA(ch, &(data), (length), \
(coll)->image->jamoSpecial, (status)); \
} \
} \
} \
@ -330,9 +335,9 @@ uint32_t getSpecialPrevCE(const UCollator *coll, uint32_t CE,
collIterate *source, uint32_t length,
UErrorCode *status);
U_CFUNC uint32_t ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status);
uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UErrorCode *status);
uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UBool jamoSpecial, UErrorCode *status);
uint32_t ucol_getPrevUCA(UChar ch, collIterate *collationSource,
uint32_t length, UErrorCode *status);
uint32_t length, UBool jamoSpecial, UErrorCode *status);
void incctx_cleanUpContext(incrementalContext *ctx);
UChar incctx_appendChar(incrementalContext *ctx, UChar c);
@ -504,6 +509,7 @@ typedef struct {
UColAttributeValue caseLevel; /* do we have an extra case level */
UColAttributeValue normalizationMode; /* attribute for normalization */
UColAttributeValue strength; /* attribute for strength */
UBool jamoSpecial; /* is jamoSpecial */
} UCATableHeader;
typedef struct {
@ -573,7 +579,7 @@ UCollator* ucol_initCollator(const UCATableHeader *image, UCollator *fillIn, UEr
void ucol_setOptionsFromHeader(UCollator* result, const UCATableHeader * image, UErrorCode *status);
void ucol_putOptionsToHeader(UCollator* result, UCATableHeader * image, UErrorCode *status);
uint32_t ucol_getIncrementalUCA(UChar ch, incrementalContext *collationSource, UErrorCode *status);
uint32_t ucol_getIncrementalUCA(UChar ch, incrementalContext *collationSource, UBool jamoSpecial, UErrorCode *status);
int32_t ucol_getIncrementalSpecialCE(const UCollator *coll, uint32_t CE, incrementalContext *ctx, UErrorCode *status);
void ucol_updateInternalState(UCollator *coll);