ICU-880 strcoll: More performance tweaks, plus fix inlines for UNIX builds.
X-SVN-Rev: 4502
This commit is contained in:
parent
53f50a5718
commit
fe8f7ca9cd
@ -70,7 +70,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMMON_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /Za /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMMON_EXPORTS" /D "U_COMMON_IMPLEMENTATION" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /Za /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMMON_EXPORTS" /D "U_COMMON_IMPLEMENTATION" /FR /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /WX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,12 +14,12 @@
|
||||
*
|
||||
* created on: 2000dec11
|
||||
* created by: Vladimir Weinstein
|
||||
*
|
||||
*
|
||||
* Modification history
|
||||
* Date Name Comments
|
||||
* 02/16/2001 synwee Added UCOL_GETPREVCE for the use in ucoleitr
|
||||
* 02/27/2001 synwee Added getMaxExpansion data structure in UCollator
|
||||
* 03/02/2001 synwee Added UCOL_IMPLICIT_CE
|
||||
* 02/27/2001 synwee Added getMaxExpansion data structure in UCollator
|
||||
* 03/02/2001 synwee Added UCOL_IMPLICIT_CE
|
||||
* 03/12/2001 synwee Added pointer start to collIterate.
|
||||
*/
|
||||
|
||||
@ -46,10 +46,10 @@
|
||||
|
||||
/* This writable buffer is used if we encounter Thai and need to reorder the string on the fly */
|
||||
/* Sometimes we already have a writable buffer (like in case of normalized strings). */
|
||||
/*
|
||||
you can change this value to any value >= 3 if you need memory -
|
||||
/*
|
||||
you can change this value to any value >= 3 if you need memory -
|
||||
it will affect the performance, though, since we're going to malloc.
|
||||
Note 3 is the minimum value for Thai collation to work correctly.
|
||||
Note 3 is the minimum value for Thai collation to work correctly.
|
||||
*/
|
||||
#define UCOL_WRITABLE_BUFFER_SIZE 256
|
||||
|
||||
@ -68,7 +68,7 @@ Note 3 is the minimum value for Thai collation to work correctly.
|
||||
#define UCOL_UNSAFECP_TABLE_SIZE 1056
|
||||
/* mask value down to "some power of two"-1 */
|
||||
/* number of bits, not num of bytes. */
|
||||
#define UCOL_UNSAFECP_TABLE_MASK 0x1fff
|
||||
#define UCOL_UNSAFECP_TABLE_MASK 0x1fff
|
||||
|
||||
|
||||
#define UCOL_RUNTIME_VERSION 1
|
||||
@ -81,11 +81,15 @@ Note 3 is the minimum value for Thai collation to work correctly.
|
||||
|
||||
#define UCOL_ITER_HASLEN 2
|
||||
|
||||
/* UCOL_ITER_INNORMBUF - set if the "pos" is in */
|
||||
/* the writable side buffer, handling */
|
||||
/* incrementally normalized characters. */
|
||||
/* UCOL_ITER_INNORMBUF - set if the "pos" is in */
|
||||
/* the writable side buffer, handling */
|
||||
/* incrementally normalized characters. */
|
||||
#define UCOL_ITER_INNORMBUF 4
|
||||
|
||||
/* UCOL_ITER_ALLOCATED - set if this iterator has */
|
||||
/* malloced storage to expand a buffer. */
|
||||
#define UCOL_ITER_ALLOCATED 8
|
||||
|
||||
#define NFC_ZERO_CC_BLOCK_LIMIT_ 0x300
|
||||
|
||||
struct collIterate {
|
||||
@ -102,7 +106,7 @@ struct collIterate {
|
||||
UChar *fcdPosition; /* Position in the original string to continue FCD check from. */
|
||||
const UCollator *coll;
|
||||
uint8_t flags;
|
||||
uint8_t origFlags;
|
||||
uint8_t origFlags;
|
||||
uint32_t CEs[UCOL_EXPAND_CE_BUFFER_SIZE]; /* This is where we store CEs */
|
||||
UChar stackWritableBuffer[UCOL_WRITABLE_BUFFER_SIZE]; /* A writable buffer. */
|
||||
};
|
||||
@ -125,7 +129,7 @@ struct UCollationElements
|
||||
{
|
||||
/**
|
||||
* Normalization mode, not exactly the same as the data in collator_.
|
||||
* If collation strength requested is UCOL_IDENTICAL, this mode will be
|
||||
* If collation strength requested is UCOL_IDENTICAL, this mode will be
|
||||
* UNORM_NONE otherwise it follows collator_.
|
||||
*/
|
||||
UNormalizationMode normalization_;
|
||||
@ -144,7 +148,7 @@ struct UCollationElements
|
||||
};
|
||||
|
||||
struct incrementalContext {
|
||||
UCharForwardIterator *source;
|
||||
UCharForwardIterator *source;
|
||||
void *sourceContext;
|
||||
UChar currentChar;
|
||||
UChar lastChar;
|
||||
@ -163,17 +167,17 @@ struct incrementalContext {
|
||||
#define UCOL_LEVELTERMINATOR 1
|
||||
|
||||
/* mask off anything but primary order */
|
||||
#define UCOL_PRIMARYORDERMASK 0xffff0000
|
||||
#define UCOL_PRIMARYORDERMASK 0xffff0000
|
||||
/* mask off anything but secondary order */
|
||||
#define UCOL_SECONDARYORDERMASK 0x0000ff00
|
||||
#define UCOL_SECONDARYORDERMASK 0x0000ff00
|
||||
/* mask off anything but tertiary order */
|
||||
#define UCOL_TERTIARYORDERMASK 0x000000ff
|
||||
#define UCOL_TERTIARYORDERMASK 0x000000ff
|
||||
/* primary order shift */
|
||||
#define UCOL_PRIMARYORDERSHIFT 16
|
||||
#define UCOL_PRIMARYORDERSHIFT 16
|
||||
/* secondary order shift */
|
||||
#define UCOL_SECONDARYORDERSHIFT 8
|
||||
#define UCOL_SECONDARYORDERSHIFT 8
|
||||
|
||||
#define UCOL_BYTE_SIZE_MASK 0xFF
|
||||
#define UCOL_BYTE_SIZE_MASK 0xFF
|
||||
|
||||
#define UCOL_CASE_BYTE_START 0x80
|
||||
#define UCOL_CASE_SHIFT_START 7
|
||||
@ -223,27 +227,6 @@ struct incrementalContext {
|
||||
#endif
|
||||
|
||||
|
||||
/* CEBuf - a growable buffer for holding CEs during strcoll */
|
||||
#define UCOL_CEBUF_SIZE 512
|
||||
typedef struct ucol_CEBuf {
|
||||
uint32_t *buf;
|
||||
uint32_t *endp;
|
||||
uint32_t *pos;
|
||||
uint32_t localArray[UCOL_CEBUF_SIZE];
|
||||
} ucol_CEBuf;
|
||||
|
||||
|
||||
#define UCOL_INIT_CEBUF(b) { \
|
||||
(b)->buf = (b)->pos = (b)->localArray; \
|
||||
(b)->endp = (b)->buf + UCOL_CEBUF_SIZE; \
|
||||
}
|
||||
|
||||
void ucol_CEBuf_Expand(ucol_CEBuf *b);
|
||||
|
||||
#define UCOL_CEBUF_PUT(b, ce) { \
|
||||
if ((b)->pos == (b)->endp) ucol_CEBuf_Expand(b); \
|
||||
*(b)->pos++ = ce; \
|
||||
}
|
||||
|
||||
/* a macro that gets a simple CE */
|
||||
/* for more complicated CEs it resorts to getComplicatedCE (what else) */
|
||||
@ -271,7 +254,7 @@ void ucol_CEBuf_Expand(ucol_CEBuf *b);
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Macro to get the maximum size of an expansion ending with the argument ce.
|
||||
* Used in the Boyer Moore algorithm.
|
||||
* Note for tailoring, the UCA maxexpansion table has been merged.
|
||||
@ -312,11 +295,11 @@ void ucol_CEBuf_Expand(ucol_CEBuf *b);
|
||||
}
|
||||
|
||||
uint32_t getSpecialCE(const UCollator *coll, uint32_t CE, collIterate *source, UErrorCode *status);
|
||||
uint32_t getSpecialPrevCE(const UCollator *coll, uint32_t CE,
|
||||
uint32_t getSpecialPrevCE(const UCollator *coll, 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,
|
||||
collIterate *collationSource,
|
||||
U_CAPI uint32_t U_EXPORT2 ucol_getPrevCE(const UCollator *coll,
|
||||
collIterate *collationSource,
|
||||
UErrorCode *status);
|
||||
uint32_t ucol_getNextUCA(UChar ch, collIterate *collationSource, UErrorCode *status);
|
||||
uint32_t ucol_getPrevUCA(UChar ch, collIterate *collationSource, UErrorCode *status);
|
||||
@ -325,7 +308,7 @@ void incctx_cleanUpContext(incrementalContext *ctx);
|
||||
UChar incctx_appendChar(incrementalContext *ctx, UChar c);
|
||||
|
||||
/* function used by C++ getCollationKey to prevent restarting the calculation */
|
||||
U_CFUNC uint8_t *ucol_getSortKeyWithAllocation(const UCollator *coll,
|
||||
U_CFUNC uint8_t *ucol_getSortKeyWithAllocation(const UCollator *coll,
|
||||
const UChar *source,
|
||||
int32_t sourceLength, int32_t *resultLen);
|
||||
|
||||
@ -354,7 +337,7 @@ ucol_calcSortKeySimpleTertiary(const UCollator *coll,
|
||||
/**
|
||||
* Makes a copy of the Collator's rule data. The format is
|
||||
* that of .col files.
|
||||
*
|
||||
*
|
||||
* @param length returns the length of the data, in bytes.
|
||||
* @param status the error status
|
||||
* @return memory, owned by the caller, of size 'length' bytes.
|
||||
@ -372,7 +355,7 @@ ucol_cloneRuleData(UCollator *coll, int32_t *length, UErrorCode *status);
|
||||
#define UCOL_CONTRACTION 0xF2000000
|
||||
#define UCOL_THAI 0xF3000000
|
||||
#define UCOL_UNMARKED 0x03
|
||||
#define UCOL_NEW_TERTIARYORDERMASK 0x0000003f
|
||||
#define UCOL_NEW_TERTIARYORDERMASK 0x0000003f
|
||||
|
||||
/* Bit mask for primary collation strength. */
|
||||
#define UCOL_PRIMARYMASK 0xFFFF0000
|
||||
@ -383,9 +366,9 @@ ucol_cloneRuleData(UCollator *coll, int32_t *length, UErrorCode *status);
|
||||
/* Bit mask for tertiary collation strength. */
|
||||
#define UCOL_TERTIARYMASK 0x000000FF
|
||||
|
||||
/**
|
||||
/**
|
||||
* Internal.
|
||||
* This indicates the last element in a UCollationElements has been consumed.
|
||||
* This indicates the last element in a UCollationElements has been consumed.
|
||||
* Compare with the UCOL_NULLORDER, UCOL_NULLORDER is returned if error occurs.
|
||||
*/
|
||||
#define UCOL_NO_MORE_CES 0x00010101
|
||||
@ -411,14 +394,14 @@ ucol_cloneRuleData(UCollator *coll, int32_t *length, UErrorCode *status);
|
||||
#define UCOL_FLAG_BIT_MASK 0x80
|
||||
#define INVC_DATA_TYPE "dat"
|
||||
#define INVC_DATA_NAME "invuca"
|
||||
#define UCOL_COMMON_TOP2 0x79
|
||||
#define UCOL_COMMON_BOT2 0x03
|
||||
#define UCOL_TOP_COUNT2 0x40
|
||||
#define UCOL_COMMON_TOP2 0x79
|
||||
#define UCOL_COMMON_BOT2 0x03
|
||||
#define UCOL_TOP_COUNT2 0x40
|
||||
#define UCOL_BOT_COUNT2 0x3D
|
||||
|
||||
#define UCOL_COMMON_TOP3 0x84
|
||||
#define UCOL_COMMON_BOT3 0x03
|
||||
#define UCOL_TOP_COUNT3 0x40
|
||||
#define UCOL_COMMON_TOP3 0x84
|
||||
#define UCOL_COMMON_BOT3 0x03
|
||||
#define UCOL_TOP_COUNT3 0x40
|
||||
#define UCOL_BOT_COUNT3 0x40
|
||||
|
||||
#define UCOL_COMMON2 0x03
|
||||
@ -470,11 +453,11 @@ typedef struct {
|
||||
uint32_t contractionCEs; /* uint32_t *contractionCEs; */
|
||||
uint32_t contractionSize; /* needed for various closures */
|
||||
uint32_t latinOneMapping; /* fast track to latin1 chars */
|
||||
|
||||
uint32_t endExpansionCE; /* array of last collation element in
|
||||
|
||||
uint32_t endExpansionCE; /* array of last collation element in
|
||||
expansion */
|
||||
uint32_t expansionCESize; /* array of maximum expansion size
|
||||
corresponding to the expansion
|
||||
uint32_t expansionCESize; /* array of maximum expansion size
|
||||
corresponding to the expansion
|
||||
collation elements with last element
|
||||
in endExpansionCE*/
|
||||
int32_t endExpansionCECount; /* size of endExpansionCE */
|
||||
@ -512,11 +495,11 @@ struct UCollator {
|
||||
UBool freeOnClose;
|
||||
UResourceBundle *rb;
|
||||
const UCATableHeader *image;
|
||||
CompactIntArray *mapping;
|
||||
CompactIntArray *mapping;
|
||||
const uint32_t *latinOneMapping;
|
||||
const uint32_t *expansion;
|
||||
const UChar *contractionIndex;
|
||||
const uint32_t *contractionCEs;
|
||||
const uint32_t *expansion;
|
||||
const UChar *contractionIndex;
|
||||
const uint32_t *contractionCEs;
|
||||
const uint8_t *scriptOrder;
|
||||
uint8_t variableMax1;
|
||||
uint8_t variableMax2;
|
||||
@ -548,11 +531,12 @@ struct UCollator {
|
||||
const uint32_t *endExpansionCE; /* array of last ces in an expansion ce.
|
||||
corresponds to expansionCESize */
|
||||
const uint32_t *lastEndExpansionCE;/* pointer to the last element in endExpansionCE */
|
||||
const uint8_t *expansionCESize; /* array of the maximum size of a
|
||||
expansion ce with the last ce
|
||||
corresponding to endExpansionCE,
|
||||
const uint8_t *expansionCESize; /* array of the maximum size of a
|
||||
expansion ce with the last ce
|
||||
corresponding to endExpansionCE,
|
||||
terminated with a null */
|
||||
const uint8_t *unsafeCP; /* unsafe code points hashtable */
|
||||
const uint8_t *unsafeCP; /* unsafe code points hashtable */
|
||||
UChar minUnsafeCP; /* Smallest unsafe Code Point. */
|
||||
};
|
||||
|
||||
/* various internal functions */
|
||||
@ -576,11 +560,11 @@ U_CAPI char U_EXPORT2 *ucol_sortKeyToString(const UCollator *coll, const uint8_t
|
||||
U_CAPI UBool U_EXPORT2 isTailored(const UCollator *coll, const UChar u, UErrorCode *status);
|
||||
|
||||
U_CAPI const U_EXPORT2 InverseTableHeader *ucol_initInverseUCA(UErrorCode *status);
|
||||
U_CAPI int32_t U_EXPORT2 ucol_inv_getNextCE(uint32_t CE, uint32_t contCE,
|
||||
uint32_t *nextCE, uint32_t *nextContCE,
|
||||
U_CAPI int32_t U_EXPORT2 ucol_inv_getNextCE(uint32_t CE, uint32_t contCE,
|
||||
uint32_t *nextCE, uint32_t *nextContCE,
|
||||
uint32_t strength);
|
||||
U_CAPI int32_t U_EXPORT2 ucol_inv_getPrevCE(uint32_t CE, uint32_t contCE,
|
||||
uint32_t *prevCE, uint32_t *prevContCE,
|
||||
U_CAPI int32_t U_EXPORT2 ucol_inv_getPrevCE(uint32_t CE, uint32_t contCE,
|
||||
uint32_t *prevCE, uint32_t *prevContCE,
|
||||
uint32_t strength);
|
||||
|
||||
void collIterFCD(collIterate *ci);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2001, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
@ -8,7 +8,7 @@
|
||||
* File CITERTST.C
|
||||
*
|
||||
* Modification History:
|
||||
* Date Name Description
|
||||
* Date Name Description
|
||||
* Madhu Katragadda Ported for C API
|
||||
* 02/19/01 synwee Modified test case for new collation iterator
|
||||
*********************************************************************************/
|
||||
@ -35,7 +35,7 @@ void addCollIterTest(TestNode** root)
|
||||
addTest(root, &TestSetText, "tscoll/citertst/TestSetText");
|
||||
addTest(root, &TestMaxExpansion, "tscoll/citertst/TestMaxExpansion");
|
||||
addTest(root, &TestUnicodeChar, "tscoll/citertst/TestUnicodeChar");
|
||||
addTest(root, &TestNormalizedUnicodeChar,
|
||||
addTest(root, &TestNormalizedUnicodeChar,
|
||||
"tscoll/citertst/TestNormalizedUnicodeChar");
|
||||
addTest(root, &TestBug672, "tscoll/citertst/TestBug672");
|
||||
addTest(root, &TestSmallBuffer, "tscoll/citertst/TestSmallBuffer");
|
||||
@ -62,18 +62,18 @@ static void TestBug672() {
|
||||
UCollationElements *titer = ucol_openElements(coll, text, -1,
|
||||
&status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("ERROR: in creation of either the collator or the collation iterator :%s\n",
|
||||
log_err("ERROR: in creation of either the collator or the collation iterator :%s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
log_verbose("locale tested %s\n", LOCALES[i]);
|
||||
|
||||
while (ucol_next(pitr, &status) != UCOL_NULLORDER &&
|
||||
while (ucol_next(pitr, &status) != UCOL_NULLORDER &&
|
||||
U_SUCCESS(status)) {
|
||||
}
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("ERROR: reversing collation iterator :%s\n",
|
||||
log_err("ERROR: reversing collation iterator :%s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -81,13 +81,13 @@ static void TestBug672() {
|
||||
|
||||
ucol_setOffset(titer, u_strlen(pattern), &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("ERROR: setting offset in collator :%s\n",
|
||||
log_err("ERROR: setting offset in collator :%s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
result[i][0] = ucol_getOffset(titer);
|
||||
log_verbose("Text iterator set to offset %d\n", result[i][0]);
|
||||
|
||||
|
||||
/* Use previous() */
|
||||
ucol_previous(titer, &status);
|
||||
result[i][1] = ucol_getOffset(titer);
|
||||
@ -97,7 +97,7 @@ static void TestBug672() {
|
||||
log_verbose("Adding one to current offset...\n");
|
||||
ucol_setOffset(titer, ucol_getOffset(titer) + 1, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("ERROR: setting offset in collator :%s\n",
|
||||
log_err("ERROR: setting offset in collator :%s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -127,12 +127,12 @@ static void TestUnicodeChar()
|
||||
|
||||
UChar *test;
|
||||
en_us = ucol_open("en_US", &status);
|
||||
|
||||
|
||||
for (codepoint = 1; codepoint < 0xFFFE;)
|
||||
{
|
||||
test = source;
|
||||
|
||||
while (codepoint % 0xFF != 0)
|
||||
while (codepoint % 0xFF != 0)
|
||||
{
|
||||
if (u_isdefined(codepoint))
|
||||
*(test ++) = codepoint;
|
||||
@ -141,14 +141,14 @@ static void TestUnicodeChar()
|
||||
|
||||
if (u_isdefined(codepoint))
|
||||
*(test ++) = codepoint;
|
||||
|
||||
|
||||
if (codepoint != 0xFFFF)
|
||||
codepoint ++;
|
||||
|
||||
*test = 0;
|
||||
*test = 0;
|
||||
iter=ucol_openElements(en_us, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(en_us);
|
||||
return;
|
||||
@ -181,7 +181,7 @@ static void TestNormalizedUnicodeChar()
|
||||
{
|
||||
test = source;
|
||||
|
||||
while (codepoint % 0xFF != 0)
|
||||
while (codepoint % 0xFF != 0)
|
||||
{
|
||||
if (u_isdefined(codepoint))
|
||||
*(test ++) = codepoint;
|
||||
@ -190,19 +190,19 @@ static void TestNormalizedUnicodeChar()
|
||||
|
||||
if (u_isdefined(codepoint))
|
||||
*(test ++) = codepoint;
|
||||
|
||||
|
||||
if (codepoint != 0xFFFF)
|
||||
codepoint ++;
|
||||
|
||||
*test = 0;
|
||||
*test = 0;
|
||||
iter=ucol_openElements(th_th, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(th_th);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
backAndForth(iter);
|
||||
ucol_closeElements(iter);
|
||||
}
|
||||
@ -214,7 +214,7 @@ static void TestNormalizedUnicodeChar()
|
||||
* Test for CollationElementIterator.previous()
|
||||
*
|
||||
* @bug 4108758 - Make sure it works with contracting characters
|
||||
*
|
||||
*
|
||||
*/
|
||||
static void TestPrevious()
|
||||
{
|
||||
@ -224,7 +224,7 @@ static void TestPrevious()
|
||||
UCollator *c1, *c2, *c3;
|
||||
UCollationElements *iter;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
test1=(UChar*)malloc(sizeof(UChar) * 50);
|
||||
test2=(UChar*)malloc(sizeof(UChar) * 50);
|
||||
u_uastrcpy(test1, "What subset of all possible test cases?");
|
||||
@ -233,7 +233,7 @@ static void TestPrevious()
|
||||
|
||||
iter=ucol_openElements(coll, test1, u_strlen(test1), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(coll);
|
||||
return;
|
||||
@ -252,7 +252,7 @@ static void TestPrevious()
|
||||
|
||||
if (c1 == NULL || U_FAILURE(status))
|
||||
{
|
||||
log_err("Couldn't create a RuleBasedCollator with a contracting sequence\n %s\n",
|
||||
log_err("Couldn't create a RuleBasedCollator with a contracting sequence\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -260,7 +260,7 @@ static void TestPrevious()
|
||||
u_uastrcpy(source, "abchdcba");
|
||||
iter=ucol_openElements(c1, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -274,15 +274,15 @@ static void TestPrevious()
|
||||
c2 = ucol_openRules(rule, u_strlen(rule), UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH, &status);
|
||||
if (c2 == NULL || U_FAILURE(status))
|
||||
{
|
||||
log_err("Couldn't create a RuleBasedCollator with a contracting sequence.\n %s\n",
|
||||
log_err("Couldn't create a RuleBasedCollator with a contracting sequence.\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
source=(UChar*)malloc(sizeof(UChar) * 5);
|
||||
source=(UChar*)malloc(sizeof(UChar) * 5);
|
||||
u_uastrcpy(source, "abcd");
|
||||
iter=ucol_openElements(c2, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -295,15 +295,15 @@ static void TestPrevious()
|
||||
c3 = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT_STRENGTH, &status);
|
||||
if (c3 == NULL || U_FAILURE(status))
|
||||
{
|
||||
log_err("Couldn't create a RuleBasedCollator with a contracting sequence.\n %s\n",
|
||||
log_err("Couldn't create a RuleBasedCollator with a contracting sequence.\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
source=(UChar*)malloc(sizeof(UChar) * 10);
|
||||
source=(UChar*)malloc(sizeof(UChar) * 10);
|
||||
u_uastrcpy(source, "abcdbchdc");
|
||||
iter=ucol_openElements(c3, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -325,7 +325,7 @@ static void TestPrevious()
|
||||
|
||||
iter=ucol_openElements(coll, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -344,7 +344,7 @@ static void TestPrevious()
|
||||
|
||||
iter=ucol_openElements(coll, source, u_strlen(source), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
return;
|
||||
}
|
||||
@ -361,7 +361,7 @@ static void TestPrevious()
|
||||
* Test for getOffset() and setOffset()
|
||||
*/
|
||||
static void TestOffset()
|
||||
{
|
||||
{
|
||||
UErrorCode status= U_ZERO_ERROR;
|
||||
UCollator *en_us=NULL;
|
||||
UCollationElements *iter, *pristine;
|
||||
@ -376,7 +376,7 @@ static void TestOffset()
|
||||
log_verbose("Testing getOffset and setOffset for CollationElements\n");
|
||||
iter=ucol_openElements(en_us, test1, u_strlen(test1), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(en_us);
|
||||
return;
|
||||
@ -389,14 +389,14 @@ static void TestOffset()
|
||||
|
||||
if (offset != u_strlen(test1))
|
||||
{
|
||||
log_err("offset at end != length %d vs %d\n", offset,
|
||||
log_err("offset at end != length %d vs %d\n", offset,
|
||||
u_strlen(test1) );
|
||||
}
|
||||
|
||||
/* Now set the offset back to the beginning and see if it works */
|
||||
pristine=ucol_openElements(en_us, test1, u_strlen(test1), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(en_us);
|
||||
return;
|
||||
@ -438,19 +438,19 @@ static void TestSetText()
|
||||
log_verbose("testing setText for Collation elements\n");
|
||||
iter1=ucol_openElements(en_us, test1, u_strlen(test1), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator1 using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator1 using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(en_us);
|
||||
return;
|
||||
}
|
||||
iter2=ucol_openElements(en_us, test2, u_strlen(test2), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator2 using ucol_openElements()\n %s\n",
|
||||
log_err("ERROR: in creation of collation element iterator2 using ucol_openElements()\n %s\n",
|
||||
myErrorName(status));
|
||||
ucol_close(en_us);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Run through the second iterator just to exercise it */
|
||||
c = ucol_next(iter2, &status);
|
||||
i = 0;
|
||||
@ -479,7 +479,7 @@ static void TestSetText()
|
||||
{
|
||||
assertEqual(iter1, iter2);
|
||||
}
|
||||
|
||||
|
||||
ucol_closeElements(iter2);
|
||||
ucol_closeElements(iter1);
|
||||
ucol_close(en_us);
|
||||
@ -497,12 +497,12 @@ static void backAndForth(UCollationElements *iter)
|
||||
int32_t orderLength = 0;
|
||||
int32_t *orders;
|
||||
orders= getOrders(iter, &orderLength);
|
||||
|
||||
|
||||
|
||||
|
||||
/* Now go through it backwards and make sure we get the same values */
|
||||
index = orderLength;
|
||||
ucol_reset(iter);
|
||||
|
||||
|
||||
/* synwee : changed */
|
||||
while ((o = ucol_previous(iter, &status)) != UCOL_NULLORDER)
|
||||
{
|
||||
@ -548,7 +548,7 @@ static void backAndForth(UCollationElements *iter)
|
||||
log_verbose("\n");
|
||||
}
|
||||
|
||||
free(orders);
|
||||
free(orders);
|
||||
}
|
||||
|
||||
/** @bug 4108762
|
||||
@ -556,39 +556,39 @@ static void backAndForth(UCollationElements *iter)
|
||||
*/
|
||||
static void TestMaxExpansion()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UCollator *coll ;/*= ucol_open("en_US", &status);*/
|
||||
UChar ch = 0;
|
||||
UCollationElements *iter ;/*= ucol_openElements(coll, &ch, 1, &status);*/
|
||||
|
||||
|
||||
UChar rule[256];
|
||||
u_uastrcpy(rule, "&a < ab < c/aba < d < z < ch");
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT_NORMALIZATION,
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH, &status);
|
||||
iter = ucol_openElements(coll, &ch, 1, &status);
|
||||
|
||||
|
||||
while (ch < 0xFFFF && U_SUCCESS(status)) {
|
||||
int count = 1;
|
||||
uint32_t order;
|
||||
ch++;
|
||||
ucol_setText(iter, &ch, 1, &status);
|
||||
order = ucol_previous(iter, &status);
|
||||
|
||||
|
||||
/* thai management */
|
||||
if (order == 0)
|
||||
order = ucol_previous(iter, &status);
|
||||
|
||||
while (U_SUCCESS(status) &&
|
||||
|
||||
while (U_SUCCESS(status) &&
|
||||
ucol_previous(iter, &status) != UCOL_NULLORDER) {
|
||||
count ++;
|
||||
count ++;
|
||||
}
|
||||
|
||||
|
||||
if (U_FAILURE(status) && ucol_getMaxExpansion(iter, order) < count) {
|
||||
log_err("Failure at codepoint %d, maximum expansion count < %d\n",
|
||||
ch, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ucol_closeElements(iter);
|
||||
ucol_close(coll);
|
||||
}
|
||||
@ -618,7 +618,7 @@ static int32_t* getOrders(UCollationElements *iter, int32_t *orderLength)
|
||||
memcpy(temp, orders, size * sizeof(int32_t));
|
||||
free(orders);
|
||||
orders = temp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
orders[size++] = order;
|
||||
@ -667,19 +667,19 @@ static void assertEqual(UCollationElements *i1, UCollationElements *i2)
|
||||
while (c1 != UCOL_NULLORDER);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Testing iterators with extremely small buffers
|
||||
*/
|
||||
static void TestSmallBuffer()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UCollator *coll;
|
||||
UCollationElements *iter;
|
||||
int count = 0;
|
||||
uint32_t *orders;
|
||||
|
||||
|
||||
UChar str[500];
|
||||
/*
|
||||
/*
|
||||
creating a long string of decomposable characters,
|
||||
since by default the writable buffer is of size 256
|
||||
*/
|
||||
@ -695,7 +695,7 @@ static void TestSmallBuffer()
|
||||
coll = ucol_open("th_TH", &status);
|
||||
iter = ucol_openElements(coll, str, 500, &status);
|
||||
|
||||
/*
|
||||
/*
|
||||
this will rearrange the string data to 250 characters of 0x300 first then
|
||||
250 characters of 0x031A
|
||||
*/
|
||||
@ -713,7 +713,7 @@ static void TestSmallBuffer()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(orders);
|
||||
ucol_closeElements(iter);
|
||||
ucol_close(coll);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /Ox /Op /I "..\..\..\include" /I "..\..\..\source\common" /I "..\..\tools\toolutil" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /Zi /Ox /Op /Ob0 /I "..\..\..\include" /I "..\..\..\source\common" /I "..\..\tools\toolutil" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
Loading…
Reference in New Issue
Block a user