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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « icu46/source/common/unicode/uversion.h ('k') | icu46/source/common/unifunct.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: icu46/source/common/unifilt.cpp
===================================================================
--- icu46/source/common/unifilt.cpp (revision 0)
+++ icu46/source/common/unifilt.cpp (revision 0)
@@ -0,0 +1,68 @@
+/*
+**********************************************************************
+* Copyright (c) 2001-2004, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* Date Name Description
+* 07/18/01 aliu Creation.
+**********************************************************************
+*/
+
+#include "unicode/unifilt.h"
+#include "unicode/rep.h"
+
+U_NAMESPACE_BEGIN
+UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(UnicodeFilter)
+
+
+/* Define this here due to the lack of another file.
+ It can't be defined in the header */
+UnicodeMatcher::~UnicodeMatcher() {}
+
+UnicodeFilter::~UnicodeFilter() {}
+
+/**
+ * UnicodeFunctor API. Cast 'this' to a UnicodeMatcher* pointer
+ * and return the pointer.
+ */
+UnicodeMatcher* UnicodeFilter::toMatcher() const {
+ return (UnicodeMatcher*) this;
+}
+
+void UnicodeFilter::setData(const TransliterationRuleData*) {}
+
+/**
+ * Default implementation of UnicodeMatcher::matches() for Unicode
+ * filters. Matches a single code point at offset (either one or
+ * two 16-bit code units).
+ */
+UMatchDegree UnicodeFilter::matches(const Replaceable& text,
+ int32_t& offset,
+ int32_t limit,
+ UBool incremental) {
+ UChar32 c;
+ if (offset < limit &&
+ contains(c = text.char32At(offset))) {
+ offset += UTF_CHAR_LENGTH(c);
+ return U_MATCH;
+ }
+ if (offset > limit &&
+ contains(c = text.char32At(offset))) {
+ // Backup offset by 1, unless the preceding character is a
+ // surrogate pair -- then backup by 2 (keep offset pointing at
+ // the lead surrogate).
+ --offset;
+ if (offset >= 0) {
+ offset -= UTF_CHAR_LENGTH(text.char32At(offset)) - 1;
+ }
+ return U_MATCH;
+ }
+ if (incremental && offset == limit) {
+ return U_PARTIAL_MATCH;
+ }
+ return U_MISMATCH;
+}
+
+U_NAMESPACE_END
+
+//eof
Property changes on: icu46/source/common/unifilt.cpp
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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