]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/rbt_rule.cpp
ICU-62141.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / rbt_rule.cpp
index 69a2202637458ece6a4e3bf761d2caef1836be38..3569e42fa4f137f903264dc11428b17ba5a52a70 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
  **********************************************************************
- *   Copyright (C) 1999-2008, International Business Machines
+ *   Copyright (C) 1999-2011, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  **********************************************************************
  *   Date        Name        Description
@@ -15,6 +17,7 @@
 #include "unicode/rep.h"
 #include "unicode/unifilt.h"
 #include "unicode/uniset.h"
+#include "unicode/utf16.h"
 #include "rbt_rule.h"
 #include "rbt_data.h"
 #include "cmemory.h"
@@ -173,7 +176,7 @@ TransliterationRule::TransliterationRule(TransliterationRule& other) :
     segmentsCount = 0;
     if (other.segmentsCount > 0) {
         segments = (UnicodeFunctor **)uprv_malloc(other.segmentsCount * sizeof(UnicodeFunctor *));
-        uprv_memcpy(segments, other.segments, other.segmentsCount*sizeof(segments[0]));
+        uprv_memcpy(segments, other.segments, (size_t)other.segmentsCount*sizeof(segments[0]));
     }
 
     if (other.anteContext != NULL) {
@@ -315,13 +318,13 @@ UBool TransliterationRule::masks(const TransliterationRule& r2) const {
 
 static inline int32_t posBefore(const Replaceable& str, int32_t pos) {
     return (pos > 0) ?
-        pos - UTF_CHAR_LENGTH(str.char32At(pos-1)) :
+        pos - U16_LENGTH(str.char32At(pos-1)) :
         pos - 1;
 }
 
 static inline int32_t posAfter(const Replaceable& str, int32_t pos) {
     return (pos >= 0 && pos < str.length()) ?
-        pos + UTF_CHAR_LENGTH(str.char32At(pos)) :
+        pos + U16_LENGTH(str.char32At(pos)) :
         pos + 1;
 }
 
@@ -501,7 +504,7 @@ UnicodeString& TransliterationRule::toRule(UnicodeString& rule,
         rule.append((UChar)36/*$*/);
     }
 
-    ICU_Utility::appendToRule(rule, FORWARD_OP, TRUE, escapeUnprintable, quoteBuf);
+    ICU_Utility::appendToRule(rule, UnicodeString(TRUE, FORWARD_OP, 3), TRUE, escapeUnprintable, quoteBuf);
 
     // Emit the output pattern
 
@@ -531,7 +534,7 @@ void TransliterationRule::addSourceSetTo(UnicodeSet& toUnionTo) const {
     int32_t limit = anteContextLength + keyLength;
     for (int32_t i=anteContextLength; i<limit; ) {
         UChar32 ch = pattern.char32At(i);
-        i += UTF_CHAR_LENGTH(ch);
+        i += U16_LENGTH(ch);
         const UnicodeMatcher* matcher = data->lookupMatcher(ch);
         if (matcher == NULL) {
             toUnionTo.add(ch);