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 "unicode/ubrk.h" | 8 #include "unicode/ubrk.h" |
9 #include "unicode/uchar.h" | 9 #include "unicode/uchar.h" |
10 #include "unicode/ustring.h" | 10 #include "unicode/ustring.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 pos = ubrk_next(static_cast<UBreakIterator*>(iter_)); | 64 pos = ubrk_next(static_cast<UBreakIterator*>(iter_)); |
65 if (pos == UBRK_DONE) { | 65 if (pos == UBRK_DONE) { |
66 pos_ = npos; | 66 pos_ = npos; |
67 return false; | 67 return false; |
68 } | 68 } |
69 pos_ = static_cast<size_t>(pos); | 69 pos_ = static_cast<size_t>(pos); |
70 return true; | 70 return true; |
71 case BREAK_NEWLINE: | 71 case BREAK_NEWLINE: |
72 do { | 72 do { |
73 pos = ubrk_next(static_cast<UBreakIterator*>(iter_)); | 73 pos = ubrk_next(static_cast<UBreakIterator*>(iter_)); |
74 if (pos == UBRK_DONE) { | 74 if (pos == UBRK_DONE) |
75 break; | 75 break; |
76 } | |
77 pos_ = static_cast<size_t>(pos); | 76 pos_ = static_cast<size_t>(pos); |
78 status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); | 77 status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); |
79 } while (status >= UBRK_LINE_SOFT && status < UBRK_LINE_SOFT_LIMIT); | 78 } while (status >= UBRK_LINE_SOFT && status < UBRK_LINE_SOFT_LIMIT); |
80 if (pos == UBRK_DONE && prev_ == pos_) { | 79 if (pos == UBRK_DONE && prev_ == pos_) { |
81 pos_ = npos; | 80 pos_ = npos; |
82 return false; | 81 return false; |
83 } | 82 } |
84 return true; | 83 return true; |
85 default: | 84 default: |
86 NOTREACHED() << "invalid break_type_"; | 85 NOTREACHED() << "invalid break_type_"; |
87 return false; | 86 return false; |
88 } | 87 } |
89 } | 88 } |
90 | 89 |
91 bool BreakIterator::IsWord() const { | 90 bool BreakIterator::IsWord() const { |
92 return (break_type_ == BREAK_WORD && | 91 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); |
93 ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)) != | 92 return (break_type_ == BREAK_WORD && status != UBRK_WORD_NONE); |
94 UBRK_WORD_NONE); | |
95 } | 93 } |
96 | 94 |
97 string16 BreakIterator::GetString() const { | 95 string16 BreakIterator::GetString() const { |
98 DCHECK(prev_ != npos && pos_ != npos); | 96 DCHECK(prev_ != npos && pos_ != npos); |
99 return string_.substr(prev_, pos_ - prev_); | 97 return string_.substr(prev_, pos_ - prev_); |
100 } | 98 } |
101 | 99 |
102 } // namespace i18n | 100 } // namespace i18n |
103 } // namespace base | 101 } // namespace base |
OLD | NEW |