ICU-11832 some better error checking based on static code analysis
X-SVN-Rev: 37930
This commit is contained in:
parent
94fe10c710
commit
0f0c7656d3
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1996-2014, International Business Machines Corporation and
|
||||
* Copyright (C) 1996-2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*****************************************************************************
|
||||
*/
|
||||
@ -508,6 +508,13 @@ Hashtable *CanonicalIterator::extract(Hashtable *fillinResult, UChar32 comp, con
|
||||
int32_t inputLen=temp.length();
|
||||
UnicodeString decompString;
|
||||
nfd.normalize(temp, decompString, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return NULL;
|
||||
}
|
||||
if (decompString.isBogus()) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
const UChar *decomp=decompString.getBuffer();
|
||||
int32_t decompLen=decompString.length();
|
||||
|
||||
|
@ -312,6 +312,9 @@ static void uplug_queryPlug(UPlugData *plug, UErrorCode *status) {
|
||||
|
||||
|
||||
static void uplug_loadPlug(UPlugData *plug, UErrorCode *status) {
|
||||
if(U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
}
|
||||
if(!plug->awaitingLoad || (plug->level < UPLUG_LEVEL_LOW) ) { /* shouldn't happen. Plugin hasn'tbeen loaded yet.*/
|
||||
*status = U_INTERNAL_PROGRAM_ERROR;
|
||||
return;
|
||||
@ -357,13 +360,11 @@ static UPlugData *uplug_allocateEmptyPlug(UErrorCode *status)
|
||||
|
||||
static UPlugData *uplug_allocatePlug(UPlugEntrypoint *entrypoint, const char *config, void *lib, const char *symName,
|
||||
UErrorCode *status) {
|
||||
UPlugData *plug;
|
||||
|
||||
UPlugData *plug = uplug_allocateEmptyPlug(status);
|
||||
if(U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plug = uplug_allocateEmptyPlug(status);
|
||||
if(config!=NULL) {
|
||||
uprv_strncpy(plug->config, config, UPLUG_NAME_MAX);
|
||||
} else {
|
||||
|
@ -1,8 +1,7 @@
|
||||
|
||||
//
|
||||
// file: rbbiscan.cpp
|
||||
//
|
||||
// Copyright (C) 2002-2014, International Business Machines Corporation and others.
|
||||
// Copyright (C) 2002-2015, International Business Machines Corporation and others.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// This file contains the Rule Based Break Iterator Rule Builder functions for
|
||||
@ -211,6 +210,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
fixOpStack(RBBINode::precOpCat);
|
||||
RBBINode *operandNode = fNodeStack[fNodeStackPtr--];
|
||||
RBBINode *orNode = pushNewNode(RBBINode::opOr);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
orNode->fLeftChild = operandNode;
|
||||
operandNode->fParent = orNode;
|
||||
}
|
||||
@ -225,6 +227,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
fixOpStack(RBBINode::precOpCat);
|
||||
RBBINode *operandNode = fNodeStack[fNodeStackPtr--];
|
||||
RBBINode *catNode = pushNewNode(RBBINode::opCat);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
catNode->fLeftChild = operandNode;
|
||||
operandNode->fParent = catNode;
|
||||
}
|
||||
@ -320,6 +325,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
RBBINode *thisRule = fNodeStack[fNodeStackPtr];
|
||||
RBBINode *endNode = pushNewNode(RBBINode::endMark);
|
||||
RBBINode *catNode = pushNewNode(RBBINode::opCat);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
fNodeStackPtr -= 2;
|
||||
catNode->fLeftChild = thisRule;
|
||||
catNode->fRightChild = endNode;
|
||||
@ -347,6 +355,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
RBBINode *thisRule = fNodeStack[fNodeStackPtr];
|
||||
RBBINode *prevRules = *destRules;
|
||||
RBBINode *orNode = pushNewNode(RBBINode::opOr);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
orNode->fLeftChild = prevRules;
|
||||
prevRules->fParent = orNode;
|
||||
orNode->fRightChild = thisRule;
|
||||
@ -387,6 +398,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
{
|
||||
RBBINode *operandNode = fNodeStack[fNodeStackPtr--];
|
||||
RBBINode *plusNode = pushNewNode(RBBINode::opPlus);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
plusNode->fLeftChild = operandNode;
|
||||
operandNode->fParent = plusNode;
|
||||
}
|
||||
@ -396,6 +410,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
{
|
||||
RBBINode *operandNode = fNodeStack[fNodeStackPtr--];
|
||||
RBBINode *qNode = pushNewNode(RBBINode::opQuestion);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
qNode->fLeftChild = operandNode;
|
||||
operandNode->fParent = qNode;
|
||||
}
|
||||
@ -405,6 +422,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
{
|
||||
RBBINode *operandNode = fNodeStack[fNodeStackPtr--];
|
||||
RBBINode *starNode = pushNewNode(RBBINode::opStar);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
starNode->fLeftChild = operandNode;
|
||||
operandNode->fParent = starNode;
|
||||
}
|
||||
@ -418,6 +438,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
// sets that just happen to contain only one character.
|
||||
{
|
||||
n = pushNewNode(RBBINode::setRef);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
findSetFor(UnicodeString(fC.fChar), n);
|
||||
n->fFirstPos = fScanIndex;
|
||||
n->fLastPos = fNextIndex;
|
||||
@ -429,6 +452,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
// scanned a ".", meaning match any single character.
|
||||
{
|
||||
n = pushNewNode(RBBINode::setRef);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
findSetFor(UnicodeString(TRUE, kAny, 3), n);
|
||||
n->fFirstPos = fScanIndex;
|
||||
n->fLastPos = fNextIndex;
|
||||
@ -439,6 +465,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
case doSlash:
|
||||
// Scanned a '/', which identifies a look-ahead break position in a rule.
|
||||
n = pushNewNode(RBBINode::lookAhead);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
n->fVal = fRuleNum;
|
||||
n->fFirstPos = fScanIndex;
|
||||
n->fLastPos = fNextIndex;
|
||||
@ -450,6 +479,9 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
case doStartTagValue:
|
||||
// Scanned a '{', the opening delimiter for a tag value within a rule.
|
||||
n = pushNewNode(RBBINode::tag);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
break;
|
||||
}
|
||||
n->fVal = 0;
|
||||
n->fFirstPos = fScanIndex;
|
||||
n->fLastPos = fNextIndex;
|
||||
@ -560,7 +592,7 @@ UBool RBBIRuleScanner::doParseActions(int32_t action)
|
||||
returnVal = FALSE;
|
||||
break;
|
||||
}
|
||||
return returnVal;
|
||||
return returnVal && U_SUCCESS(*fRB->fStatus);
|
||||
}
|
||||
|
||||
|
||||
@ -1051,6 +1083,9 @@ void RBBIRuleScanner::parse() {
|
||||
if (fRB->fReverseTree == NULL) {
|
||||
fRB->fReverseTree = pushNewNode(RBBINode::opStar);
|
||||
RBBINode *operand = pushNewNode(RBBINode::setRef);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
return;
|
||||
}
|
||||
findSetFor(UnicodeString(TRUE, kAny, 3), operand);
|
||||
fRB->fReverseTree->fLeftChild = operand;
|
||||
operand->fParent = fRB->fReverseTree;
|
||||
@ -1103,6 +1138,9 @@ void RBBIRuleScanner::printNodeStack(const char *title) {
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
RBBINode *RBBIRuleScanner::pushNewNode(RBBINode::NodeType t) {
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
return NULL;
|
||||
}
|
||||
fNodeStackPtr++;
|
||||
if (fNodeStackPtr >= kStackSize) {
|
||||
error(U_BRK_INTERNAL_ERROR);
|
||||
@ -1192,6 +1230,9 @@ void RBBIRuleScanner::scanSet() {
|
||||
RBBINode *n;
|
||||
|
||||
n = pushNewNode(RBBINode::setRef);
|
||||
if (U_FAILURE(*fRB->fStatus)) {
|
||||
return;
|
||||
}
|
||||
n->fFirstPos = startPos;
|
||||
n->fLastPos = fNextIndex;
|
||||
fRB->fRules.extractBetween(n->fFirstPos, n->fLastPos, n->fText);
|
||||
|
@ -594,6 +594,9 @@ void UnicodeString::swap(UnicodeString &other) U_NOEXCEPT {
|
||||
|
||||
UnicodeString UnicodeString::unescape() const {
|
||||
UnicodeString result(length(), (UChar32)0, (int32_t)0); // construct with capacity
|
||||
if (result.isBogus()) {
|
||||
return result;
|
||||
}
|
||||
const UChar *array = getBuffer();
|
||||
int32_t len = length();
|
||||
int32_t prev = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-2014, International Business Machines
|
||||
* Copyright (C) 2005-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -2028,6 +2028,9 @@ utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status)
|
||||
return NULL;
|
||||
}
|
||||
ut = utext_setup(ut, sizeof(ReplExtra), status);
|
||||
if(U_FAILURE(*status)) {
|
||||
return ut;
|
||||
}
|
||||
|
||||
ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_WRITABLE);
|
||||
if(rep->hasMetaData()) {
|
||||
@ -2733,6 +2736,9 @@ charIterTextClone(UText *dest, const UText *src, UBool deep, UErrorCode * status
|
||||
CharacterIterator *srcCI =(CharacterIterator *)src->context;
|
||||
srcCI = srcCI->clone();
|
||||
dest = utext_openCharacterIterator(dest, srcCI, status);
|
||||
if (U_FAILURE(*status)) {
|
||||
return dest;
|
||||
}
|
||||
// cast off const on getNativeIndex.
|
||||
// For CharacterIterator based UTexts, this is safe, the operation is const.
|
||||
int64_t ix = utext_getNativeIndex((UText *)src);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2014, International Business Machines
|
||||
* Copyright (C) 2010-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: uts46.cpp
|
||||
@ -180,7 +180,7 @@ private:
|
||||
int32_t
|
||||
markBadACELabel(UnicodeString &dest,
|
||||
int32_t labelStart, int32_t labelLength,
|
||||
UBool toASCII, IDNAInfo &info) const;
|
||||
UBool toASCII, IDNAInfo &info, UErrorCode &errorCode) const;
|
||||
|
||||
void
|
||||
checkLabelBiDi(const UChar *label, int32_t labelLength, IDNAInfo &info) const;
|
||||
@ -587,6 +587,9 @@ UTS46::processUnicode(const UnicodeString &src,
|
||||
int32_t
|
||||
UTS46::mapDevChars(UnicodeString &dest, int32_t labelStart, int32_t mappingStart,
|
||||
UErrorCode &errorCode) const {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return 0;
|
||||
}
|
||||
int32_t length=dest.length();
|
||||
UChar *s=dest.getBuffer(dest[mappingStart]==0xdf ? length+1 : length);
|
||||
if(s==NULL) {
|
||||
@ -644,6 +647,9 @@ UTS46::mapDevChars(UnicodeString &dest, int32_t labelStart, int32_t mappingStart
|
||||
uts46Norm2.normalize(dest.tempSubString(labelStart), normalized, errorCode);
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
dest.replace(labelStart, 0x7fffffff, normalized);
|
||||
if(dest.isBogus()) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
return dest.length();
|
||||
}
|
||||
}
|
||||
@ -665,9 +671,16 @@ isNonASCIIDisallowedSTD3Valid(UChar32 c) {
|
||||
// Returns labelLength (= the new label length).
|
||||
static int32_t
|
||||
replaceLabel(UnicodeString &dest, int32_t destLabelStart, int32_t destLabelLength,
|
||||
const UnicodeString &label, int32_t labelLength) {
|
||||
const UnicodeString &label, int32_t labelLength, UErrorCode &errorCode) {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if(&label!=&dest) {
|
||||
dest.replace(destLabelStart, destLabelLength, label);
|
||||
if(dest.isBogus()) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return labelLength;
|
||||
}
|
||||
@ -677,6 +690,9 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
int32_t labelStart, int32_t labelLength,
|
||||
UBool toASCII,
|
||||
IDNAInfo &info, UErrorCode &errorCode) const {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return 0;
|
||||
}
|
||||
UnicodeString fromPunycode;
|
||||
UnicodeString *labelString;
|
||||
const UChar *label=dest.getBuffer()+labelStart;
|
||||
@ -711,7 +727,7 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
fromPunycode.releaseBuffer(unicodeLength);
|
||||
if(U_FAILURE(punycodeErrorCode)) {
|
||||
info.labelErrors|=UIDNA_ERROR_PUNYCODE;
|
||||
return markBadACELabel(dest, labelStart, labelLength, toASCII, info);
|
||||
return markBadACELabel(dest, labelStart, labelLength, toASCII, info, errorCode);
|
||||
}
|
||||
// Check for NFC, and for characters that are not
|
||||
// valid or deviation characters according to the normalizer.
|
||||
@ -726,7 +742,7 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
}
|
||||
if(!isValid) {
|
||||
info.labelErrors|=UIDNA_ERROR_INVALID_ACE_LABEL;
|
||||
return markBadACELabel(dest, labelStart, labelLength, toASCII, info);
|
||||
return markBadACELabel(dest, labelStart, labelLength, toASCII, info, errorCode);
|
||||
}
|
||||
labelString=&fromPunycode;
|
||||
label=fromPunycode.getBuffer();
|
||||
@ -739,7 +755,8 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
// Validity check
|
||||
if(labelLength==0) {
|
||||
info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
|
||||
return replaceLabel(dest, destLabelStart, destLabelLength, *labelString, labelLength);
|
||||
return replaceLabel(dest, destLabelStart, destLabelLength,
|
||||
*labelString, labelLength, errorCode);
|
||||
}
|
||||
// labelLength>0
|
||||
if(labelLength>=4 && label[2]==0x2d && label[3]==0x2d) {
|
||||
@ -861,7 +878,7 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
info.labelErrors|=UIDNA_ERROR_LABEL_TOO_LONG;
|
||||
}
|
||||
return replaceLabel(dest, destLabelStart, destLabelLength,
|
||||
punycode, punycodeLength);
|
||||
punycode, punycodeLength, errorCode);
|
||||
} else {
|
||||
// all-ASCII label
|
||||
if(labelLength>63) {
|
||||
@ -874,10 +891,11 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
// then leave it but make sure it does not look valid.
|
||||
if(wasPunycode) {
|
||||
info.labelErrors|=UIDNA_ERROR_INVALID_ACE_LABEL;
|
||||
return markBadACELabel(dest, destLabelStart, destLabelLength, toASCII, info);
|
||||
return markBadACELabel(dest, destLabelStart, destLabelLength, toASCII, info, errorCode);
|
||||
}
|
||||
}
|
||||
return replaceLabel(dest, destLabelStart, destLabelLength, *labelString, labelLength);
|
||||
return replaceLabel(dest, destLabelStart, destLabelLength,
|
||||
*labelString, labelLength, errorCode);
|
||||
}
|
||||
|
||||
// Make sure an ACE label does not look valid.
|
||||
@ -886,7 +904,10 @@ UTS46::processLabel(UnicodeString &dest,
|
||||
int32_t
|
||||
UTS46::markBadACELabel(UnicodeString &dest,
|
||||
int32_t labelStart, int32_t labelLength,
|
||||
UBool toASCII, IDNAInfo &info) const {
|
||||
UBool toASCII, IDNAInfo &info, UErrorCode &errorCode) const {
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return 0;
|
||||
}
|
||||
UBool disallowNonLDHDot=(options&UIDNA_USE_STD3_RULES)!=0;
|
||||
UBool isASCII=TRUE;
|
||||
UBool onlyLDH=TRUE;
|
||||
@ -914,6 +935,10 @@ UTS46::markBadACELabel(UnicodeString &dest,
|
||||
} while(++s<limit);
|
||||
if(onlyLDH) {
|
||||
dest.insert(labelStart+labelLength, (UChar)0xfffd);
|
||||
if(dest.isBogus()) {
|
||||
errorCode=U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
++labelLength;
|
||||
} else {
|
||||
if(toASCII && isASCII && labelLength>63) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1999-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
* Copyright (C) 1999-2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
* Date Name Description
|
||||
* 10/22/99 alan Creation.
|
||||
@ -196,6 +196,9 @@ int32_t UVector32::indexOf(int32_t key, int32_t startIndex) const {
|
||||
|
||||
|
||||
UBool UVector32::expandCapacity(int32_t minimumCapacity, UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (minimumCapacity < 0) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return FALSE;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1999-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
* Copyright (C) 1999-2015, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
@ -114,6 +114,9 @@ void UVector64::removeAllElements(void) {
|
||||
}
|
||||
|
||||
UBool UVector64::expandCapacity(int32_t minimumCapacity, UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (minimumCapacity < 0) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return FALSE;
|
||||
|
@ -225,10 +225,6 @@ void RegexMatcher::init(UErrorCode &status) {
|
||||
fInput = NULL;
|
||||
fInputLength = 0;
|
||||
fInputUniStrMaybeMutable = FALSE;
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
fDeferredStatus = status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -2500,6 +2496,10 @@ REStackFrame *RegexMatcher::resetStack() {
|
||||
fStack->removeAllElements();
|
||||
|
||||
REStackFrame *iFrame = (REStackFrame *)fStack->reserveBlock(fPattern->fFrameSize, fDeferredStatus);
|
||||
if(U_FAILURE(fDeferredStatus)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t i;
|
||||
for (i=0; i<fPattern->fFrameSize-RESTACKFRAME_HDRCOUNT; i++) {
|
||||
iFrame->fExtra[i] = -1;
|
||||
@ -2687,9 +2687,12 @@ void RegexMatcher::IncrementTime(UErrorCode &status) {
|
||||
//
|
||||
//--------------------------------------------------------------------------------
|
||||
inline REStackFrame *RegexMatcher::StateSave(REStackFrame *fp, int64_t savePatIdx, UErrorCode &status) {
|
||||
if (U_FAILURE(status)) {
|
||||
return fp;
|
||||
}
|
||||
// push storage for a new frame.
|
||||
int64_t *newFP = fStack->reserveBlock(fFrameSize, status);
|
||||
if (newFP == NULL) {
|
||||
if (U_FAILURE(status)) {
|
||||
// Failure on attempted stack expansion.
|
||||
// Stack function set some other error code, change it to a more
|
||||
// specific one for regular expressions.
|
||||
@ -2781,6 +2784,10 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
|
||||
|
||||
fFrameSize = fPattern->fFrameSize;
|
||||
REStackFrame *fp = resetStack();
|
||||
if (U_FAILURE(fDeferredStatus)) {
|
||||
status = fDeferredStatus;
|
||||
return;
|
||||
}
|
||||
|
||||
fp->fPatIdx = 0;
|
||||
fp->fInputIdx = startIdx;
|
||||
@ -4344,6 +4351,10 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
|
||||
|
||||
fFrameSize = fPattern->fFrameSize;
|
||||
REStackFrame *fp = resetStack();
|
||||
if (U_FAILURE(fDeferredStatus)) {
|
||||
status = fDeferredStatus;
|
||||
return;
|
||||
}
|
||||
|
||||
fp->fPatIdx = 0;
|
||||
fp->fInputIdx = startIdx;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2001-2014, International Business Machines
|
||||
* Copyright (C) 2001-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*
|
||||
@ -34,14 +34,10 @@ U_NAMESPACE_USE
|
||||
#define DEFAULT_BUFFER_SIZE 16
|
||||
#define BUFFER_GROW 8
|
||||
|
||||
#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
|
||||
|
||||
#define ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
|
||||
|
||||
#define NEW_ARRAY(type, count) (type *) uprv_malloc((count) * sizeof(type))
|
||||
|
||||
#define GROW_ARRAY(array, newSize) uprv_realloc((void *) (array), (newSize) * sizeof (array)[0])
|
||||
|
||||
#define DELETE_ARRAY(array) uprv_free((void *) (array))
|
||||
|
||||
struct RCEI
|
||||
@ -63,8 +59,8 @@ struct RCEBuffer
|
||||
RCEBuffer();
|
||||
~RCEBuffer();
|
||||
|
||||
UBool empty() const;
|
||||
void put(uint32_t ce, int32_t ixLow, int32_t ixHigh);
|
||||
UBool isEmpty() const;
|
||||
void put(uint32_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode);
|
||||
const RCEI *get();
|
||||
};
|
||||
|
||||
@ -82,15 +78,22 @@ RCEBuffer::~RCEBuffer()
|
||||
}
|
||||
}
|
||||
|
||||
UBool RCEBuffer::empty() const
|
||||
UBool RCEBuffer::isEmpty() const
|
||||
{
|
||||
return bufferIndex <= 0;
|
||||
}
|
||||
|
||||
void RCEBuffer::put(uint32_t ce, int32_t ixLow, int32_t ixHigh)
|
||||
void RCEBuffer::put(uint32_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode)
|
||||
{
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
if (bufferIndex >= bufferSize) {
|
||||
RCEI *newBuffer = NEW_ARRAY(RCEI, bufferSize + BUFFER_GROW);
|
||||
if (newBuffer == NULL) {
|
||||
errorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
ARRAY_COPY(newBuffer, buffer, bufferSize);
|
||||
|
||||
@ -137,15 +140,22 @@ void PCEBuffer::reset()
|
||||
bufferIndex = 0;
|
||||
}
|
||||
|
||||
UBool PCEBuffer::empty() const
|
||||
UBool PCEBuffer::isEmpty() const
|
||||
{
|
||||
return bufferIndex <= 0;
|
||||
}
|
||||
|
||||
void PCEBuffer::put(uint64_t ce, int32_t ixLow, int32_t ixHigh)
|
||||
void PCEBuffer::put(uint64_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode)
|
||||
{
|
||||
if (U_FAILURE(errorCode)) {
|
||||
return;
|
||||
}
|
||||
if (bufferIndex >= bufferSize) {
|
||||
PCEI *newBuffer = NEW_ARRAY(PCEI, bufferSize + BUFFER_GROW);
|
||||
if (newBuffer == NULL) {
|
||||
errorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
ARRAY_COPY(newBuffer, buffer, bufferSize);
|
||||
|
||||
@ -381,7 +391,7 @@ UCollationPCE::previousProcessed(
|
||||
|
||||
// pceBuffer.reset();
|
||||
|
||||
while (pceBuffer.empty()) {
|
||||
while (pceBuffer.isEmpty()) {
|
||||
// buffer raw CEs up to non-ignorable primary
|
||||
RCEBuffer rceb;
|
||||
int32_t ce;
|
||||
@ -393,30 +403,33 @@ UCollationPCE::previousProcessed(
|
||||
low = cei->getOffset();
|
||||
|
||||
if (ce == UCOL_NULLORDER) {
|
||||
if (! rceb.empty()) {
|
||||
if (!rceb.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
goto finish;
|
||||
}
|
||||
|
||||
rceb.put((uint32_t)ce, low, high);
|
||||
} while ((ce & UCOL_PRIMARYORDERMASK) == 0 || isContinuation(ce));
|
||||
rceb.put((uint32_t)ce, low, high, *status);
|
||||
} while (U_SUCCESS(*status) && ((ce & UCOL_PRIMARYORDERMASK) == 0 || isContinuation(ce)));
|
||||
|
||||
// process the raw CEs
|
||||
while (! rceb.empty()) {
|
||||
while (U_SUCCESS(*status) && !rceb.isEmpty()) {
|
||||
const RCEI *rcei = rceb.get();
|
||||
|
||||
result = processCE(rcei->ce);
|
||||
|
||||
if (result != UCOL_IGNORABLE) {
|
||||
pceBuffer.put(result, rcei->low, rcei->high);
|
||||
pceBuffer.put(result, rcei->low, rcei->high, *status);
|
||||
}
|
||||
}
|
||||
if (U_FAILURE(*status)) {
|
||||
return UCOL_PROCESSED_NULLORDER;
|
||||
}
|
||||
}
|
||||
|
||||
finish:
|
||||
if (pceBuffer.empty()) {
|
||||
if (pceBuffer.isEmpty()) {
|
||||
// **** Is -1 the right value for ixLow, ixHigh? ****
|
||||
if (ixLow != NULL) {
|
||||
*ixLow = -1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2001-2014 IBM and others. All rights reserved.
|
||||
* Copyright (C) 2001-2015 IBM and others. All rights reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
* 08/13/2001 synwee Creation.
|
||||
@ -69,8 +69,8 @@ struct PCEBuffer
|
||||
~PCEBuffer();
|
||||
|
||||
void reset();
|
||||
UBool empty() const;
|
||||
void put(uint64_t ce, int32_t ixLow, int32_t ixHigh);
|
||||
UBool isEmpty() const;
|
||||
void put(uint64_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode);
|
||||
const PCEI *get();
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
/ *
|
||||
* (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
|
||||
* (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
@ -633,9 +633,9 @@ le_int32 IndicReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
|
||||
MPreFixups *mpreFixups = NULL;
|
||||
const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
|
||||
|
||||
if(classTable==NULL) {
|
||||
success = LE_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
if (classTable==NULL) {
|
||||
success = LE_INTERNAL_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (classTable->scriptFlags & SF_MPRE_FIXUP) {
|
||||
@ -1074,6 +1074,9 @@ le_int32 IndicReordering::v2process(const LEUnicode *chars, le_int32 charCount,
|
||||
LEUnicode *outChars, LEGlyphStorage &glyphStorage)
|
||||
{
|
||||
const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
|
||||
if (classTable == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DynamicProperties dynProps[INDIC_BLOCK_SIZE];
|
||||
IndicReordering::getDynamicProperties(dynProps,classTable);
|
||||
|
Loading…
Reference in New Issue
Block a user