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

Side by Side Diff: source/common/brkiter.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/common/brkeng.cpp ('k') | source/common/caniter.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) 1997-2014, International Business Machines Corporation and 3 * Copyright (C) 1997-2015, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ******************************************************************************* 5 *******************************************************************************
6 * 6 *
7 * File brkiter.cpp 7 * File brkiter.cpp
8 * 8 *
9 * Modification History: 9 * Modification History:
10 * 10 *
11 * Date Name Description 11 * Date Name Description
12 * 02/18/97 aliu Converted from OpenClass. Added DONE. 12 * 02/18/97 aliu Converted from OpenClass. Added DONE.
13 * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance meth ods. 13 * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance meth ods.
14 ******************************************************************************** ********* 14 ******************************************************************************** *********
15 */ 15 */
16 16
17 // ***************************************************************************** 17 // *****************************************************************************
18 // This file was generated from the java source file BreakIterator.java 18 // This file was generated from the java source file BreakIterator.java
19 // ***************************************************************************** 19 // *****************************************************************************
20 20
21 #include "unicode/utypes.h" 21 #include "unicode/utypes.h"
22 22
23 #if !UCONFIG_NO_BREAK_ITERATION 23 #if !UCONFIG_NO_BREAK_ITERATION
24 24
25 #include "unicode/rbbi.h" 25 #include "unicode/rbbi.h"
26 #include "unicode/brkiter.h" 26 #include "unicode/brkiter.h"
27 #include "unicode/udata.h" 27 #include "unicode/udata.h"
28 #include "unicode/ures.h" 28 #include "unicode/ures.h"
29 #include "unicode/ustring.h" 29 #include "unicode/ustring.h"
30 #include "unicode/filteredbrk.h"
30 #include "ucln_cmn.h" 31 #include "ucln_cmn.h"
31 #include "cstring.h" 32 #include "cstring.h"
32 #include "umutex.h" 33 #include "umutex.h"
33 #include "servloc.h" 34 #include "servloc.h"
34 #include "locbased.h" 35 #include "locbased.h"
35 #include "uresimp.h" 36 #include "uresimp.h"
36 #include "uassert.h" 37 #include "uassert.h"
37 #include "ubrkimpl.h" 38 #include "ubrkimpl.h"
38 #include "charstr.h" 39 #include "charstr.h"
39 40
(...skipping 22 matching lines...) Expand all
62 UResourceBundle *brkName = &brkNameStack; 63 UResourceBundle *brkName = &brkNameStack;
63 RuleBasedBreakIterator *result = NULL; 64 RuleBasedBreakIterator *result = NULL;
64 65
65 if (U_FAILURE(status)) 66 if (U_FAILURE(status))
66 return NULL; 67 return NULL;
67 68
68 ures_initStackObject(brkRules); 69 ures_initStackObject(brkRules);
69 ures_initStackObject(brkName); 70 ures_initStackObject(brkName);
70 71
71 // Get the locale 72 // Get the locale
72 UResourceBundle *b = ures_open(U_ICUDATA_BRKITR, loc.getName(), &status); 73 UResourceBundle *b = ures_openNoDefault(U_ICUDATA_BRKITR, loc.getName(), &st atus);
73 /* this is a hack for now. Should be fixed when the data is fetched from
74 brk_index.txt */
75 if(status==U_USING_DEFAULT_WARNING){
76 status=U_ZERO_ERROR;
77 ures_openFillIn(b, U_ICUDATA_BRKITR, "", &status);
78 }
79 74
80 // Get the "boundaries" array. 75 // Get the "boundaries" array.
81 if (U_SUCCESS(status)) { 76 if (U_SUCCESS(status)) {
82 brkRules = ures_getByKeyWithFallback(b, "boundaries", brkRules, &status) ; 77 brkRules = ures_getByKeyWithFallback(b, "boundaries", brkRules, &status) ;
83 // Get the string object naming the rules file 78 // Get the string object naming the rules file
84 brkName = ures_getByKeyWithFallback(brkRules, type, brkName, &status); 79 brkName = ures_getByKeyWithFallback(brkRules, type, brkName, &status);
85 // Get the actual string 80 // Get the actual string
86 brkfname = ures_getString(brkName, &size, &status); 81 brkfname = ures_getString(brkName, &size, &status);
87 U_ASSERT((size_t)size<sizeof(fnbuff)); 82 U_ASSERT((size_t)size<sizeof(fnbuff));
88 if ((size_t)size>=sizeof(fnbuff)) { 83 if ((size_t)size>=sizeof(fnbuff)) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return result; 377 return result;
383 } 378 }
384 else 379 else
385 #endif 380 #endif
386 { 381 {
387 return makeInstance(loc, kind, status); 382 return makeInstance(loc, kind, status);
388 } 383 }
389 } 384 }
390 385
391 // ------------------------------------- 386 // -------------------------------------
387 enum { kKeyValueLenMax = 32 };
392 388
393 BreakIterator* 389 BreakIterator*
394 BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status) 390 BreakIterator::makeInstance(const Locale& loc, int32_t kind, UErrorCode& status)
395 { 391 {
396 392
397 if (U_FAILURE(status)) { 393 if (U_FAILURE(status)) {
398 return NULL; 394 return NULL;
399 } 395 }
396 char lbType[kKeyValueLenMax];
400 397
401 BreakIterator *result = NULL; 398 BreakIterator *result = NULL;
402 switch (kind) { 399 switch (kind) {
403 case UBRK_CHARACTER: 400 case UBRK_CHARACTER:
404 result = BreakIterator::buildInstance(loc, "grapheme", kind, status); 401 result = BreakIterator::buildInstance(loc, "grapheme", kind, status);
405 break; 402 break;
406 case UBRK_WORD: 403 case UBRK_WORD:
407 result = BreakIterator::buildInstance(loc, "word", kind, status); 404 result = BreakIterator::buildInstance(loc, "word", kind, status);
408 break; 405 break;
409 case UBRK_LINE: 406 case UBRK_LINE:
410 result = BreakIterator::buildInstance(loc, "line", kind, status); 407 uprv_strcpy(lbType, "line");
408 {
409 char lbKeyValue[kKeyValueLenMax] = {0};
410 UErrorCode kvStatus = U_ZERO_ERROR;
411 int32_t kLen = loc.getKeywordValue("lb", lbKeyValue, kKeyValueLenMax , kvStatus);
412 if (U_SUCCESS(kvStatus) && kLen > 0 && (uprv_strcmp(lbKeyValue,"stri ct")==0 || uprv_strcmp(lbKeyValue,"normal")==0 || uprv_strcmp(lbKeyValue,"loose" )==0)) {
413 uprv_strcat(lbType, "_");
414 uprv_strcat(lbType, lbKeyValue);
415 }
416 }
417 result = BreakIterator::buildInstance(loc, lbType, kind, status);
411 break; 418 break;
412 case UBRK_SENTENCE: 419 case UBRK_SENTENCE:
413 result = BreakIterator::buildInstance(loc, "sentence", kind, status); 420 result = BreakIterator::buildInstance(loc, "sentence", kind, status);
421 {
422 char ssKeyValue[kKeyValueLenMax] = {0};
423 UErrorCode kvStatus = U_ZERO_ERROR;
424 int32_t kLen = loc.getKeywordValue("ss", ssKeyValue, kKeyValueLenMax , kvStatus);
425 if (U_SUCCESS(kvStatus) && kLen > 0 && uprv_strcmp(ssKeyValue,"stand ard")==0) {
426 FilteredBreakIteratorBuilder* fbiBuilder = FilteredBreakIterator Builder::createInstance(loc, kvStatus);
427 if (U_SUCCESS(kvStatus)) {
428 result = fbiBuilder->build(result, status);
429 delete fbiBuilder;
430 }
431 }
432 }
414 break; 433 break;
415 case UBRK_TITLE: 434 case UBRK_TITLE:
416 result = BreakIterator::buildInstance(loc, "title", kind, status); 435 result = BreakIterator::buildInstance(loc, "title", kind, status);
417 break; 436 break;
418 default: 437 default:
419 status = U_ILLEGAL_ARGUMENT_ERROR; 438 status = U_ILLEGAL_ARGUMENT_ERROR;
420 } 439 }
421 440
422 if (U_FAILURE(status)) { 441 if (U_FAILURE(status)) {
423 return NULL; 442 return NULL;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 BreakIterator::BreakIterator (const Locale& valid, const Locale& actual) { 483 BreakIterator::BreakIterator (const Locale& valid, const Locale& actual) {
465 U_LOCALE_BASED(locBased, (*this)); 484 U_LOCALE_BASED(locBased, (*this));
466 locBased.setLocaleIDs(valid, actual); 485 locBased.setLocaleIDs(valid, actual);
467 } 486 }
468 487
469 U_NAMESPACE_END 488 U_NAMESPACE_END
470 489
471 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 490 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
472 491
473 //eof 492 //eof
OLDNEW
« no previous file with comments | « source/common/brkeng.cpp ('k') | source/common/caniter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698