Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: source/common/caniter.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/common/brkiter.cpp ('k') | source/common/charstr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/common/caniter.cpp
diff --git a/source/common/caniter.cpp b/source/common/caniter.cpp
index d47681787755ee6be6cd1658fa1c72a8cab62745..58b378181056fccc4f287417004d836dfdbe93f6 100644
--- a/source/common/caniter.cpp
+++ b/source/common/caniter.cpp
@@ -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.
*****************************************************************************
*/
@@ -294,7 +294,7 @@ void U_EXPORT2 CanonicalIterator::permute(UnicodeString &source, UBool skipZeros
for (i = 0; i < source.length(); i += U16_LENGTH(cp)) {
cp = source.char32At(i);
const UHashElement *ne = NULL;
- int32_t el = -1;
+ int32_t el = UHASH_FIRST;
UnicodeString subPermuteString = source;
// optimization:
@@ -359,7 +359,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
// TODO: optimize by not permuting any class zero.
const UHashElement *ne = NULL;
- int32_t el = -1;
+ int32_t el = UHASH_FIRST;
//Iterator it = basic.iterator();
ne = basic.nextElement(el);
//while (it.hasNext())
@@ -370,7 +370,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
permutations.removeAll();
permute(item, CANITER_SKIP_ZEROES, &permutations, status);
const UHashElement *ne2 = NULL;
- int32_t el2 = -1;
+ int32_t el2 = UHASH_FIRST;
//Iterator it2 = permutations.iterator();
ne2 = permutations.nextElement(el2);
//while (it2.hasNext())
@@ -416,7 +416,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i
}
//result.toArray(finalResult);
result_len = 0;
- el = -1;
+ el = UHASH_FIRST;
ne = result.nextElement(el);
while(ne != NULL) {
finalResult[result_len++] = *((UnicodeString *)(ne->value.pointer));
@@ -463,7 +463,7 @@ Hashtable *CanonicalIterator::getEquivalents2(Hashtable *fillinResult, const UCh
UnicodeString prefix(segment, i);
prefix += cp2;
- int32_t el = -1;
+ int32_t el = UHASH_FIRST;
const UHashElement *ne = remainder.nextElement(el);
while (ne != NULL) {
UnicodeString item = *((UnicodeString *)(ne->value.pointer));
@@ -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();
« no previous file with comments | « source/common/brkiter.cpp ('k') | source/common/charstr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698