}
}
}
- n->fRuleRoot = this->fRuleRoot;
- n->fChainIn = this->fChainIn;
return n;
}
//-------------------------------------------------------------------------
RBBINode *RBBINode::flattenVariables() {
if (fType == varRef) {
- RBBINode *retNode = fLeftChild->cloneTree();
- delete this;
+ RBBINode *retNode = fLeftChild->cloneTree();
+ if (retNode != NULL) {
+ retNode->fRuleRoot = this->fRuleRoot;
+ retNode->fChainIn = this->fChainIn;
+ }
+ delete this; // TODO: undefined behavior. Fix.
return retNode;
}
#include "unicode/uchar.h"
#include "unicode/parsepos.h"
-#include "umutex.h"
-
-#include "rbbirb.h"
+#include "cstr.h"
#include "rbbinode.h"
+#include "rbbirb.h"
+#include "umutex.h"
//
//
#ifdef RBBI_DEBUG
void RBBISymbolTable::rbbiSymtablePrint() const {
- RBBIDebugPrintf("Variable Definitions\n"
- "Name Node Val String Val\n"
- "----------------------------------------------------------------------\n");
+ RBBIDebugPrintf("Variable Definitions Symbol Table\n"
+ "Name Node serial String Val\n"
+ "-------------------------------------------------------------------\n");
int32_t pos = UHASH_FIRST;
const UHashElement *e = NULL;
}
RBBISymbolTableEntry *s = (RBBISymbolTableEntry *)e->value.pointer;
- RBBI_DEBUG_printUnicodeString(s->key, 15);
- RBBIDebugPrintf(" %8p ", (void *)s->val);
- RBBI_DEBUG_printUnicodeString(s->val->fLeftChild->fText);
- RBBIDebugPrintf("\n");
+ RBBIDebugPrintf("%-19s %8p %7d ", CStr(s->key)(), (void *)s->val, s->val->fSerialNum);
+ RBBIDebugPrintf(" %s\n", CStr(s->val->fLeftChild->fText)());
}
RBBIDebugPrintf("\nParsed Variable Definitions\n");
break;
}
RBBISymbolTableEntry *s = (RBBISymbolTableEntry *)e->value.pointer;
- RBBI_DEBUG_printUnicodeString(s->key);
- RBBINode::printTree(s->val->fLeftChild, TRUE);
+ RBBIDebugPrintf("%s\n", CStr(s->key)());
+ RBBINode::printTree(s->val, TRUE);
+ RBBINode::printTree(s->val->fLeftChild, FALSE);
RBBIDebugPrintf("\n");
}
}
TESTCASE_AUTO(TestDictRules);
TESTCASE_AUTO(TestBug5532);
TESTCASE_AUTO(TestBug7547);
+ TESTCASE_AUTO(TestBug12797);
TESTCASE_AUTO_END;
}
}
+void RBBITest::TestBug12797() {
+ UnicodeString rules = "!!chain; !!forward; $v=b c; a b; $v; !!reverse; .*;";
+ UErrorCode status = U_ZERO_ERROR;
+ UParseError parseError;
+ RuleBasedBreakIterator bi(rules, parseError, status);
+ if (U_FAILURE(status)) {
+ errln("%s:%s status = %s", __FILE__, __LINE__, u_errorName(status));
+ return;
+ }
+ UnicodeString text = "abc";
+ bi.setText(text);
+ bi.first();
+ int32_t boundary = bi.next();
+ if (boundary != 3) {
+ errln("%s:%d expected boundary==3, got %d", __FILE__, __LINE__, boundary);
+ }
+}
+
+
//
// TestDebug - A place-holder test for debugging purposes.
// For putting in fragments of other tests that can be invoked
// for tracing without a lot of unwanted extra stuff happening.
//
void RBBITest::TestDebug(void) {
-#if 0
- UErrorCode status = U_ZERO_ERROR;
- int pos = 0;
- int ruleStatus = 0;
-
- RuleBasedBreakIterator* bi =
- // (RuleBasedBreakIterator *)BreakIterator::createLineInstance(Locale::getDefault(), status);
- // (RuleBasedBreakIterator *)BreakIterator::createWordInstance(Locale::Locale("th"), status);
- (RuleBasedBreakIterator *)BreakIterator::createSentenceInstance(Locale::getDefault(), status);
- UnicodeString s("\\u2008\\u002e\\udc6a\\u37cd\\u71d0\\u2048\\U000e006a\\u002e\\u0046\\ufd3f\\u000a\\u002e");
- // UnicodeString s("Aaa. Bcd");
- s = s.unescape();
- bi->setText(s);
- UBool r = bi->isBoundary(8);
- printf("%s", r?"true":"false");
- return;
- pos = bi->last();
- do {
- // ruleStatus = bi->getRuleStatus();
- printf("%d\t%d\n", pos, ruleStatus);
- pos = bi->previous();
- } while (pos != BreakIterator::DONE);
-#endif
+
}
void RBBITest::TestProperties() {