mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-12797 RBBI rule compiler fix.
X-SVN-Rev: 39432
This commit is contained in:
parent
4e22ce5dc8
commit
92f758f6fc
4 changed files with 38 additions and 38 deletions
|
@ -169,8 +169,6 @@ RBBINode *RBBINode::cloneTree() {
|
|||
}
|
||||
}
|
||||
}
|
||||
n->fRuleRoot = this->fRuleRoot;
|
||||
n->fChainIn = this->fChainIn;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -196,8 +194,12 @@ RBBINode *RBBINode::cloneTree() {
|
|||
//-------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#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"
|
||||
|
||||
|
||||
//
|
||||
|
@ -228,9 +228,9 @@ RBBISymbolTableEntry::~RBBISymbolTableEntry() {
|
|||
//
|
||||
#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;
|
||||
|
@ -241,10 +241,8 @@ void RBBISymbolTable::rbbiSymtablePrint() const {
|
|||
}
|
||||
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");
|
||||
|
@ -255,8 +253,9 @@ void RBBISymbolTable::rbbiSymtablePrint() const {
|
|||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ void RBBITest::runIndexedTest( int32_t index, UBool exec, const char* &name, cha
|
|||
TESTCASE_AUTO(TestDictRules);
|
||||
TESTCASE_AUTO(TestBug5532);
|
||||
TESTCASE_AUTO(TestBug7547);
|
||||
TESTCASE_AUTO(TestBug12797);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
@ -4633,35 +4634,32 @@ void RBBITest::TestBug7547() {
|
|||
}
|
||||
|
||||
|
||||
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() {
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
void TestBug5532();
|
||||
void TestBug9983();
|
||||
void TestBug7547();
|
||||
void TestBug12797();
|
||||
|
||||
void TestDebug();
|
||||
void TestProperties();
|
||||
|
|
Loading…
Add table
Reference in a new issue