OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/i18n/break_iterator.h" | 5 #include "base/i18n/break_iterator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/icu/source/common/unicode/ubrk.h" | 8 #include "third_party/icu/source/common/unicode/ubrk.h" |
9 #include "third_party/icu/source/common/unicode/uchar.h" | 9 #include "third_party/icu/source/common/unicode/uchar.h" |
10 #include "third_party/icu/source/common/unicode/ustring.h" | 10 #include "third_party/icu/source/common/unicode/ustring.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 NOTREACHED() << "ubrk_openRules failed to parse rule string at line " | 67 NOTREACHED() << "ubrk_openRules failed to parse rule string at line " |
68 << parse_error.line << ", offset " << parse_error.offset; | 68 << parse_error.line << ", offset " << parse_error.offset; |
69 } | 69 } |
70 } else { | 70 } else { |
71 iter_ = ubrk_open(break_type, | 71 iter_ = ubrk_open(break_type, |
72 NULL, | 72 NULL, |
73 string_.data(), | 73 string_.data(), |
74 static_cast<int32_t>(string_.size()), | 74 static_cast<int32_t>(string_.size()), |
75 &status); | 75 &status); |
76 if (U_FAILURE(status)) { | 76 if (U_FAILURE(status)) { |
77 NOTREACHED() << "ubrk_open failed for type " << break_type | 77 NOTREACHED() << "ubrk_open failed"; |
78 << " with error " << status; | |
79 } | 78 } |
80 } | 79 } |
81 | 80 |
82 if (U_FAILURE(status)) { | 81 if (U_FAILURE(status)) { |
83 return false; | 82 return false; |
84 } | 83 } |
85 | 84 |
86 // Move the iterator to the beginning of the string. | 85 // Move the iterator to the beginning of the string. |
87 ubrk_first(static_cast<UBreakIterator*>(iter_)); | 86 ubrk_first(static_cast<UBreakIterator*>(iter_)); |
88 return true; | 87 return true; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return GetStringPiece().as_string(); | 176 return GetStringPiece().as_string(); |
178 } | 177 } |
179 | 178 |
180 StringPiece16 BreakIterator::GetStringPiece() const { | 179 StringPiece16 BreakIterator::GetStringPiece() const { |
181 DCHECK(prev_ != npos && pos_ != npos); | 180 DCHECK(prev_ != npos && pos_ != npos); |
182 return string_.substr(prev_, pos_ - prev_); | 181 return string_.substr(prev_, pos_ - prev_); |
183 } | 182 } |
184 | 183 |
185 } // namespace i18n | 184 } // namespace i18n |
186 } // namespace base | 185 } // namespace base |
OLD | NEW |