mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 09:21:03 +00:00
ICU-5117 Fixes for other versions of gcc
X-SVN-Rev: 19411
This commit is contained in:
parent
1d5b134af8
commit
56b11c8b39
2 changed files with 88 additions and 85 deletions
|
@ -50,13 +50,13 @@ LanguageBreakFactory::~LanguageBreakFactory() {
|
|||
*/
|
||||
|
||||
UnhandledEngine::UnhandledEngine(UErrorCode &status) {
|
||||
for (int32_t i = 0; i < sizeof(fHandled)/sizeof(fHandled[0]); ++i) {
|
||||
for (int32_t i = 0; i < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0])); ++i) {
|
||||
fHandled[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
UnhandledEngine::~UnhandledEngine() {
|
||||
for (int32_t i = 0; i < sizeof(fHandled)/sizeof(fHandled[0]); ++i) {
|
||||
for (int32_t i = 0; i < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0])); ++i) {
|
||||
if (fHandled[i] != 0) {
|
||||
delete fHandled[i];
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ UnhandledEngine::~UnhandledEngine() {
|
|||
|
||||
UBool
|
||||
UnhandledEngine::handles(UChar32 c, int32_t breakType) const {
|
||||
return (breakType >= 0 && breakType < sizeof(fHandled)/sizeof(fHandled[0])
|
||||
return (breakType >= 0 && breakType < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0]))
|
||||
&& fHandled[breakType] != 0 && fHandled[breakType]->contains(c));
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ UnhandledEngine::findBreaks( CharacterIterator *text,
|
|||
UBool reverse,
|
||||
int32_t breakType,
|
||||
UStack &foundBreaks ) const {
|
||||
if (breakType >= 0 && breakType < sizeof(fHandled)/sizeof(fHandled[0])) {
|
||||
if (breakType >= 0 && breakType < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0]))) {
|
||||
UChar32 c = text->current32();
|
||||
if (reverse) {
|
||||
while(text->getIndex() > startPos && fHandled[breakType]->contains(c)) {
|
||||
|
@ -94,7 +94,7 @@ UnhandledEngine::findBreaks( CharacterIterator *text,
|
|||
|
||||
void
|
||||
UnhandledEngine::handleCharacter(UChar32 c, int32_t breakType) {
|
||||
if (breakType >= 0 && breakType < sizeof(fHandled)/sizeof(fHandled[0])) {
|
||||
if (breakType >= 0 && breakType < (int32_t)(sizeof(fHandled)/sizeof(fHandled[0]))) {
|
||||
if (fHandled[breakType] == 0) {
|
||||
fHandled[breakType] = new UnicodeSet();
|
||||
if (fHandled[breakType] == 0) {
|
||||
|
|
|
@ -68,14 +68,14 @@ TernaryNode::TernaryNode(UChar uc) {
|
|||
low = NULL;
|
||||
equal = NULL;
|
||||
high = NULL;
|
||||
};
|
||||
}
|
||||
|
||||
// Not inline since it's recursive
|
||||
TernaryNode::~TernaryNode() {
|
||||
delete low;
|
||||
delete equal;
|
||||
delete high;
|
||||
};
|
||||
}
|
||||
|
||||
MutableTrieDictionary::MutableTrieDictionary( UChar median, UErrorCode &status ) {
|
||||
// Start the trie off with something. Having the root node already present
|
||||
|
@ -255,16 +255,6 @@ public:
|
|||
return new MutableTrieEnumeration(fRoot, status);
|
||||
}
|
||||
|
||||
// Very expensive, but this should never be used.
|
||||
virtual int32_t count(UErrorCode &status) const {
|
||||
MutableTrieEnumeration counter(fRoot, status);
|
||||
int32_t result = 0;
|
||||
while (counter.snext(status) != NULL && U_SUCCESS(status)) {
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual const UnicodeString *snext(UErrorCode &status) {
|
||||
if (fNodeStack.empty() || U_FAILURE(status)) {
|
||||
return NULL;
|
||||
|
@ -328,6 +318,16 @@ public:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Very expensive, but this should never be used.
|
||||
virtual int32_t count(UErrorCode &status) const {
|
||||
MutableTrieEnumeration counter(fRoot, status);
|
||||
int32_t result = 0;
|
||||
while (counter.snext(status) != NULL && U_SUCCESS(status)) {
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void reset(UErrorCode &status) {
|
||||
fNodeStack.removeAllElements();
|
||||
fBranchStack.removeAllElements();
|
||||
|
@ -545,6 +545,8 @@ public:
|
|||
return new CompactTrieEnumeration(fHeader, status);
|
||||
}
|
||||
|
||||
virtual const UnicodeString * snext(UErrorCode &status);
|
||||
|
||||
// Very expensive, but this should never be used.
|
||||
virtual int32_t count(UErrorCode &status) const {
|
||||
CompactTrieEnumeration counter(fHeader, status);
|
||||
|
@ -555,74 +557,6 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
virtual const UnicodeString *snext(UErrorCode &status) {
|
||||
if (fNodeStack.empty() || U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
const CompactTrieNode *node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
int where = fIndexStack.peeki();
|
||||
while (!fNodeStack.empty() && U_SUCCESS(status)) {
|
||||
int nodeCount = (node->flagscount & kCountMask);
|
||||
UBool goingDown = FALSE;
|
||||
if (nodeCount == 0) {
|
||||
// Terminal node; go up immediately
|
||||
fNodeStack.popi();
|
||||
fIndexStack.popi();
|
||||
node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
where = fIndexStack.peeki();
|
||||
}
|
||||
else if (node->flagscount & kVerticalNode) {
|
||||
// Vertical node
|
||||
const CompactTrieVerticalNode *vnode = (const CompactTrieVerticalNode *)node;
|
||||
if (where == 0) {
|
||||
// Going down
|
||||
unistr.append((const UChar *)vnode->chars, (int32_t) nodeCount);
|
||||
fIndexStack.setElementAt(1, fIndexStack.size()-1);
|
||||
node = getCompactNode(fHeader, fNodeStack.push(vnode->equal, status));
|
||||
where = fIndexStack.push(0, status);
|
||||
goingDown = TRUE;
|
||||
}
|
||||
else {
|
||||
// Going up
|
||||
unistr.truncate(unistr.length()-nodeCount);
|
||||
fNodeStack.popi();
|
||||
fIndexStack.popi();
|
||||
node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
where = fIndexStack.peeki();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Horizontal node
|
||||
const CompactTrieHorizontalNode *hnode = (const CompactTrieHorizontalNode *)node;
|
||||
if (where > 0) {
|
||||
// Pop previous char
|
||||
unistr.truncate(unistr.length()-1);
|
||||
}
|
||||
if (where < nodeCount) {
|
||||
// Push on next node
|
||||
unistr.append(hnode->entries[where].ch);
|
||||
fIndexStack.setElementAt(where+1, fIndexStack.size()-1);
|
||||
node = getCompactNode(fHeader, fNodeStack.push(hnode->entries[where].equal, status));
|
||||
where = fIndexStack.push(0, status);
|
||||
goingDown = TRUE;
|
||||
}
|
||||
else {
|
||||
// Going up
|
||||
fNodeStack.popi();
|
||||
fIndexStack.popi();
|
||||
node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
where = fIndexStack.peeki();
|
||||
}
|
||||
}
|
||||
// Check if the parent of the node we've just gone down to ends a
|
||||
// word. If so, return it.
|
||||
if (goingDown && (node->flagscount & kParentEndsWord)) {
|
||||
return &unistr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual void reset(UErrorCode &status) {
|
||||
fNodeStack.removeAllElements();
|
||||
fIndexStack.removeAllElements();
|
||||
|
@ -634,6 +568,75 @@ public:
|
|||
|
||||
const char CompactTrieEnumeration::fgClassID = '\0';
|
||||
|
||||
const UnicodeString *
|
||||
CompactTrieEnumeration::snext(UErrorCode &status) {
|
||||
if (fNodeStack.empty() || U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
const CompactTrieNode *node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
int where = fIndexStack.peeki();
|
||||
while (!fNodeStack.empty() && U_SUCCESS(status)) {
|
||||
int nodeCount = (node->flagscount & kCountMask);
|
||||
UBool goingDown = FALSE;
|
||||
if (nodeCount == 0) {
|
||||
// Terminal node; go up immediately
|
||||
fNodeStack.popi();
|
||||
fIndexStack.popi();
|
||||
node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
where = fIndexStack.peeki();
|
||||
}
|
||||
else if (node->flagscount & kVerticalNode) {
|
||||
// Vertical node
|
||||
const CompactTrieVerticalNode *vnode = (const CompactTrieVerticalNode *)node;
|
||||
if (where == 0) {
|
||||
// Going down
|
||||
unistr.append((const UChar *)vnode->chars, (int32_t) nodeCount);
|
||||
fIndexStack.setElementAt(1, fIndexStack.size()-1);
|
||||
node = getCompactNode(fHeader, fNodeStack.push(vnode->equal, status));
|
||||
where = fIndexStack.push(0, status);
|
||||
goingDown = TRUE;
|
||||
}
|
||||
else {
|
||||
// Going up
|
||||
unistr.truncate(unistr.length()-nodeCount);
|
||||
fNodeStack.popi();
|
||||
fIndexStack.popi();
|
||||
node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
where = fIndexStack.peeki();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Horizontal node
|
||||
const CompactTrieHorizontalNode *hnode = (const CompactTrieHorizontalNode *)node;
|
||||
if (where > 0) {
|
||||
// Pop previous char
|
||||
unistr.truncate(unistr.length()-1);
|
||||
}
|
||||
if (where < nodeCount) {
|
||||
// Push on next node
|
||||
unistr.append(hnode->entries[where].ch);
|
||||
fIndexStack.setElementAt(where+1, fIndexStack.size()-1);
|
||||
node = getCompactNode(fHeader, fNodeStack.push(hnode->entries[where].equal, status));
|
||||
where = fIndexStack.push(0, status);
|
||||
goingDown = TRUE;
|
||||
}
|
||||
else {
|
||||
// Going up
|
||||
fNodeStack.popi();
|
||||
fIndexStack.popi();
|
||||
node = getCompactNode(fHeader, fNodeStack.peeki());
|
||||
where = fIndexStack.peeki();
|
||||
}
|
||||
}
|
||||
// Check if the parent of the node we've just gone down to ends a
|
||||
// word. If so, return it.
|
||||
if (goingDown && (node->flagscount & kParentEndsWord)) {
|
||||
return &unistr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
StringEnumeration *
|
||||
CompactTrieDictionary::openWords( UErrorCode &status ) const {
|
||||
if (U_FAILURE(status)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue