ICU-6076 Don't crash when initialization fails.
X-SVN-Rev: 23451
This commit is contained in:
parent
acd8f28273
commit
1da25d4d3b
@ -99,7 +99,7 @@ RuleBasedBreakIterator::RuleBasedBreakIterator( const UnicodeString &rules,
|
||||
init();
|
||||
if (U_FAILURE(status)) {return;}
|
||||
RuleBasedBreakIterator *bi = (RuleBasedBreakIterator *)
|
||||
RBBIRuleBuilder::createRuleBasedBreakIterator(rules, parseError, status);
|
||||
RBBIRuleBuilder::createRuleBasedBreakIterator(rules, &parseError, status);
|
||||
// Note: This is a bit awkward. The RBBI ruleBuilder has a factory method that
|
||||
// creates and returns a complete RBBI. From here, in a constructor, we
|
||||
// can't just return the object created by the builder factory, hence
|
||||
|
@ -43,12 +43,12 @@ U_NAMESPACE_BEGIN
|
||||
//
|
||||
//----------------------------------------------------------------------------------------
|
||||
RBBIRuleBuilder::RBBIRuleBuilder(const UnicodeString &rules,
|
||||
UParseError &parseErr,
|
||||
UParseError *parseErr,
|
||||
UErrorCode &status)
|
||||
: fRules(rules)
|
||||
{
|
||||
fStatus = &status; // status is checked below
|
||||
fParseError = &parseErr;
|
||||
fParseError = parseErr;
|
||||
fDebugEnv = NULL;
|
||||
#ifdef RBBI_DEBUG
|
||||
fDebugEnv = getenv("U_RBBIDEBUG");
|
||||
@ -72,6 +72,9 @@ RBBIRuleBuilder::RBBIRuleBuilder(const UnicodeString &rules,
|
||||
fRuleStatusVals = NULL;
|
||||
fScanner = NULL;
|
||||
fSetBuilder = NULL;
|
||||
if (parseErr) {
|
||||
uprv_memset(parseErr, 0, sizeof(UParseError));
|
||||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
@ -226,7 +229,7 @@ RBBIDataHeader *RBBIRuleBuilder::flattenData() {
|
||||
//----------------------------------------------------------------------------------------
|
||||
BreakIterator *
|
||||
RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules,
|
||||
UParseError &parseError,
|
||||
UParseError *parseError,
|
||||
UErrorCode &status)
|
||||
{
|
||||
// status checked below
|
||||
@ -236,10 +239,10 @@ RBBIRuleBuilder::createRuleBasedBreakIterator( const UnicodeString &rules,
|
||||
// and list of all Unicode Sets referenced by the rules.
|
||||
//
|
||||
RBBIRuleBuilder builder(rules, parseError, status);
|
||||
builder.fScanner->parse();
|
||||
if (U_FAILURE(status)) { // status checked here bcos build below doesn't
|
||||
return NULL;
|
||||
}
|
||||
builder.fScanner->parse();
|
||||
|
||||
//
|
||||
// UnicodeSet processing.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// rbbirb.h
|
||||
//
|
||||
// Copyright (C) 2002-2005, International Business Machines Corporation and others.
|
||||
// Copyright (C) 2002-2008, International Business Machines Corporation and others.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// This file contains declarations for several classes from the
|
||||
@ -107,7 +107,7 @@ public:
|
||||
// public ICU API for creating RBBIs uses this function to do the actual work.
|
||||
//
|
||||
static BreakIterator * createRuleBasedBreakIterator( const UnicodeString &rules,
|
||||
UParseError &parseError,
|
||||
UParseError *parseError,
|
||||
UErrorCode &status);
|
||||
|
||||
public:
|
||||
@ -116,7 +116,7 @@ public:
|
||||
// are NOT intended to be accessed by anything outside of the
|
||||
// rule builder implementation.
|
||||
RBBIRuleBuilder(const UnicodeString &rules,
|
||||
UParseError &parseErr,
|
||||
UParseError *parseErr,
|
||||
UErrorCode &status
|
||||
);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
*****************************************************************************************
|
||||
* Copyright (C) 1996-2007, International Business Machines
|
||||
********************************************************************************
|
||||
* Copyright (C) 1996-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*****************************************************************************************
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
@ -21,12 +21,12 @@
|
||||
|
||||
U_NAMESPACE_USE
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// ubrk_open Create a canned type of break iterator based on type (word, line, etc.)
|
||||
// and locale.
|
||||
//
|
||||
//----------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
U_CAPI UBreakIterator* U_EXPORT2
|
||||
ubrk_open(UBreakIteratorType type,
|
||||
const char *locale,
|
||||
@ -84,12 +84,12 @@ ubrk_open(UBreakIteratorType type,
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// ubrk_openRules open a break iterator from a set of break rules.
|
||||
// Invokes the rule builder.
|
||||
//
|
||||
//----------------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
U_CAPI UBreakIterator* U_EXPORT2
|
||||
ubrk_openRules( const UChar *rules,
|
||||
int32_t rulesLength,
|
||||
@ -104,7 +104,7 @@ ubrk_openRules( const UChar *rules,
|
||||
|
||||
BreakIterator *result = 0;
|
||||
UnicodeString ruleString(rules, rulesLength);
|
||||
result = RBBIRuleBuilder::createRuleBasedBreakIterator(ruleString, *parseErr, *status);
|
||||
result = RBBIRuleBuilder::createRuleBasedBreakIterator(ruleString, parseErr, *status);
|
||||
if(U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user