mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-20 20:19:32 +00:00
ICU-861
Updated UCOL_GETPREVCE. X-SVN-Rev: 3733
This commit is contained in:
parent
c60ff4212c
commit
1966b36a04
5 changed files with 69 additions and 49 deletions
|
@ -41,7 +41,7 @@
|
|||
/* synwee : public can't remove */
|
||||
int32_t const CollationElementIterator::NULLORDER = 0xffffffff;
|
||||
// int32_t const CollationElementIterator::UNMAPPEDCHARVALUE = 0x7fff0000;
|
||||
int32_t const CollationElementIterator::NO_MORE_CES = 0x00010101;
|
||||
// int32_t const CollationElementIterator::NO_MORE_CES = 0x00010101;
|
||||
|
||||
/* CollationElementIterator public constructor/destructor ------------------ */
|
||||
|
||||
|
@ -68,8 +68,7 @@ UTextOffset CollationElementIterator::getOffset() const
|
|||
/**
|
||||
* Get the ordering priority of the next character in the string.
|
||||
* @return the next character's ordering. Returns NULLORDER if an error has
|
||||
* occured otherwise if the end of string has been reached,
|
||||
* NO_MORE_CES is returned.
|
||||
* occured or if the end of string has been reached
|
||||
*/
|
||||
int32_t CollationElementIterator::next(UErrorCode& status)
|
||||
{
|
||||
|
@ -190,8 +189,7 @@ UBool CollationElementIterator::operator==(
|
|||
* Get the ordering priority of the previous collation element in the string.
|
||||
* @param status the error code status.
|
||||
* @return the previous element's ordering. Returns NULLORDER if an error has
|
||||
* occured otherwise if the start of string has been reached,
|
||||
* NO_MORE_CES is returned.
|
||||
* occured or if the start of string has been reached.
|
||||
*/
|
||||
int32_t CollationElementIterator::previous(UErrorCode& status)
|
||||
{
|
||||
|
|
|
@ -102,6 +102,37 @@ ucol_next(UCollationElements *elems,
|
|||
|
||||
int32_t result;
|
||||
UCOL_GETNEXTCE(result, elems->collator_, elems->iteratordata_, status);
|
||||
/*
|
||||
if ((elems->iteratordata_).CEpos > (elems->iteratordata_).toReturn)
|
||||
{
|
||||
result = *((elems->iteratordata_).toReturn++);
|
||||
if ((elems->iteratordata_).CEpos == (elems->iteratordata_).toReturn)
|
||||
(elems->iteratordata_).CEpos = (elems->iteratordata_).toReturn =
|
||||
(elems->iteratordata_).CEs;
|
||||
}
|
||||
else
|
||||
if ((elems->iteratordata_).pos < (elems->iteratordata_).len)
|
||||
{
|
||||
UChar ch = *(elems->iteratordata_).pos++;
|
||||
if (ch <= 0xFF)
|
||||
(result) = (elems->collator_)->latinOneMapping[ch];
|
||||
else
|
||||
(result) = ucmp32_get((elems->collator_)->mapping, ch);
|
||||
|
||||
if((result) >= UCOL_NOT_FOUND)
|
||||
{
|
||||
(result) = getSpecialCE((elems->collator_), (result),
|
||||
&(elems->iteratordata_), (status));
|
||||
if ((result) == UCOL_NOT_FOUND)
|
||||
(result) = ucol_getNextUCA(ch, &(elems->iteratordata_), (status));
|
||||
}
|
||||
}
|
||||
else
|
||||
(result) = UCOL_NO_MORE_CES;
|
||||
*/
|
||||
|
||||
if (result == UCOL_NO_MORE_CES)
|
||||
result = UCOL_NULLORDER;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -113,28 +144,28 @@ ucol_previous(UCollationElements *elems,
|
|||
return UCOL_NULLORDER;
|
||||
|
||||
int32_t result;
|
||||
/* UCOL_GETPREVCE(result, elems->collator_, elems->iteratordata_,
|
||||
elems->length_, status); */
|
||||
UCOL_GETPREVCE(result, elems->collator_, elems->iteratordata_,
|
||||
elems->length_, status);
|
||||
|
||||
/* synwee : to be removed, only for testing */
|
||||
/* synwee : to be removed, only for testing
|
||||
const UCollator *coll = elems->collator_;
|
||||
collIterate *data = &(elems->iteratordata_);
|
||||
int32_t length = elems->length_;
|
||||
|
||||
if (data->CEpos > data->CEs)
|
||||
{
|
||||
(result) = *(data->toReturn --);
|
||||
{
|
||||
data->toReturn --;
|
||||
(result) = *(data->toReturn);
|
||||
if (data->CEs == data->toReturn)
|
||||
data->CEpos = data->toReturn = data->CEs;
|
||||
data->CEpos = data->toReturn = data->CEs;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
pointers are always at the next position to be retrieved for getnextce
|
||||
/* pointers are always at the next position to be retrieved for getnextce
|
||||
for every first previous step after a next, value returned will the same
|
||||
as the last next value
|
||||
*/
|
||||
if (data->len - data->pos == length)
|
||||
/*if (data->len - data->pos == length)
|
||||
(result) = UCOL_NO_MORE_CES;
|
||||
else
|
||||
{
|
||||
|
@ -161,7 +192,10 @@ ucol_previous(UCollationElements *elems,
|
|||
(result) = ucol_getPrevUCA(ch, data, length, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
if (result == UCOL_NO_MORE_CES)
|
||||
result = UCOL_NULLORDER;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -232,28 +232,29 @@ struct incrementalContext {
|
|||
* For more complicated CEs it resorts to getComplicatedCE.
|
||||
*/
|
||||
#define UCOL_GETPREVCE(order, coll, data, length, status) { \
|
||||
if (data.CEpos > data.CEs) { \
|
||||
(order) = *(data.toReturn --); \
|
||||
if (data.CEs == data.toReturn) { \
|
||||
data.CEpos = data.toReturn = data.CEs; \
|
||||
if ((data).CEpos > (data).CEs) { \
|
||||
(data).toReturn --; \
|
||||
(order) = *((data).toReturn); \
|
||||
if ((data).CEs == (data).toReturn) { \
|
||||
(data).CEpos = (data).toReturn = (data).CEs; \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
if (data.len - data.pos == length) { \
|
||||
if ((data).len - (data).pos == length) { \
|
||||
(order) = UCOL_NO_MORE_CES; \
|
||||
} \
|
||||
else { \
|
||||
UChar ch; \
|
||||
if (data.pos != data.writableBuffer) { \
|
||||
data.pos --; \
|
||||
if ((data).pos != (data).writableBuffer) { \
|
||||
(data).pos --; \
|
||||
} \
|
||||
else { \
|
||||
data.pos = data.string + \
|
||||
(length - (data.len - data.writableBuffer)); \
|
||||
data.len = data.string + length; \
|
||||
data.isThai = TRUE; \
|
||||
(data).pos = (data).string + \
|
||||
(length - ((data).len - (data).writableBuffer)); \
|
||||
(data).len = (data).string + length; \
|
||||
(data).isThai = TRUE; \
|
||||
} \
|
||||
ch = *(data.pos); \
|
||||
ch = *((data).pos); \
|
||||
if (ch <= 0xFF) { \
|
||||
(order) = (coll)->latinOneMapping[ch]; \
|
||||
} \
|
||||
|
@ -342,9 +343,9 @@ ucol_cloneRuleData(UCollator *coll, int32_t *length, UErrorCode *status);
|
|||
#define UCOL_TERTIARYMASK 0x000000FF
|
||||
|
||||
/**
|
||||
* Internal.
|
||||
* This indicates the last element in a UCollationElements has been consumed.
|
||||
* Compare with the older UCOL_NULLORDER, UCOL_NULLORDER is returned if error
|
||||
* occurs.
|
||||
* Compare with the UCOL_NULLORDER, UCOL_NULLORDER is returned if error occurs.
|
||||
*/
|
||||
#define UCOL_NO_MORE_CES 0x00010101
|
||||
|
||||
|
|
|
@ -112,12 +112,6 @@ public:
|
|||
*/
|
||||
static int32_t const NULLORDER;
|
||||
|
||||
/**
|
||||
* NO_MORE_CES indicates that the iterator has consumed the last element.
|
||||
* Constant is actually the bitwise seperator of the collation elements.
|
||||
*/
|
||||
static int32_t const NO_MORE_CES;
|
||||
|
||||
// CollationElementIterator public constructor/destructor -------------------
|
||||
|
||||
/**
|
||||
|
@ -151,8 +145,7 @@ public:
|
|||
* Gets the ordering priority of the next character in the string.
|
||||
* @param status the error code status.
|
||||
* @return the next character's ordering. otherwise returns NULLORDER if an
|
||||
* error has occured or NO_MORE_CES if the end of string has been
|
||||
* reached
|
||||
* error has occured or if the end of string has been reached
|
||||
*/
|
||||
int32_t next(UErrorCode& status);
|
||||
|
||||
|
@ -160,8 +153,7 @@ public:
|
|||
* Get the ordering priority of the previous collation element in the string.
|
||||
* @param status the error code status.
|
||||
* @return the previous element's ordering. otherwise returns NULLORDER if an
|
||||
* error has occured or NO_MORE_CES if the start of string has been
|
||||
* reached
|
||||
* error has occured or if the start of string has been reached
|
||||
*/
|
||||
int32_t previous(UErrorCode& status);
|
||||
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
#define UCOLEITR_H
|
||||
|
||||
/**
|
||||
* This indicates an error has occured during processing.
|
||||
* This indicates an error has occured during processing or if no more CEs is
|
||||
* to be returned.
|
||||
*/
|
||||
#define UCOL_NULLORDER 0xFFFFFFFF
|
||||
/*
|
||||
* End or start of the of string has been reached, hence there's no more
|
||||
* collation element to be retrieved.
|
||||
*/
|
||||
#define UCOL_NO_MORE_CES 0x00010101
|
||||
|
||||
#include "unicode/ucol.h"
|
||||
|
||||
|
@ -130,8 +126,7 @@ ucol_reset(UCollationElements *elems);
|
|||
* @param elems The UCollationElements containing the text.
|
||||
* @param status A pointer to an UErrorCode to receive any errors.
|
||||
* @return The next collation elements ordering, otherwise returns NULLORDER
|
||||
* if an error has occured or NO_MORE_CES if the end of string has
|
||||
* been reached
|
||||
* if an error has occured or if the end of string has been reached
|
||||
*/
|
||||
U_CAPI int32_t
|
||||
ucol_next(UCollationElements *elems, UErrorCode *status);
|
||||
|
@ -142,8 +137,8 @@ ucol_next(UCollationElements *elems, UErrorCode *status);
|
|||
* @param elems The UCollationElements containing the text.
|
||||
* @param status A pointer to an UErrorCode to receive any errors.
|
||||
* @return The previous collation elements ordering, otherwise returns
|
||||
* NULLORDER if an error has occured or NO_MORE_CES if the start of
|
||||
* string has been reached
|
||||
* NULLORDER if an error has occured or if the start of string has
|
||||
* been reached
|
||||
*/
|
||||
U_CAPI int32_t
|
||||
ucol_previous(UCollationElements *elems, UErrorCode *status);
|
||||
|
|
Loading…
Add table
Reference in a new issue