ICU-4539 Fixes for EBCDIC safety and UCONFIG_NO_CONVERSION=1.

X-SVN-Rev: 17956
This commit is contained in:
George Rhoten 2005-06-21 16:55:19 +00:00
parent 642bc191a9
commit 2568486432
4 changed files with 14 additions and 8 deletions

View File

@ -30,6 +30,8 @@ static const UChar COLON_COLON[] = {0x3A, 0x3A, 0}; //"::"
U_NAMESPACE_BEGIN
const UChar CompoundTransliterator::PASS_STRING[] = { 0x0025, 0x0050, 0x0061, 0x0073, 0x0073, 0 }; // "%Pass"
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CompoundTransliterator)
/**
@ -373,16 +375,16 @@ UnicodeString& CompoundTransliterator::toRules(UnicodeString& rulesSource,
// ::BEGIN/::END blocks) are given IDs that begin with
// "%Pass": use toRules() to write all the rules to the output
// (and insert "::Null;" if we have two in a row)
if (trans[i]->getID().startsWith("%Pass")) {
if (trans[i]->getID().startsWith(PASS_STRING)) {
trans[i]->toRules(rule, escapeUnprintable);
if (numAnonymousRBTs > 1 && i > 0 && trans[i - 1]->getID().startsWith("%Pass"))
rule = "::Null;" + rule;
if (numAnonymousRBTs > 1 && i > 0 && trans[i - 1]->getID().startsWith(PASS_STRING))
rule = UNICODE_STRING_SIMPLE("::Null;") + rule;
// we also use toRules() on CompoundTransliterators (which we
// check for by looking for a semicolon in the ID)-- this gets
// the list of their child transliterators output in the right
// format
} else if (trans[i]->getID().indexOf(';') >= 0) {
} else if (trans[i]->getID().indexOf(ID_DELIM) >= 0) {
trans[i]->toRules(rule, escapeUnprintable);
// for everything else, use Transliterator::toRules()

View File

@ -191,6 +191,9 @@ public:
*/
static UClassID U_EXPORT2 getStaticClassID();
/* @internal */
static const UChar PASS_STRING[];
private:
friend class Transliterator;

View File

@ -929,7 +929,7 @@ Transliterator::createInstance(const UnicodeString& ID,
U_ASSERT(list.size() > 0);
Transliterator* t = NULL;
if (list.size() > 1 || canonID.indexOf(";") >= 0) {
if (list.size() > 1 || canonID.indexOf(ID_DELIM) >= 0) {
// [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only
// has one child transliterator. This is so that toRules() will return the right thing
// (without any inactive ID), but our main ID still comes out correct. That is, if we
@ -1063,7 +1063,7 @@ Transliterator::createFromRules(const UnicodeString& ID,
if (parser.compoundFilter != NULL) {
UnicodeString filterPattern;
parser.compoundFilter->toPattern(filterPattern, FALSE);
t = createInstance(filterPattern + ";"
t = createInstance(filterPattern + UnicodeString(ID_DELIM)
+ *((UnicodeString*)parser.idBlockVector->elementAt(0)), UTRANS_FORWARD, parseError, status);
}
else
@ -1095,7 +1095,8 @@ Transliterator::createFromRules(const UnicodeString& ID,
}
if (!parser.dataVector->isEmpty()) {
TransliterationRuleData* data = (TransliterationRuleData*)parser.dataVector->orphanElementAt(0);
transliterators.addElement(new RuleBasedTransliterator((UnicodeString)"%Pass" + (passNumber++),
transliterators.addElement(
new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + (passNumber++),
data, TRUE), status);
}
}

View File

@ -1223,7 +1223,7 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID
UVector* rbts = new UVector(status);
int32_t passNumber = 1;
for (int32_t i = 0; U_SUCCESS(status) && i < entry->u.dataVector->size(); i++) {
Transliterator* t = new RuleBasedTransliterator((UnicodeString)"%Pass" + (passNumber++),
Transliterator* t = new RuleBasedTransliterator(UnicodeString(CompoundTransliterator::PASS_STRING) + (passNumber++),
(TransliterationRuleData*)(entry->u.dataVector->elementAt(i)), FALSE);
if (t == 0)
status = U_MEMORY_ALLOCATION_ERROR;