From d4ebc2590dfa535ec700d950eb8c4c03359fdb2b Mon Sep 17 00:00:00 2001 From: Syn Wee Quek Date: Fri, 9 Mar 2001 18:25:30 +0000 Subject: [PATCH] ICU-861 Updated previous iterator for Thai collation. X-SVN-Rev: 3996 --- icu4c/source/i18n/ucol_imp.h | 13 ++++++++++--- icu4c/source/i18n/ucoleitr.cpp | 27 ++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/icu4c/source/i18n/ucol_imp.h b/icu4c/source/i18n/ucol_imp.h index e7b41521a2..e620e5a8de 100644 --- a/icu4c/source/i18n/ucol_imp.h +++ b/icu4c/source/i18n/ucol_imp.h @@ -277,9 +277,16 @@ struct incrementalContext { if (ch <= 0xFF) { \ (order) = (coll)->latinOneMapping[ch]; \ } \ - else { \ - (order) = ucmp32_get((coll)->mapping, ch); \ - } \ + else \ + if ((data).isThai && UCOL_ISTHAIBASECONSONANT(ch) && \ + ((data).pos) != (data).string && \ + ((data).pos) != (data).writableBuffer && \ + UCOL_ISTHAIPREVOWEL(*((data).pos -1))) { \ + result = UCOL_THAI; \ + } \ + else { \ + (result) = ucmp32_get((coll)->mapping, ch); \ + } \ if ((order) >= UCOL_NOT_FOUND) { \ (order) = getSpecialPrevCE((coll), (order), &(data), (length), \ (status)); \ diff --git a/icu4c/source/i18n/ucoleitr.cpp b/icu4c/source/i18n/ucoleitr.cpp index 86477afff5..ac2bf14923 100644 --- a/icu4c/source/i18n/ucoleitr.cpp +++ b/icu4c/source/i18n/ucoleitr.cpp @@ -105,10 +105,8 @@ ucol_next(UCollationElements *elems, } elems->reset_ = FALSE; - - UCOL_GETNEXTCE(result, elems->collator_, elems->iteratordata_, status); -#ifdef UCOL_DEBUG +#ifdef _DEBUG if ((elems->iteratordata_).CEpos > (elems->iteratordata_).toReturn) { result = *((elems->iteratordata_).toReturn++); @@ -135,6 +133,8 @@ ucol_next(UCollationElements *elems, } else (result) = UCOL_NO_MORE_CES; +#else + UCOL_GETNEXTCE(result, elems->collator_, elems->iteratordata_, status); #endif if (result == UCOL_NO_MORE_CES) { @@ -160,10 +160,7 @@ ucol_previous(UCollationElements *elems, elems->reset_ = FALSE; - UCOL_GETPREVCE(result, elems->collator_, elems->iteratordata_, - elems->length_, status); - -#ifdef UCOL_DEBUG +#ifdef _DEBUG const UCollator *coll = elems->collator_; collIterate *data = &(elems->iteratordata_); int32_t length = elems->length_; @@ -186,8 +183,17 @@ ucol_previous(UCollationElements *elems, UChar ch = *(data->pos); if (ch <= 0xFF) (result) = (coll)->latinOneMapping[ch]; - else - (result) = ucmp32_get((coll)->mapping, ch); + else { + if (data->isThai && UCOL_ISTHAIBASECONSONANT(ch) && + (data->pos) != data->string && + (data->pos) != data->writableBuffer && + UCOL_ISTHAIPREVOWEL(*(data->pos -1))) { + result = UCOL_THAI; + } + else { + (result) = ucmp32_get((coll)->mapping, ch); + } + } if ((result) >= UCOL_NOT_FOUND) { @@ -197,6 +203,9 @@ ucol_previous(UCollationElements *elems, } } } +#else + UCOL_GETPREVCE(result, elems->collator_, elems->iteratordata_, + elems->length_, status); #endif if (result == UCOL_NO_MORE_CES) {