summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/i18n/translit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu-xetex/i18n/translit.cpp')
-rw-r--r--Build/source/libs/icu-xetex/i18n/translit.cpp78
1 files changed, 50 insertions, 28 deletions
diff --git a/Build/source/libs/icu-xetex/i18n/translit.cpp b/Build/source/libs/icu-xetex/i18n/translit.cpp
index 3469fe6feea..8a990f40bcd 100644
--- a/Build/source/libs/icu-xetex/i18n/translit.cpp
+++ b/Build/source/libs/icu-xetex/i18n/translit.cpp
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (C) 1999-2005, International Business Machines
+* Copyright (C) 1999-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@@ -107,7 +107,7 @@ UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(Transliterator)
* Return TRUE if the given UTransPosition is valid for text of
* the given length.
*/
-inline UBool positionIsValid(UTransPosition& index, int32_t len) {
+static inline UBool positionIsValid(UTransPosition& index, int32_t len) {
return !(index.contextStart < 0 ||
index.start < index.contextStart ||
index.limit < index.start ||
@@ -126,17 +126,20 @@ inline UBool positionIsValid(UTransPosition& index, int32_t len) {
Transliterator::Transliterator(const UnicodeString& theID,
UnicodeFilter* adoptedFilter) :
UObject(), ID(theID), filter(adoptedFilter),
- maximumContextLength(0) {
-
- // NUL-terminate the ID string
- ID.getTerminatedBuffer();
+ maximumContextLength(0)
+{
+ // NUL-terminate the ID string, which is a non-aliased copy.
+ ID.append((UChar)0);
+ ID.truncate(ID.length()-1);
}
/**
* Destructor.
*/
Transliterator::~Transliterator() {
- delete filter;
+ if (filter) {
+ delete filter;
+ }
}
/**
@@ -144,10 +147,11 @@ Transliterator::~Transliterator() {
*/
Transliterator::Transliterator(const Transliterator& other) :
UObject(other), ID(other.ID), filter(0),
- maximumContextLength(other.maximumContextLength) {
-
- // NUL-terminate the ID string
- ID.getTerminatedBuffer();
+ maximumContextLength(other.maximumContextLength)
+{
+ // NUL-terminate the ID string, which is a non-aliased copy.
+ ID.append((UChar)0);
+ ID.truncate(ID.length()-1);
if (other.filter != 0) {
// We own the filter, so we must have our own copy
@@ -155,6 +159,10 @@ Transliterator::Transliterator(const Transliterator& other) :
}
}
+Transliterator* Transliterator::clone() const {
+ return NULL;
+}
+
/**
* Assignment operator.
*/
@@ -990,7 +998,7 @@ Transliterator* Transliterator::createBasicInstance(const UnicodeString& id,
// Other aliases are handled with TransliteratorAlias::create().
if (alias->isRuleBased()) {
// Step 1. parse
- TransliteratorParser parser;
+ TransliteratorParser parser(ec);
alias->parse(parser, pe, ec);
delete alias;
alias = 0;
@@ -1041,7 +1049,7 @@ Transliterator::createFromRules(const UnicodeString& ID,
{
Transliterator* t = NULL;
- TransliteratorParser parser;
+ TransliteratorParser parser(status);
parser.parse(rules, dir, parseError, status);
if (U_FAILURE(status)) {
@@ -1049,13 +1057,13 @@ Transliterator::createFromRules(const UnicodeString& ID,
}
// NOTE: The logic here matches that in TransliteratorRegistry.
- if (parser.idBlockVector->size() == 0 && parser.dataVector->size() == 0) {
+ if (parser.idBlockVector.size() == 0 && parser.dataVector.size() == 0) {
t = new NullTransliterator();
}
- else if (parser.idBlockVector->size() == 0 && parser.dataVector->size() == 1) {
- t = new RuleBasedTransliterator(ID, (TransliterationRuleData*)parser.dataVector->orphanElementAt(0), TRUE);
+ else if (parser.idBlockVector.size() == 0 && parser.dataVector.size() == 1) {
+ t = new RuleBasedTransliterator(ID, (TransliterationRuleData*)parser.dataVector.orphanElementAt(0), TRUE);
}
- else if (parser.idBlockVector->size() == 1 && parser.dataVector->size() == 0) {
+ else if (parser.idBlockVector.size() == 1 && parser.dataVector.size() == 0) {
// idBlock, no data -- this is an alias. The ID has
// been munged from reverse into forward mode, if
// necessary, so instantiate the ID in the forward
@@ -1064,10 +1072,10 @@ Transliterator::createFromRules(const UnicodeString& ID,
UnicodeString filterPattern;
parser.compoundFilter->toPattern(filterPattern, FALSE);
t = createInstance(filterPattern + UnicodeString(ID_DELIM)
- + *((UnicodeString*)parser.idBlockVector->elementAt(0)), UTRANS_FORWARD, parseError, status);
+ + *((UnicodeString*)parser.idBlockVector.elementAt(0)), UTRANS_FORWARD, parseError, status);
}
else
- t = createInstance(*((UnicodeString*)parser.idBlockVector->elementAt(0)), UTRANS_FORWARD, parseError, status);
+ t = createInstance(*((UnicodeString*)parser.idBlockVector.elementAt(0)), UTRANS_FORWARD, parseError, status);
if (t != NULL) {
@@ -1078,13 +1086,13 @@ Transliterator::createFromRules(const UnicodeString& ID,
UVector transliterators(status);
int32_t passNumber = 1;
- int32_t limit = parser.idBlockVector->size();
- if (parser.dataVector->size() > limit)
- limit = parser.dataVector->size();
+ int32_t limit = parser.idBlockVector.size();
+ if (parser.dataVector.size() > limit)
+ limit = parser.dataVector.size();
for (int32_t i = 0; i < limit; i++) {
- if (i < parser.idBlockVector->size()) {
- UnicodeString* idBlock = (UnicodeString*)parser.idBlockVector->elementAt(i);
+ if (i < parser.idBlockVector.size()) {
+ UnicodeString* idBlock = (UnicodeString*)parser.idBlockVector.elementAt(i);
if (!idBlock->isEmpty()) {
Transliterator* temp = createInstance(*idBlock, UTRANS_FORWARD, parseError, status);
if (temp != NULL && temp->getDynamicClassID() != NullTransliterator::getStaticClassID())
@@ -1093,8 +1101,8 @@ Transliterator::createFromRules(const UnicodeString& ID,
delete temp;
}
}
- if (!parser.dataVector->isEmpty()) {
- TransliterationRuleData* data = (TransliterationRuleData*)parser.dataVector->orphanElementAt(0);
+ if (!parser.dataVector.isEmpty()) {
+ TransliterationRuleData* data = (TransliterationRuleData*)parser.dataVector.orphanElementAt(0);
transliterators.addElement(
new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + (passNumber++),
data, TRUE), status);
@@ -1236,6 +1244,20 @@ void Transliterator::_registerInstance(Transliterator* adoptedPrototype) {
registry->put(adoptedPrototype, TRUE);
}
+void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID,
+ const UnicodeString& realID) {
+ umtx_init(&registryMutex);
+ Mutex lock(&registryMutex);
+ if (HAVE_REGISTRY) {
+ _registerAlias(aliasID, realID);
+ }
+}
+
+void Transliterator::_registerAlias(const UnicodeString& aliasID,
+ const UnicodeString& realID) {
+ registry->put(aliasID, realID, FALSE, TRUE);
+}
+
/**
* Unregisters a transliterator or class. This may be either
* a system transliterator or a user transliterator or class.
@@ -1489,13 +1511,13 @@ UBool Transliterator::initializeRegistry() {
(ures_getUnicodeStringByKey(res, "direction", &status).charAt(0) ==
0x0046 /*F*/) ?
UTRANS_FORWARD : UTRANS_REVERSE;
- registry->put(id, UnicodeString(TRUE, resString, len), dir, visible);
+ registry->put(id, UnicodeString(TRUE, resString, len), dir, TRUE, visible);
}
break;
case 0x61: // 'a'
// 'alias'; row[2]=createInstance argument
resString = ures_getString(res, &len, &status);
- registry->put(id, UnicodeString(TRUE, resString, len), TRUE);
+ registry->put(id, UnicodeString(TRUE, resString, len), TRUE, TRUE);
break;
}
}