From 3fe96feba6db59b86db03c3530f2cffe7fe5bf1e Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Mon, 30 Jul 2001 23:22:51 +0000 Subject: [PATCH] ICU-1076 remove limit of 9 segments X-SVN-Rev: 5378 --- icu4c/source/i18n/rbt_data.cpp | 4 ++-- icu4c/source/i18n/rbt_data.h | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/icu4c/source/i18n/rbt_data.cpp b/icu4c/source/i18n/rbt_data.cpp index 0cef0ad2e1..5438e53c70 100644 --- a/icu4c/source/i18n/rbt_data.cpp +++ b/icu4c/source/i18n/rbt_data.cpp @@ -71,6 +71,6 @@ TransliterationRuleData::lookup(UChar32 standIn) const { int32_t TransliterationRuleData::lookupSegmentReference(UChar32 c) const { - int32_t i = c - segmentBase; - return (i >= 0 && i < 9) ? i : -1; + int32_t i = segmentBase - c; + return (i >= 0 && i < segmentCount) ? i : -1; } diff --git a/icu4c/source/i18n/rbt_data.h b/icu4c/source/i18n/rbt_data.h index c60e718c46..d677fbe11a 100644 --- a/icu4c/source/i18n/rbt_data.h +++ b/icu4c/source/i18n/rbt_data.h @@ -78,10 +78,13 @@ public: /** * The character that represents segment 1. Characters segmentBase - * through segmentBase + 8 represent segments 1 through 9. + * through segmentBase - segmentCount + 1 represent segments 1 + * through segmentCount. Segments work down while variables work up. */ UChar segmentBase; + int32_t segmentCount; + public: TransliterationRuleData(UErrorCode& status); @@ -99,16 +102,16 @@ public: /** * Return the zero-based index of the segment represented by the given * character, or -1 if none. Repeat: This is a zero-based return value, - * 0..8, even though these are notated "$1".."$9". + * 0..n-1, even though these are notated "$1".."$n", where n is segmentCount. */ int32_t lookupSegmentReference(UChar32 c) const; /** * Return the character used to stand for the given segment reference. - * The reference must be in the range 1..9. + * The reference must be in the range 1..segmentCount. */ UChar getSegmentStandin(int32_t ref) const { - return (UChar)(segmentBase + ref - 1); + return (UChar)(segmentBase - ref + 1); } };