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

Side by Side Diff: source/common/brkiter.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 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-2013, International Business Machines Corporation and 3 * Copyright (C) 1997-2014, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ******************************************************************************* 5 *******************************************************************************
6 * 6 *
7 * File TXTBDRY.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 // *****************************************************************************
(...skipping 10 matching lines...) Expand all
28 #include "unicode/ures.h" 28 #include "unicode/ures.h"
29 #include "unicode/ustring.h" 29 #include "unicode/ustring.h"
30 #include "ucln_cmn.h" 30 #include "ucln_cmn.h"
31 #include "cstring.h" 31 #include "cstring.h"
32 #include "umutex.h" 32 #include "umutex.h"
33 #include "servloc.h" 33 #include "servloc.h"
34 #include "locbased.h" 34 #include "locbased.h"
35 #include "uresimp.h" 35 #include "uresimp.h"
36 #include "uassert.h" 36 #include "uassert.h"
37 #include "ubrkimpl.h" 37 #include "ubrkimpl.h"
38 #include "charstr.h"
38 39
39 // ***************************************************************************** 40 // *****************************************************************************
40 // class BreakIterator 41 // class BreakIterator
41 // This class implements methods for finding the location of boundaries in text. 42 // This class implements methods for finding the location of boundaries in text.
42 // Instances of BreakIterator maintain a current position and scan over text 43 // Instances of BreakIterator maintain a current position and scan over text
43 // returning the index of characters where boundaries occur. 44 // returning the index of characters where boundaries occur.
44 // ***************************************************************************** 45 // *****************************************************************************
45 46
46 U_NAMESPACE_BEGIN 47 U_NAMESPACE_BEGIN
47 48
48 // ------------------------------------- 49 // -------------------------------------
49 50
50 BreakIterator* 51 BreakIterator*
51 BreakIterator::buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode &status) 52 BreakIterator::buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode &status)
52 { 53 {
53 char fnbuff[256]; 54 char fnbuff[256];
54 char ext[4]={'\0'}; 55 char ext[4]={'\0'};
55 char actualLocale[ULOC_FULLNAME_CAPACITY]; 56 CharString actualLocale;
56 int32_t size; 57 int32_t size;
57 const UChar* brkfname = NULL; 58 const UChar* brkfname = NULL;
58 UResourceBundle brkRulesStack; 59 UResourceBundle brkRulesStack;
59 UResourceBundle brkNameStack; 60 UResourceBundle brkNameStack;
60 UResourceBundle *brkRules = &brkRulesStack; 61 UResourceBundle *brkRules = &brkRulesStack;
61 UResourceBundle *brkName = &brkNameStack; 62 UResourceBundle *brkName = &brkNameStack;
62 RuleBasedBreakIterator *result = NULL; 63 RuleBasedBreakIterator *result = NULL;
63 64
64 if (U_FAILURE(status)) 65 if (U_FAILURE(status))
65 return NULL; 66 return NULL;
(...skipping 20 matching lines...) Expand all
86 U_ASSERT((size_t)size<sizeof(fnbuff)); 87 U_ASSERT((size_t)size<sizeof(fnbuff));
87 if ((size_t)size>=sizeof(fnbuff)) { 88 if ((size_t)size>=sizeof(fnbuff)) {
88 size=0; 89 size=0;
89 if (U_SUCCESS(status)) { 90 if (U_SUCCESS(status)) {
90 status = U_BUFFER_OVERFLOW_ERROR; 91 status = U_BUFFER_OVERFLOW_ERROR;
91 } 92 }
92 } 93 }
93 94
94 // Use the string if we found it 95 // Use the string if we found it
95 if (U_SUCCESS(status) && brkfname) { 96 if (U_SUCCESS(status) && brkfname) {
96 uprv_strncpy(actualLocale, 97 actualLocale.append(ures_getLocaleInternal(brkName, &status), -1, st atus);
97 ures_getLocaleInternal(brkName, &status),
98 sizeof(actualLocale)/sizeof(actualLocale[0]));
99 98
100 UChar* extStart=u_strchr(brkfname, 0x002e); 99 UChar* extStart=u_strchr(brkfname, 0x002e);
101 int len = 0; 100 int len = 0;
102 if(extStart!=NULL){ 101 if(extStart!=NULL){
103 len = (int)(extStart-brkfname); 102 len = (int)(extStart-brkfname);
104 u_UCharsToChars(extStart+1, ext, sizeof(ext)); // nul terminates the buff 103 u_UCharsToChars(extStart+1, ext, sizeof(ext)); // nul terminates the buff
105 u_UCharsToChars(brkfname, fnbuff, len); 104 u_UCharsToChars(brkfname, fnbuff, len);
106 } 105 }
107 fnbuff[len]=0; // nul terminate 106 fnbuff[len]=0; // nul terminate
108 } 107 }
109 } 108 }
110 109
111 ures_close(brkRules); 110 ures_close(brkRules);
112 ures_close(brkName); 111 ures_close(brkName);
113 112
114 UDataMemory* file = udata_open(U_ICUDATA_BRKITR, ext, fnbuff, &status); 113 UDataMemory* file = udata_open(U_ICUDATA_BRKITR, ext, fnbuff, &status);
115 if (U_FAILURE(status)) { 114 if (U_FAILURE(status)) {
116 ures_close(b); 115 ures_close(b);
117 return NULL; 116 return NULL;
118 } 117 }
119 118
120 // Create a RuleBasedBreakIterator 119 // Create a RuleBasedBreakIterator
121 result = new RuleBasedBreakIterator(file, status); 120 result = new RuleBasedBreakIterator(file, status);
122 121
123 // If there is a result, set the valid locale and actual locale, and the kin d 122 // If there is a result, set the valid locale and actual locale, and the kin d
124 if (U_SUCCESS(status) && result != NULL) { 123 if (U_SUCCESS(status) && result != NULL) {
125 U_LOCALE_BASED(locBased, *(BreakIterator*)result); 124 U_LOCALE_BASED(locBased, *(BreakIterator*)result);
126 locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status ), actualLocale); 125 locBased.setLocaleIDs(ures_getLocaleByType(b, ULOC_VALID_LOCALE, &status ),
126 actualLocale.data());
127 result->setBreakType(kind); 127 result->setBreakType(kind);
128 } 128 }
129 129
130 ures_close(b); 130 ures_close(b);
131 131
132 if (U_FAILURE(status) && result != NULL) { // Sometimes redundant check, bu t simple 132 if (U_FAILURE(status) && result != NULL) { // Sometimes redundant check, bu t simple
133 delete result; 133 delete result;
134 return NULL; 134 return NULL;
135 } 135 }
136 136
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return 0; 454 return 0;
455 } 455 }
456 if (capacity < 1) { 456 if (capacity < 1) {
457 status = U_BUFFER_OVERFLOW_ERROR; 457 status = U_BUFFER_OVERFLOW_ERROR;
458 return 1; 458 return 1;
459 } 459 }
460 *fillInVec = 0; 460 *fillInVec = 0;
461 return 1; 461 return 1;
462 } 462 }
463 463
464 BreakIterator::BreakIterator (const Locale& valid, const Locale& actual) {
465 U_LOCALE_BASED(locBased, (*this));
466 locBased.setLocaleIDs(valid, actual);
467 }
468
464 U_NAMESPACE_END 469 U_NAMESPACE_END
465 470
466 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 471 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
467 472
468 //eof 473 //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