ICU-2789 add UErrorCode to getInclusions()/addPropertyStarts()

X-SVN-Rev: 11479
This commit is contained in:
Markus Scherer 2003-04-09 17:34:24 +00:00
parent 64e7e84da2
commit 280cd31096
7 changed files with 28 additions and 18 deletions

View file

@ -885,11 +885,12 @@ _enumPropertyStartsRange(const void *context, UChar32 start, UChar32 limit, uint
#define USET_ADD_CP_AND_NEXT(set, cp) uset_add(set, cp); uset_add(set, cp+1)
U_CAPI void U_EXPORT2
uchar_addPropertyStarts(USet *set) {
uchar_addPropertyStarts(USet *set, UErrorCode *pErrorCode) {
UChar32 c;
int32_t value, value2;
if(!HAVE_DATA) {
*pErrorCode=dataErrorCode;
return;
}

View file

@ -1309,7 +1309,7 @@ private:
* Return a cached copy of the inclusions list that
* uprv_getInclusions() produces.
*/
static const UnicodeSet* getInclusions();
static const UnicodeSet* getInclusions(UErrorCode &errorCode);
friend class UnicodeSetIterator;

View file

@ -2603,9 +2603,8 @@ void UnicodeSet::applyFilter(UnicodeSet::Filter filter,
// those properties. Scanning code points is slow.
if (U_FAILURE(status)) return;
const UnicodeSet* inclusions = getInclusions();
if (inclusions == NULL) {
status = U_INTERNAL_PROGRAM_ERROR;
const UnicodeSet* inclusions = getInclusions(status);
if (U_FAILURE(status)) {
return;
}
@ -2926,10 +2925,18 @@ UnicodeSet& UnicodeSet::applyPropertyPattern(const UnicodeString& pattern,
// Inclusions list
//----------------------------------------------------------------
const UnicodeSet* UnicodeSet::getInclusions() {
const UnicodeSet* UnicodeSet::getInclusions(UErrorCode &errorCode) {
if (INCLUSIONS == NULL) {
UnicodeSet *incl = new UnicodeSet();
uprv_getInclusions((USet *)incl);
if(incl == NULL) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
uprv_getInclusions((USet *)incl, &errorCode);
if(U_FAILURE(errorCode)) {
delete incl;
return NULL;
}
umtx_lock(NULL);
if (INCLUSIONS == NULL) {
INCLUSIONS = incl;

View file

@ -1101,12 +1101,10 @@ unorm_isNFSkippable(UChar32 c, UNormalizationMode mode) {
}
U_CAPI void U_EXPORT2
unorm_addPropertyStarts(USet *set) {
UErrorCode errorCode;
unorm_addPropertyStarts(USet *set, UErrorCode *pErrorCode) {
UChar c;
errorCode=U_ZERO_ERROR;
if(!_haveData(errorCode)) {
if(!_haveData(*pErrorCode)) {
return;
}

View file

@ -349,7 +349,7 @@ unorm_isNFSkippable(UChar32 c, UNormalizationMode mode);
* @internal
*/
U_CAPI void U_EXPORT2
unorm_addPropertyStarts(USet *set);
unorm_addPropertyStarts(USet *set, UErrorCode *pErrorCode);
/**
* Description of the format of unorm.dat version 2.2.

View file

@ -422,9 +422,13 @@ u_getIntPropertyMaxValue(UProperty which) {
* UnicodeSet depends on the inclusions set.
*/
U_CAPI void U_EXPORT2
uprv_getInclusions(USet* set) {
uset_removeRange(set, 0, 0x10ffff);
uprv_getInclusions(USet* set, UErrorCode *pErrorCode) {
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
return;
}
unorm_addPropertyStarts(set);
uchar_addPropertyStarts(set);
uset_clear(set);
unorm_addPropertyStarts(set, pErrorCode);
uchar_addPropertyStarts(set, pErrorCode);
}

View file

@ -332,7 +332,7 @@ uprv_getISOCommentCharacters(USet* set);
* @internal
*/
U_CAPI void U_EXPORT2
uchar_addPropertyStarts(USet *set);
uchar_addPropertyStarts(USet *set, UErrorCode *pErrorCode);
/**
* Return a set of characters for property enumeration.
@ -343,6 +343,6 @@ uchar_addPropertyStarts(USet *set);
* @internal
*/
U_CAPI void U_EXPORT2
uprv_getInclusions(USet* set);
uprv_getInclusions(USet* set, UErrorCode *pErrorCode);
#endif