OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 static bool searcherInUse; | 242 static bool searcherInUse; |
243 #endif | 243 #endif |
244 | 244 |
245 static UStringSearch* createSearcher() | 245 static UStringSearch* createSearcher() |
246 { | 246 { |
247 // Provide a non-empty pattern and non-empty text so usearch_open will not f
ail, | 247 // Provide a non-empty pattern and non-empty text so usearch_open will not f
ail, |
248 // but it doesn't matter exactly what it is, since we don't perform any sear
ches | 248 // but it doesn't matter exactly what it is, since we don't perform any sear
ches |
249 // without setting both the pattern and the text. | 249 // without setting both the pattern and the text. |
250 UErrorCode status = U_ZERO_ERROR; | 250 UErrorCode status = U_ZERO_ERROR; |
251 String searchCollatorName = currentSearchLocaleID() + String("@collation=sea
rch"); | 251 String searchCollatorName = currentSearchLocaleID() + String("@collation=sea
rch"); |
252 UStringSearch* searcher = usearch_open(&newlineCharacter, 1, &newlineCharact
er, 1, searchCollatorName.utf8().data(), 0, &status); | 252 UStringSearch* searcher = usearch_open(&characterNewline, 1, &characterNewli
ne, 1, searchCollatorName.utf8().data(), 0, &status); |
253 ASSERT(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING || statu
s == U_USING_DEFAULT_WARNING); | 253 ASSERT(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING || statu
s == U_USING_DEFAULT_WARNING); |
254 return searcher; | 254 return searcher; |
255 } | 255 } |
256 | 256 |
257 static UStringSearch* searcher() | 257 static UStringSearch* searcher() |
258 { | 258 { |
259 static UStringSearch* searcher = createSearcher(); | 259 static UStringSearch* searcher = createSearcher(); |
260 return searcher; | 260 return searcher; |
261 } | 261 } |
262 | 262 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 if (m_targetRequiresKanaWorkaround) | 329 if (m_targetRequiresKanaWorkaround) |
330 normalizeCharactersIntoNFCForm(m_target.data(), m_target.size(), m_norma
lizedTarget); | 330 normalizeCharactersIntoNFCForm(m_target.data(), m_target.size(), m_norma
lizedTarget); |
331 } | 331 } |
332 | 332 |
333 inline SearchBuffer::~SearchBuffer() | 333 inline SearchBuffer::~SearchBuffer() |
334 { | 334 { |
335 // Leave the static object pointing to valid strings (pattern=targer, | 335 // Leave the static object pointing to valid strings (pattern=targer, |
336 // text=buffer). Otheriwse, usearch_reset() will results in 'use-after-free' | 336 // text=buffer). Otheriwse, usearch_reset() will results in 'use-after-free' |
337 // error. | 337 // error. |
338 UErrorCode status = U_ZERO_ERROR; | 338 UErrorCode status = U_ZERO_ERROR; |
339 usearch_setPattern(blink::searcher(), &newlineCharacter, 1, &status); | 339 usearch_setPattern(blink::searcher(), &characterNewline, 1, &status); |
340 usearch_setText(blink::searcher(), &newlineCharacter, 1, &status); | 340 usearch_setText(blink::searcher(), &characterNewline, 1, &status); |
341 ASSERT(status == U_ZERO_ERROR); | 341 ASSERT(status == U_ZERO_ERROR); |
342 | 342 |
343 unlockSearcher(); | 343 unlockSearcher(); |
344 } | 344 } |
345 | 345 |
346 template<typename CharType> | 346 template<typename CharType> |
347 inline void SearchBuffer::append(const CharType* characters, size_t length) | 347 inline void SearchBuffer::append(const CharType* characters, size_t length) |
348 { | 348 { |
349 ASSERT(length); | 349 ASSERT(length); |
350 | 350 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 resultEnd = collapseTo; | 659 resultEnd = collapseTo; |
660 return; | 660 return; |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); | 664 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); |
665 computeRangeIterator.calculateCharacterSubrange(matchStart, matchLength, res
ultStart, resultEnd); | 665 computeRangeIterator.calculateCharacterSubrange(matchStart, matchLength, res
ultStart, resultEnd); |
666 } | 666 } |
667 | 667 |
668 } // namespace blink | 668 } // namespace blink |
OLD | NEW |