diff options
author | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 21:26:52 +0000 |
---|---|---|
committer | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 21:26:52 +0000 |
commit | b1080093bca40696fae18292fbd40129412cb381 (patch) | |
tree | 51c1ab105688b2464e8bbe683d45be36a4db3479 | |
parent | 783f5be582cb485e42018d1ff948000eeac1bc2f (diff) | |
download | chromium_src-b1080093bca40696fae18292fbd40129412cb381.zip chromium_src-b1080093bca40696fae18292fbd40129412cb381.tar.gz chromium_src-b1080093bca40696fae18292fbd40129412cb381.tar.bz2 |
Fixes word_iterator to actually compile. Next time, never just paste code in that _should_ fix things without actually compiling :(
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@672 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/word_iterator.cc | 9 | ||||
-rw-r--r-- | base/word_iterator.h | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/base/word_iterator.cc b/base/word_iterator.cc index b0161f2..fcd32f5 100644 --- a/base/word_iterator.cc +++ b/base/word_iterator.cc @@ -31,6 +31,7 @@ #include "base/logging.h" #include "unicode/ubrk.h" +#include "unicode/ustring.h" const int WordIterator::npos = -1; @@ -61,25 +62,25 @@ bool WordIterator::Init() { NOTREACHED(); break_type = UBRK_LINE; } -#ifdef U_WCHAR_IS_UTF16 +#if defined(WCHAR_T_IS_UTF16) iter_ = ubrk_open(break_type, NULL, string_.data(), static_cast<int32_t>(string_.size()), &status); -#else // U_WCHAR_IS_UTF16 +#else // WCHAR_T_IS_UTF16 // When wchar_t is wider than UChar (16 bits), transform |string_| into a // UChar* string. Size the UChar* buffer to be large enough to hold twice // as many UTF-16 code points as there are UCS-4 characters, in case each // character translates to a UTF-16 surrogate pair, and leave room for a NUL // terminator. // TODO(avi): avoid this alloc - chars_.resize(wide.length() * sizeof(UChar) + 1); + chars_.resize(string_.length() * sizeof(UChar) + 1); UErrorCode error = U_ZERO_ERROR; int32_t destLength; u_strFromWCS(&chars_[0], chars_.size(), &destLength, string_.data(), string_.length(), &error); - iter_ = ubrk_open(break_type, NULL, chars_, destLength, &status); + iter_ = ubrk_open(break_type, NULL, &chars_[0], destLength, &status); #endif if (U_FAILURE(status)) { NOTREACHED() << "ubrk_open failed"; diff --git a/base/word_iterator.h b/base/word_iterator.h index 8329f64..097290f 100644 --- a/base/word_iterator.h +++ b/base/word_iterator.h @@ -31,9 +31,11 @@ #define BASE_WORD_ITERATOR_H__ #include <string> +#include <vector> + +#include "unicode/uchar.h" #include "base/basictypes.h" -#include "unicode/umachine.h" // Needed for U_WCHAR_IS_UTF16. // The WordIterator class iterates through the words and word breaks // in a string. (In the string " foo bar! ", the word breaks are at the @@ -94,7 +96,7 @@ class WordIterator { private: // ICU iterator. void* iter_; -#ifndef U_WCHAR_IS_UTF16 +#if !defined(WCHAR_T_IS_UTF16) std::vector<UChar> chars_; #endif |