X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/common/rbbinode.cpp?ds=inline diff --git a/icuSources/common/rbbinode.cpp b/icuSources/common/rbbinode.cpp index af467b6d..1468be9c 100644 --- a/icuSources/common/rbbinode.cpp +++ b/icuSources/common/rbbinode.cpp @@ -1,6 +1,6 @@ /* *************************************************************************** -* Copyright (C) 2002-2006 International Business Machines Corporation * +* Copyright (C) 2002-2016 International Business Machines Corporation * * and others. All rights reserved. * *************************************************************************** */ @@ -56,6 +56,8 @@ RBBINode::RBBINode(NodeType t) : UMemory() { fLastPos = 0; fNullable = FALSE; fLookAheadEnd = FALSE; + fRuleRoot = FALSE; + fChainIn = FALSE; fVal = 0; fPrecedence = precZero; @@ -86,6 +88,8 @@ RBBINode::RBBINode(const RBBINode &other) : UMemory(other) { fLastPos = other.fLastPos; fNullable = other.fNullable; fVal = other.fVal; + fRuleRoot = FALSE; + fChainIn = other.fChainIn; UErrorCode status = U_ZERO_ERROR; fFirstPosSet = new UVector(status); // TODO - get a real status from somewhere fLastPosSet = new UVector(status); @@ -149,15 +153,20 @@ RBBINode *RBBINode::cloneTree() { n = this; } else { n = new RBBINode(*this); - if (fLeftChild != NULL) { - n->fLeftChild = fLeftChild->cloneTree(); - n->fLeftChild->fParent = n; - } - if (fRightChild != NULL) { - n->fRightChild = fRightChild->cloneTree(); - n->fRightChild->fParent = n; + // Check for null pointer. + if (n != NULL) { + if (fLeftChild != NULL) { + n->fLeftChild = fLeftChild->cloneTree(); + n->fLeftChild->fParent = n; + } + if (fRightChild != NULL) { + n->fRightChild = fRightChild->cloneTree(); + n->fRightChild->fParent = n; + } } } + n->fRuleRoot = this->fRuleRoot; + n->fChainIn = this->fChainIn; return n; } @@ -269,6 +278,12 @@ void RBBINode::findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &s // //------------------------------------------------------------------------- #ifdef RBBI_DEBUG + +static int32_t serial(const RBBINode *node) { + return (node == NULL? -1 : node->fSerialNum); +} + + void RBBINode::printNode() { static const char * const nodeTypeNames[] = { "setRef", @@ -292,9 +307,10 @@ void RBBINode::printNode() { if (this==NULL) { RBBIDebugPrintf("%10p", (void *)this); } else { - RBBIDebugPrintf("%10p %12s %10p %10p %10p %4d %6d %d ", - (void *)this, nodeTypeNames[fType], (void *)fParent, (void *)fLeftChild, (void *)fRightChild, - fSerialNum, fFirstPos, fVal); + RBBIDebugPrintf("%10p %5d %12s %c%c %5d %5d %5d %6d %d ", + (void *)this, fSerialNum, nodeTypeNames[fType], fRuleRoot?'R':' ', fChainIn?'C':' ', + serial(fLeftChild), serial(fRightChild), serial(fParent), + fFirstPos, fVal); if (fType == varRef) { RBBI_DEBUG_printUnicodeString(fText); } @@ -325,11 +341,13 @@ U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth) // //------------------------------------------------------------------------- #ifdef RBBI_DEBUG +void RBBINode::printNodeHeader() { + RBBIDebugPrintf(" Address serial type LeftChild RightChild Parent position value\n"); +} + void RBBINode::printTree(UBool printHeading) { if (printHeading) { - RBBIDebugPrintf( "-------------------------------------------------------------------\n" - " Address type Parent LeftChild RightChild serial position value\n" - ); + printNodeHeader(); } this->printNode(); if (this != NULL) {