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"; | 77 NOTREACHED() << "ubrk_open failed for type " << break_type |
| 78 << " with error " << status; |
78 } | 79 } |
79 } | 80 } |
80 | 81 |
81 if (U_FAILURE(status)) { | 82 if (U_FAILURE(status)) { |
82 return false; | 83 return false; |
83 } | 84 } |
84 | 85 |
85 // Move the iterator to the beginning of the string. | 86 // Move the iterator to the beginning of the string. |
86 ubrk_first(static_cast<UBreakIterator*>(iter_)); | 87 ubrk_first(static_cast<UBreakIterator*>(iter_)); |
87 return true; | 88 return true; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return GetStringPiece().as_string(); | 177 return GetStringPiece().as_string(); |
177 } | 178 } |
178 | 179 |
179 StringPiece16 BreakIterator::GetStringPiece() const { | 180 StringPiece16 BreakIterator::GetStringPiece() const { |
180 DCHECK(prev_ != npos && pos_ != npos); | 181 DCHECK(prev_ != npos && pos_ != npos); |
181 return string_.substr(prev_, pos_ - prev_); | 182 return string_.substr(prev_, pos_ - prev_); |
182 } | 183 } |
183 | 184 |
184 } // namespace i18n | 185 } // namespace i18n |
185 } // namespace base | 186 } // namespace base |
OLD | NEW |