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

Side by Side Diff: source/i18n/identifier_info.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 unified diff | Download patch
« no previous file with comments | « source/i18n/i18n.vcxproj.filters ('k') | source/i18n/islamcal.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ********************************************************************** 2 **********************************************************************
3 * Copyright (C) 2012-2014, International Business Machines 3 * Copyright (C) 2012-2014, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ********************************************************************** 5 **********************************************************************
6 */ 6 */
7 7
8 #include "unicode/utypes.h" 8 #include "unicode/utypes.h"
9 9
10 #include "unicode/uchar.h" 10 #include "unicode/uchar.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 break; 161 break;
162 } 162 }
163 } 163 }
164 // Now make a final pass through ScriptSetSet to remove alternates that came before singles. 164 // Now make a final pass through ScriptSetSet to remove alternates that came before singles.
165 // [Kana], [Kana Hira] => [Kana] 165 // [Kana], [Kana Hira] => [Kana]
166 // This is relatively infrequent, so doesn't have to be optimized. 166 // This is relatively infrequent, so doesn't have to be optimized.
167 // We also compute any commonalities among the alternates. 167 // We also compute any commonalities among the alternates.
168 if (uhash_count(fScriptSetSet) > 0) { 168 if (uhash_count(fScriptSetSet) > 0) {
169 fCommonAmongAlternates->setAll(); 169 fCommonAmongAlternates->setAll();
170 for (int32_t it = -1;;) { 170 for (int32_t it = UHASH_FIRST;;) {
171 const UHashElement *nextHashEl = uhash_nextElement(fScriptSetSet, &i t); 171 const UHashElement *nextHashEl = uhash_nextElement(fScriptSetSet, &i t);
172 if (nextHashEl == NULL) { 172 if (nextHashEl == NULL) {
173 break; 173 break;
174 } 174 }
175 ScriptSet *next = static_cast<ScriptSet *>(nextHashEl->key.pointer); 175 ScriptSet *next = static_cast<ScriptSet *>(nextHashEl->key.pointer);
176 // [Kana], [Kana Hira] => [Kana] 176 // [Kana], [Kana Hira] => [Kana]
177 if (fRequiredScripts->intersects(*next)) { 177 if (fRequiredScripts->intersects(*next)) {
178 uhash_removeElement(fScriptSetSet, nextHashEl); 178 uhash_removeElement(fScriptSetSet, nextHashEl);
179 } else { 179 } else {
180 fCommonAmongAlternates->intersect(*next); 180 fCommonAmongAlternates->intersect(*next);
181 // [[Arab Syrc Thaa]; [Arab Syrc]] => [[Arab Syrc]] 181 // [[Arab Syrc Thaa]; [Arab Syrc]] => [[Arab Syrc]]
182 for (int32_t otherIt = -1;;) { 182 for (int32_t otherIt = UHASH_FIRST;;) {
183 const UHashElement *otherHashEl = uhash_nextElement(fScriptS etSet, &otherIt); 183 const UHashElement *otherHashEl = uhash_nextElement(fScriptS etSet, &otherIt);
184 if (otherHashEl == NULL) { 184 if (otherHashEl == NULL) {
185 break; 185 break;
186 } 186 }
187 ScriptSet *other = static_cast<ScriptSet *>(otherHashEl->key .pointer); 187 ScriptSet *other = static_cast<ScriptSet *>(otherHashEl->key .pointer);
188 if (next != other && next->contains(*other)) { 188 if (next != other && next->contains(*other)) {
189 uhash_removeElement(fScriptSetSet, nextHashEl); 189 uhash_removeElement(fScriptSetSet, nextHashEl);
190 break; 190 break;
191 } 191 }
192 } 192 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 (fCommonAmongAlternates->countMembers() == 0 ? uhash_count(fScriptSe tSet) : 1); 262 (fCommonAmongAlternates->countMembers() == 0 ? uhash_count(fScriptSe tSet) : 1);
263 return count; 263 return count;
264 } 264 }
265 265
266 266
267 267
268 UBool IdentifierInfo::containsWithAlternates(const ScriptSet &container, const S criptSet &containee) const { 268 UBool IdentifierInfo::containsWithAlternates(const ScriptSet &container, const S criptSet &containee) const {
269 if (!container.contains(containee)) { 269 if (!container.contains(containee)) {
270 return FALSE; 270 return FALSE;
271 } 271 }
272 for (int32_t iter = -1; ;) { 272 for (int32_t iter = UHASH_FIRST; ;) {
273 const UHashElement *hashEl = uhash_nextElement(fScriptSetSet, &iter); 273 const UHashElement *hashEl = uhash_nextElement(fScriptSetSet, &iter);
274 if (hashEl == NULL) { 274 if (hashEl == NULL) {
275 break; 275 break;
276 } 276 }
277 ScriptSet *alternatives = static_cast<ScriptSet *>(hashEl->key.pointer); 277 ScriptSet *alternatives = static_cast<ScriptSet *>(hashEl->key.pointer);
278 if (!container.intersects(*alternatives)) { 278 if (!container.intersects(*alternatives)) {
279 return false; 279 return false;
280 } 280 }
281 } 281 }
282 return true; 282 return true;
283 } 283 }
284 284
285 UnicodeString &IdentifierInfo::displayAlternates(UnicodeString &dest, const UHas htable *alternates, UErrorCode &status) { 285 UnicodeString &IdentifierInfo::displayAlternates(UnicodeString &dest, const UHas htable *alternates, UErrorCode &status) {
286 UVector sorted(status); 286 UVector sorted(status);
287 if (U_FAILURE(status)) { 287 if (U_FAILURE(status)) {
288 return dest; 288 return dest;
289 } 289 }
290 for (int32_t pos = -1; ;) { 290 for (int32_t pos = UHASH_FIRST; ;) {
291 const UHashElement *el = uhash_nextElement(alternates, &pos); 291 const UHashElement *el = uhash_nextElement(alternates, &pos);
292 if (el == NULL) { 292 if (el == NULL) {
293 break; 293 break;
294 } 294 }
295 ScriptSet *ss = static_cast<ScriptSet *>(el->key.pointer); 295 ScriptSet *ss = static_cast<ScriptSet *>(el->key.pointer);
296 sorted.addElement(ss, status); 296 sorted.addElement(ss, status);
297 } 297 }
298 sorted.sort(uhash_compareScriptSet, status); 298 sorted.sort(uhash_compareScriptSet, status);
299 UnicodeString separator = UNICODE_STRING_SIMPLE("; "); 299 UnicodeString separator = UNICODE_STRING_SIMPLE("; ");
300 for (int32_t i=0; i<sorted.size(); i++) { 300 for (int32_t i=0; i<sorted.size(); i++) {
301 if (i>0) { 301 if (i>0) {
302 dest.append(separator); 302 dest.append(separator);
303 } 303 }
304 ScriptSet *ss = static_cast<ScriptSet *>(sorted.elementAt(i)); 304 ScriptSet *ss = static_cast<ScriptSet *>(sorted.elementAt(i));
305 ss->displayScripts(dest); 305 ss->displayScripts(dest);
306 } 306 }
307 return dest; 307 return dest;
308 } 308 }
309 309
310 U_NAMESPACE_END 310 U_NAMESPACE_END
311 311
OLDNEW
« no previous file with comments | « source/i18n/i18n.vcxproj.filters ('k') | source/i18n/islamcal.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698