ICU-1211 correcting what gets exported where

X-SVN-Rev: 6361
This commit is contained in:
Vladimir Weinstein 2001-10-20 01:09:31 +00:00
parent 4e2e55a6f3
commit d81ea96439
12 changed files with 97 additions and 19 deletions

View File

@ -753,6 +753,7 @@ void ucol_initUCA(UErrorCode *status) {
/* normalize it into the collIterate's writable buffer, */
/* switch the collIterate's state to use the writable buffer. */
/* */
static
void collIterNormalize(collIterate *collationSource)
{
UErrorCode status = U_ZERO_ERROR;
@ -1022,21 +1023,21 @@ inline uint32_t ucol_IGetNextCE(const UCollator *coll, collIterate *collationSou
/* because all of the UCA data is replicated in the latinOneMapping array */
order = coll->latinOneMapping[ch];
if (order > UCOL_NOT_FOUND) {
order = getSpecialCE(coll, ch, order, collationSource, status);
order = ucol_prv_getSpecialCE(coll, ch, order, collationSource, status);
}
}
else
{
order = ucmpe32_get(coll->mapping, ch); /* we'll go for slightly slower trie */
if(order > UCOL_NOT_FOUND) { /* if a CE is special */
order = getSpecialCE(coll, ch, order, collationSource, status); /* and try to get the special CE */
order = ucol_prv_getSpecialCE(coll, ch, 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 */
/* if we got here, the codepoint MUST be over 0xFF - so we look directly in the trie */
order = ucmpe32_get(UCA->mapping, ch);
if(order > UCOL_NOT_FOUND) { /* UCA also gives us a special CE */
order = getSpecialCE(UCA, ch, order, collationSource, status);
order = ucol_prv_getSpecialCE(UCA, ch, order, collationSource, status);
}
}
}
@ -1055,6 +1056,7 @@ U_CAPI uint32_t ucol_getNextCE(const UCollator *coll, collIterate *collationSour
* switch the collIterate's state to use the writable buffer.
* @param data collation iterator data
*/
static
void collPrevIterNormalize(collIterate *data)
{
UErrorCode status = U_ZERO_ERROR;
@ -1319,13 +1321,13 @@ inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
contraction
*/
if (ucol_contractionEndCP(ch, coll) && !isAtStartPrevIterate(data)) {
result = getSpecialPrevCE(coll, ch, UCOL_CONTRACTION, data, status);
result = ucol_prv_getSpecialPrevCE(coll, ch, UCOL_CONTRACTION, data, status);
}
else {
if (ch <= 0xFF) {
result = coll->latinOneMapping[ch];
if (result > UCOL_NOT_FOUND) {
result = getSpecialPrevCE(coll, ch, result, data, status);
result = ucol_prv_getSpecialPrevCE(coll, ch, result, data, status);
}
}
else {
@ -1339,7 +1341,7 @@ inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
result = ucmpe32_get(coll->mapping, ch);
}
if (result > UCOL_NOT_FOUND) {
result = getSpecialPrevCE(coll, ch, result, data, status);
result = ucol_prv_getSpecialPrevCE(coll, ch, result, data, status);
}
if (result == UCOL_NOT_FOUND) {
if (!isAtStartPrevIterate(data) &&
@ -1351,7 +1353,7 @@ inline uint32_t ucol_IGetPrevCE(const UCollator *coll, collIterate *data,
}
if (result > UCOL_NOT_FOUND) {
result = getSpecialPrevCE(UCA, ch, result, data, status);
result = ucol_prv_getSpecialPrevCE(UCA, ch, result, data, status);
}
}
}
@ -1629,7 +1631,7 @@ inline void setDiscontiguosAttribute(collIterate *source, UChar *buffer,
fcdposition = pos, pos = start of normalization buffer. if pos in
normalization buffer, we'll insert the copy infront of pos and point pos
to the start of the normalization buffer. why am i doing these copies?
well, so that the whole chunk of codes in the getNextCE, getSpecialCE does
well, so that the whole chunk of codes in the getNextCE, ucol_prv_getSpecialCE does
not require any changes, which be really painful. */
uint32_t length = u_strlen(buffer);;
if (source->flags & UCOL_ITER_INNORMBUF) {
@ -1661,6 +1663,7 @@ inline void setDiscontiguosAttribute(collIterate *source, UChar *buffer,
* @param constart index to the start character in the contraction table
* @return discontiguos collation element offset
*/
static
uint32_t getDiscontiguous(const UCollator *coll, collIterate *source,
const UChar *constart)
{
@ -1792,11 +1795,13 @@ inline uint32_t getImplicit(UChar32 cp, collIterate *collationSource, uint32_t h
return (r & UCOL_PRIMARYMASK) | 0x00000505; // This was 'order'
}
static
inline UChar getPrevNormalizedChar(collIterate *data);
/* This function handles the special CEs like contractions, expansions, surrogates, Thai */
/* It is called by getNextCE */
uint32_t getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status) {
uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status) {
collIterateState entryState;
backupState(source, &entryState);
@ -1870,7 +1875,7 @@ uint32_t getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate
// prefix data is stored backwards in the table.
const UChar *UCharOffset;
UChar schar, tchar;
UChar32 normOutput = 0;
//UChar32 normOutput = 0;
collIterateState prefixState;
backupState(source, &prefixState);
loadState(source, &entryState, TRUE);
@ -2289,6 +2294,7 @@ inline void normalizePrevContraction(collIterate *data)
* @param data collation element iterator data
* @return previous character
*/
static
inline UChar getPrevNormalizedChar(collIterate *data)
{
UChar prevch;
@ -2404,7 +2410,7 @@ inline uint32_t getPrevImplicit(UChar32 cp, collIterate *collationSource, uint32
* surrogates, Thai.
* It is called by both getPrevCE
*/
uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
collIterate *source,
UErrorCode *status)
{
@ -2485,7 +2491,7 @@ uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
collIterateState prefixState;
backupState(source, &prefixState);
//UChar *sourcePointer = source->pos;
UChar32 normOutput = 0;
//UChar32 normOutput = 0;
for(;;) {
// This loop will run once per source string character, for as long as we
// are matching a potential contraction sequence
@ -2770,6 +2776,7 @@ uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
/* This should really be a macro */
/* However, it is used only when stack buffers are not sufficiently big, and then we're messed up performance wise */
/* anyway */
static
uint8_t *reallocateBuffer(uint8_t **secondaries, uint8_t *secStart, uint8_t *second, uint32_t *secSize, uint32_t newSize, UErrorCode *status) {
#ifdef UCOL_DEBUG
fprintf(stderr, ".");
@ -2966,7 +2973,7 @@ int32_t ucol_getSortKeySize(const UCollator *coll, collIterate *s, int32_t curre
UBool compareIdent = (strength == UCOL_IDENTICAL);
UBool doCase = (coll->caseLevel == UCOL_ON);
UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
UBool qShifted = shifted && (compareQuad == 0);
//UBool qShifted = shifted && (compareQuad == 0);
UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
uint8_t fSecsBuff[UCOL_FSEC_BUF_SIZE];
@ -3313,7 +3320,7 @@ ucol_calcSortKey(const UCollator *coll,
UBool doCase = (coll->caseLevel == UCOL_ON);
UBool isFrenchSec = (coll->frenchCollation == UCOL_ON) && (compareSec == 0);
UBool shifted = (coll->alternateHandling == UCOL_SHIFTED);
UBool qShifted = shifted && (compareQuad == 0);
//UBool qShifted = shifted && (compareQuad == 0);
UBool doHiragana = (coll->hiraganaQ == UCOL_ON) && (compareQuad == 0);
const uint8_t *scriptOrder = coll->scriptOrder;
@ -4693,6 +4700,7 @@ U_CAPI UBool isTailored(const UCollator *coll, const UChar u, UErrorCode *status
/* TODO: make an incremental NFD Comparison function, which could */
/* be of general use */
static
UCollationResult ucol_checkIdent(collIterate *sColl, collIterate *tColl, UBool normalize)
{
int32_t comparison;
@ -4799,6 +4807,7 @@ inline void UCOL_INIT_CEBUF(ucol_CEBuf *b) {
(b)->endp = (b)->buf + UCOL_CEBUF_SIZE;
};
static
void ucol_CEBuf_Expand(ucol_CEBuf *b, collIterate *ci) {
uint32_t oldSize;
uint32_t newSize;

View File

@ -20,6 +20,7 @@
#include "ucol_bld.h"
#include "ucln_in.h"
static const InverseTableHeader* invUCA = NULL;
static UDataMemory* invUCA_DATA_MEM = NULL;
@ -48,6 +49,7 @@ isAcceptableInvUCA(void * /*context*/,
}
U_CDECL_END
static
int32_t ucol_inv_findCE(uint32_t CE, uint32_t SecondCE) {
uint32_t bottom = 0, top = invUCA->tableSize;
uint32_t i = 0;
@ -577,6 +579,7 @@ U_CFUNC void ucol_initBuffers(/*UColTokenParser *src,*/ UColTokListHeader *lh, U
}
}
static
uint32_t u_toLargeKana(const UChar *source, const uint32_t sourceLen, UChar *resBuf, const uint32_t resLen, UErrorCode *status) {
uint32_t i = 0;
UChar c;
@ -611,6 +614,7 @@ uint32_t u_toLargeKana(const UChar *source, const uint32_t sourceLen, UChar *res
return sourceLen;
}
static
uint32_t u_toSmallKana(const UChar *source, const uint32_t sourceLen, UChar *resBuf, const uint32_t resLen, UErrorCode *status) {
uint32_t i = 0;
UChar c;
@ -645,6 +649,7 @@ uint32_t u_toSmallKana(const UChar *source, const uint32_t sourceLen, UChar *res
return sourceLen;
}
static
uint8_t ucol_uprv_getCaseBits(const UCollator *UCA, const UChar *src, uint32_t len, UErrorCode *status) {
uint32_t i = 0;
UChar n[128];

View File

@ -38,7 +38,7 @@
#include "unicode/unistr.h"
#include "unicode/normlzr.h"
U_CFUNC
UCATableHeader *ucol_assembleTailoringTable(UColTokenParser *src, UErrorCode *status);
typedef struct {

View File

@ -22,6 +22,8 @@
#include "cmemory.h"
#include "unicode/uchar.h"
U_NAMESPACE_BEGIN
void uprv_growTable(ContractionTable *tbl, UErrorCode *status) {
if(tbl->position == tbl->size) {
uint32_t *newData = (uint32_t *)realloc(tbl->CEs, 2*tbl->size*sizeof(uint32_t));
@ -457,3 +459,4 @@ uint32_t uprv_cnttab_changeContraction(CntTable *table, uint32_t element, UChar
}
}
U_NAMESPACE_END

View File

@ -26,6 +26,8 @@
#include "ucol_elm.h"
#include "ucol_imp.h"
U_NAMESPACE_BEGIN
#define UPRV_CNTTAB_NEWELEMENT 0xFFFFFF
#define isCntTableElement(CE) (isSpecial((CE)) && \
@ -73,4 +75,6 @@ uint32_t uprv_cnttab_changeContraction(CntTable *table, uint32_t element, UChar
uint32_t uprv_cnttab_findCE(CntTable *table, uint32_t element, UChar codePoint, UErrorCode *status);
UBool uprv_cnttab_isTailored(CntTable *table, uint32_t element, UChar *ztString, UErrorCode *status);
U_NAMESPACE_END
#endif

View File

@ -26,6 +26,8 @@
#include "ucol_elm.h"
#include "unicode/uchar.h"
U_NAMESPACE_BEGIN
static uint32_t uprv_uca_processContraction(CntTable *contractions, UCAElements *element, uint32_t existingCE, UErrorCode *status);
U_CDECL_BEGIN
@ -1186,4 +1188,4 @@ UCATableHeader *uprv_uca_assembleTable(tempUCATable *t, UErrorCode *status) {
return myData;
}
U_NAMESPACE_END

View File

@ -30,6 +30,8 @@
#include <stdio.h>
#endif
U_NAMESPACE_BEGIN
typedef struct {
uint32_t *CEs;
int32_t position;
@ -96,4 +98,6 @@ U_CAPI uint32_t U_EXPORT2 uprv_uca_setRange(tempUCATable *t, UChar32 rangeStart,
#define paddedsize(something) ((something)+((((something)%4)!=0)?(4-(something)%4):0))
#define headersize (paddedsize(sizeof(UCATableHeader))+paddedsize(sizeof(UColOptionSet)))
U_NAMESPACE_END
#endif

View File

@ -247,8 +247,11 @@ struct UCollationElements
} \
}
uint32_t getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status);
uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
U_CFUNC
uint32_t ucol_prv_getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate *source, UErrorCode *status);
U_CFUNC
uint32_t ucol_prv_getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
collIterate *source, UErrorCode *status);
U_CAPI uint32_t U_EXPORT2 ucol_getNextCE(const UCollator *coll, collIterate *collationSource, UErrorCode *status);
U_CAPI uint32_t U_EXPORT2 ucol_getPrevCE(const UCollator *coll,
@ -265,6 +268,7 @@ ucol_getSortKeyWithAllocation(const UCollator *coll,
void *ucol_getABuffer(const UCollator *coll, uint32_t size);
/* worker function for generating sortkeys */
U_CFUNC
int32_t
ucol_calcSortKey(const UCollator *coll,
const UChar *source,
@ -274,6 +278,7 @@ ucol_calcSortKey(const UCollator *coll,
UBool allocatePrimary,
UErrorCode *status);
U_CFUNC
int32_t
ucol_calcSortKeySimpleTertiary(const UCollator *coll,
const UChar *source,
@ -283,6 +288,11 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll,
UBool allocatePrimary,
UErrorCode *status);
U_CFUNC
int32_t
ucol_getSortKeySize(const UCollator *coll, collIterate *s,
int32_t currentSize, UColAttributeValue strength,
int32_t len);
/**
* Makes a copy of the Collator's rule data. The format is
* that of .col files.
@ -640,13 +650,20 @@ struct UCollator {
};
/* various internal functions */
int32_t ucol_getIncrementalCE(const UCollator *coll, incrementalContext *ctx, UErrorCode *status);
U_CFUNC
void ucol_initUCA(UErrorCode *status);
U_CFUNC
UCollator* ucol_initCollator(const UCATableHeader *image, UCollator *fillIn, UErrorCode *status);
U_CFUNC
void ucol_setOptionsFromHeader(UCollator* result, UColOptionSet * opts, UErrorCode *status);
U_CFUNC
void ucol_putOptionsToHeader(UCollator* result, UColOptionSet * opts, UErrorCode *status);
U_CFUNC
void ucol_updateInternalState(UCollator *coll);
U_CAPI uint32_t U_EXPORT2 ucol_getFirstCE(const UCollator *coll, UChar u, UErrorCode *status);
@ -660,6 +677,11 @@ U_CAPI int32_t U_EXPORT2 ucol_inv_getNextCE(uint32_t CE, uint32_t contCE,
U_CAPI int32_t U_EXPORT2 ucol_inv_getPrevCE(uint32_t CE, uint32_t contCE,
uint32_t *prevCE, uint32_t *prevContCE,
uint32_t strength);
U_CFUNC
int32_t
ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
const uint8_t *src2, int32_t src2Length,
uint8_t *dest, int32_t destCapacity);

View File

@ -24,6 +24,8 @@
#include "cmemory.h"
#include "ucol_tok.h"
U_NAMESPACE_BEGIN
void ucol_tok_initTokenList(UColTokenParser *src, const UChar *rules, const uint32_t rulesLength, UCollator *UCA, UErrorCode *status) {
uint32_t nSize = 0;
uint32_t estimatedSize = (2*rulesLength+UCOL_TOK_EXTRA_RULE_SPACE_SIZE);
@ -1155,3 +1157,5 @@ void deleteToken(void *token) {
UColToken *tok = (UColToken *)token;
uprv_free(tok);
}
U_NAMESPACE_END

View File

@ -25,6 +25,8 @@
#include "uhash.h"
#include "unicode/parseerr.h"
U_NAMESPACE_BEGIN
#define UCOL_TOK_UNSET 0xFFFFFFFF
#define UCOL_TOK_RESET 0xDEADBEEF
@ -139,6 +141,8 @@ U_CFUNC int32_t uhash_hashTokens(const UHashTok k);
U_CFUNC UBool uhash_compareTokens(const UHashTok key1, const UHashTok key2);
U_CFUNC void deleteToken(void *token);
U_NAMESPACE_END
#endif

View File

@ -581,6 +581,8 @@ inline UTextOffset getNextSafeOffset(const UCollator *collator,
* @return TRUE if there is non-ignorable accents before at the beginning
* of the match, FALSE otherwise.
*/
static
UBool checkExtraMatchAccents(const UStringSearch *strsrch, UTextOffset start,
UTextOffset end,
UErrorCode *status)
@ -663,6 +665,7 @@ UBool checkExtraMatchAccents(const UStringSearch *strsrch, UTextOffset start,
* @return TRUE if there are accents on either side of the match,
* FALSE otherwise
*/
static
UBool hasAccentsBeforeMatch(const UStringSearch *strsrch, UTextOffset start,
UTextOffset end)
{
@ -734,6 +737,7 @@ UBool hasAccentsBeforeMatch(const UStringSearch *strsrch, UTextOffset start,
* @return TRUE if there are accents on either side of the match,
* FALSE otherwise
*/
static
UBool hasAccentsAfterMatch(const UStringSearch *strsrch, UTextOffset start,
UTextOffset end)
{
@ -869,6 +873,8 @@ inline UTextOffset getColElemIterOffset(const UCollationElements *coleiter,
* @param status error status if any
* @return TRUE if match passes the contraction test, FALSE otherwise
*/
static
UBool checkNextExactContractionMatch(UStringSearch *strsrch,
UTextOffset *start,
UTextOffset *end, UErrorCode *status)
@ -1129,6 +1135,7 @@ inline UBool checkCollationMatch(const UStringSearch *strsrch,
* @return USEARCH_DONE if a match is not found, otherwise return the starting
* offset of the match. Note this start includes all preceding accents.
*/
static
UTextOffset doNextCanonicalPrefixMatch(UStringSearch *strsrch,
UTextOffset start,
UTextOffset end,
@ -1253,6 +1260,7 @@ inline void cleanUpSafeText(const UStringSearch *strsrch, UChar *safetext,
* @return USEARCH_DONE if a match is not found, otherwise return the starting
* offset of the match. Note this start includes all preceding accents.
*/
static
UTextOffset doNextCanonicalSuffixMatch(UStringSearch *strsrch,
UTextOffset textoffset,
UErrorCode *status)
@ -1370,6 +1378,7 @@ UTextOffset doNextCanonicalSuffixMatch(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if the match is valid, FALSE otherwise
*/
static
UBool doNextCanonicalMatch(UStringSearch *strsrch,
UTextOffset textoffset,
UErrorCode *status)
@ -1467,6 +1476,7 @@ inline UTextOffset getPreviousUStringSearchBaseOffset(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if match passes the contraction test, FALSE otherwise
*/
static
UBool checkNextCanonicalContractionMatch(UStringSearch *strsrch,
UTextOffset *start,
UTextOffset *end,
@ -1555,6 +1565,7 @@ UBool checkNextCanonicalContractionMatch(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if the match is valid, FALSE otherwise
*/
static
inline UBool checkNextCanonicalMatch(UStringSearch *strsrch,
UTextOffset *textoffset,
UErrorCode *status)
@ -1661,6 +1672,7 @@ inline UTextOffset reverseShift(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if match passes the contraction test, FALSE otherwise
*/
static
UBool checkPreviousExactContractionMatch(UStringSearch *strsrch,
UTextOffset *start,
UTextOffset *end, UErrorCode *status)
@ -1737,6 +1749,7 @@ UBool checkPreviousExactContractionMatch(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if the match is valid, FALSE otherwise
*/
static
inline UBool checkPreviousExactMatch(UStringSearch *strsrch,
UTextOffset *textoffset,
UErrorCode *status)
@ -1785,6 +1798,7 @@ inline UBool checkPreviousExactMatch(UStringSearch *strsrch,
* @return USEARCH_DONE if a match is not found, otherwise return the ending
* offset of the match. Note this start includes all following accents.
*/
static
UTextOffset doPreviousCanonicalSuffixMatch(UStringSearch *strsrch,
UTextOffset start,
UTextOffset end,
@ -1868,6 +1882,7 @@ UTextOffset doPreviousCanonicalSuffixMatch(UStringSearch *strsrch,
* @return USEARCH_DONE if a match is not found, otherwise return the ending
* offset of the match. Note this start includes all following accents.
*/
static
UTextOffset doPreviousCanonicalPrefixMatch(UStringSearch *strsrch,
UTextOffset textoffset,
UErrorCode *status)
@ -1988,6 +2003,7 @@ UTextOffset doPreviousCanonicalPrefixMatch(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if the match is valid, FALSE otherwise
*/
static
UBool doPreviousCanonicalMatch(UStringSearch *strsrch,
UTextOffset textoffset,
UErrorCode *status)
@ -2061,6 +2077,7 @@ UBool doPreviousCanonicalMatch(UStringSearch *strsrch,
* @param status error status if any
* @return TRUE if match passes the contraction test, FALSE otherwise
*/
static
UBool checkPreviousCanonicalContractionMatch(UStringSearch *strsrch,
UTextOffset *start,
UTextOffset *end, UErrorCode *status)

View File

@ -90,6 +90,7 @@ struct UStringSearch {
* @param status error status if any
* @return TRUE if an exact match is found, FALSE otherwise
*/
U_CFUNC
UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status);
/**
@ -100,6 +101,7 @@ UBool usearch_handleNextExact(UStringSearch *strsrch, UErrorCode *status);
* @param status error status if any
* @return TRUE if a canonical match is found, FALSE otherwise
*/
U_CFUNC
UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status);
/**
@ -108,6 +110,7 @@ UBool usearch_handleNextCanonical(UStringSearch *strsrch, UErrorCode *status);
* @param strsrch string search data
* @param status error status if any
*/
U_CFUNC
UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status);
/**
@ -118,6 +121,7 @@ UBool usearch_handlePreviousExact(UStringSearch *strsrch, UErrorCode *status);
* @param status error status if any
* @return TRUE if a canonical match is found, FALSE otherwise
*/
U_CFUNC
UBool usearch_handlePreviousCanonical(UStringSearch *strsrch,
UErrorCode *status);