X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..08b89b0a244153b9f5bbb2f49c55ab0f7298122e:/icuSources/common/uniset.cpp diff --git a/icuSources/common/uniset.cpp b/icuSources/common/uniset.cpp index 4ff3f6b2..676c855d 100644 --- a/icuSources/common/uniset.cpp +++ b/icuSources/common/uniset.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 1999-2009, International Business Machines +* Copyright (C) 1999-2012, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -9,19 +9,21 @@ */ #include "unicode/utypes.h" -#include "unicode/uniset.h" #include "unicode/parsepos.h" #include "unicode/symtable.h" +#include "unicode/uniset.h" +#include "unicode/utf8.h" +#include "unicode/utf16.h" #include "ruleiter.h" #include "cmemory.h" #include "cstring.h" -#include "uhash.h" +#include "patternprops.h" +#include "uelement.h" #include "util.h" #include "uvector.h" #include "charstr.h" #include "ustrfmt.h" #include "uassert.h" -#include "hash.h" #include "bmpset.h" #include "unisetspan.h" @@ -123,11 +125,11 @@ static inline void _dbgdt(UnicodeSet* set) { // UnicodeString in UVector support //---------------------------------------------------------------- -static void U_CALLCONV cloneUnicodeString(UHashTok *dst, UHashTok *src) { +static void U_CALLCONV cloneUnicodeString(UElement *dst, UElement *src) { dst->pointer = new UnicodeString(*(UnicodeString*)src->pointer); } -static int8_t U_CALLCONV compareUnicodeString(UHashTok t1, UHashTok t2) { +static int8_t U_CALLCONV compareUnicodeString(UElement t1, UElement t2) { const UnicodeString &a = *(const UnicodeString*)t1.pointer; const UnicodeString &b = *(const UnicodeString*)t2.pointer; return a.compare(b); @@ -1059,7 +1061,7 @@ int32_t UnicodeSet::getSingleCP(const UnicodeString& s) { */ UnicodeSet& UnicodeSet::addAll(const UnicodeString& s) { UChar32 cp; - for (int32_t i = 0; i < s.length(); i += UTF_CHAR_LENGTH(cp)) { + for (int32_t i = 0; i < s.length(); i += U16_LENGTH(cp)) { cp = s.char32At(i); add(cp); } @@ -1558,7 +1560,7 @@ UBool UnicodeSet::allocateStrings(UErrorCode &status) { if (U_FAILURE(status)) { return FALSE; } - strings = new UVector(uhash_deleteUnicodeString, + strings = new UVector(uprv_deleteUObject, uhash_compareUnicodeString, 1, status); if (strings == NULL) { // Check for memory allocation error. status = U_MEMORY_ALLOCATION_ERROR; @@ -1892,7 +1894,7 @@ void UnicodeSet::retain(const UChar32* other, int32_t otherLen, int8_t polarity) void UnicodeSet::_appendToPat(UnicodeString& buf, const UnicodeString& s, UBool escapeUnprintable) { UChar32 cp; - for (int32_t i = 0; i < s.length(); i += UTF_CHAR_LENGTH(cp)) { + for (int32_t i = 0; i < s.length(); i += U16_LENGTH(cp)) { _appendToPat(buf, cp = s.char32At(i), escapeUnprintable); } } @@ -1926,7 +1928,7 @@ escapeUnprintable) { break; default: // Escape whitespace - if (uprv_isRuleWhiteSpace(c)) { + if (PatternProps::isWhiteSpace(c)) { buf.append(BACKSLASH); } break; @@ -2232,10 +2234,7 @@ int32_t UnicodeSet::spanUTF8(const char *s, int32_t length, USetSpanCondition sp UChar32 c; int32_t start=0, prev=0; do { - U8_NEXT(s, start, length, c); - if(c<0) { - c=0xfffd; - } + U8_NEXT_OR_FFFD(s, start, length, c); if(spanCondition!=contains(c)) { break; } @@ -2273,10 +2272,7 @@ int32_t UnicodeSet::spanBackUTF8(const char *s, int32_t length, USetSpanConditio UChar32 c; int32_t prev=length; do { - U8_PREV(s, 0, length, c); - if(c<0) { - c=0xfffd; - } + U8_PREV_OR_FFFD(s, 0, length, c); if(spanCondition!=contains(c)) { break; }