Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: icu46/source/common/unifilt.cpp

Issue 5516007: Check in the pristine copy of ICU 4.6... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « icu46/source/common/unicode/uversion.h ('k') | icu46/source/common/unifunct.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 **********************************************************************
3 * Copyright (c) 2001-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 07/18/01 aliu Creation.
8 **********************************************************************
9 */
10
11 #include "unicode/unifilt.h"
12 #include "unicode/rep.h"
13
14 U_NAMESPACE_BEGIN
15 UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(UnicodeFilter)
16
17
18 /* Define this here due to the lack of another file.
19 It can't be defined in the header */
20 UnicodeMatcher::~UnicodeMatcher() {}
21
22 UnicodeFilter::~UnicodeFilter() {}
23
24 /**
25 * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
26 * and return the pointer.
27 */
28 UnicodeMatcher* UnicodeFilter::toMatcher() const {
29 return (UnicodeMatcher*) this;
30 }
31
32 void UnicodeFilter::setData(const TransliterationRuleData*) {}
33
34 /**
35 * Default implementation of UnicodeMatcher::matches() for Unicode
36 * filters. Matches a single code point at offset (either one or
37 * two 16-bit code units).
38 */
39 UMatchDegree UnicodeFilter::matches(const Replaceable& text,
40 int32_t& offset,
41 int32_t limit,
42 UBool incremental) {
43 UChar32 c;
44 if (offset < limit &&
45 contains(c = text.char32At(offset))) {
46 offset += UTF_CHAR_LENGTH(c);
47 return U_MATCH;
48 }
49 if (offset > limit &&
50 contains(c = text.char32At(offset))) {
51 // Backup offset by 1, unless the preceding character is a
52 // surrogate pair -- then backup by 2 (keep offset pointing at
53 // the lead surrogate).
54 --offset;
55 if (offset >= 0) {
56 offset -= UTF_CHAR_LENGTH(text.char32At(offset)) - 1;
57 }
58 return U_MATCH;
59 }
60 if (incremental && offset == limit) {
61 return U_PARTIAL_MATCH;
62 }
63 return U_MISMATCH;
64 }
65
66 U_NAMESPACE_END
67
68 //eof
OLDNEW
« no previous file with comments | « icu46/source/common/unicode/uversion.h ('k') | icu46/source/common/unifunct.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698