]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/scriptset.cpp
ICU-57149.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / scriptset.cpp
index 809e5f63a9f0c47a590de013c78302aa7106833b..9be244e0bbfebf4ab34b45fec7bffea6f68a0385 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2013, International Business Machines
+*   Copyright (C) 2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *
 
 #include "scriptset.h"
 #include "uassert.h"
+#include "cmemory.h"
 
 U_NAMESPACE_BEGIN
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 //----------------------------------------------------------------------------
 //
 //  ScriptSet implementation
 //
 //----------------------------------------------------------------------------
 ScriptSet::ScriptSet() {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         bits[i] = 0;
     }
 }
@@ -42,7 +41,7 @@ ScriptSet::ScriptSet(const ScriptSet &other) {
     
 
 ScriptSet & ScriptSet::operator =(const ScriptSet &other) {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         bits[i] = other.bits[i];
     }
     return *this;
@@ -50,7 +49,7 @@ ScriptSet & ScriptSet::operator =(const ScriptSet &other) {
 
 
 UBool ScriptSet::operator == (const ScriptSet &other) const {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         if (bits[i] != other.bits[i]) {
             return FALSE;
         }
@@ -103,14 +102,14 @@ ScriptSet &ScriptSet::reset(UScriptCode script, UErrorCode &status) {
 
 
 ScriptSet &ScriptSet::Union(const ScriptSet &other) {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         bits[i] |= other.bits[i];
     }
     return *this;
 }
 
 ScriptSet &ScriptSet::intersect(const ScriptSet &other) {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         bits[i] &= other.bits[i];
     }
     return *this;
@@ -126,7 +125,7 @@ ScriptSet &ScriptSet::intersect(UScriptCode script, UErrorCode &status) {
 }
     
 UBool ScriptSet::intersects(const ScriptSet &other) const {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         if ((bits[i] & other.bits[i]) != 0) {
             return true;
         }
@@ -142,7 +141,7 @@ UBool ScriptSet::contains(const ScriptSet &other) const {
 
 
 ScriptSet &ScriptSet::setAll() {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         bits[i] = 0xffffffffu;
     }
     return *this;
@@ -150,7 +149,7 @@ ScriptSet &ScriptSet::setAll() {
 
 
 ScriptSet &ScriptSet::resetAll() {
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         bits[i] = 0;
     }
     return *this;
@@ -160,7 +159,7 @@ int32_t ScriptSet::countMembers() const {
     // This bit counter is good for sparse numbers of '1's, which is
     //  very much the case that we will usually have.
     int32_t count = 0;
-    for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+    for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         uint32_t x = bits[i];
         while (x > 0) {
             count++;
@@ -172,7 +171,7 @@ int32_t ScriptSet::countMembers() const {
 
 int32_t ScriptSet::hashCode() const {
     int32_t hash = 0;
-    for (int32_t i=0; i<LENGTHOF(bits); i++) {
+    for (int32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
         hash ^= bits[i];
     }
     return hash;
@@ -196,7 +195,7 @@ UnicodeString &ScriptSet::displayScripts(UnicodeString &dest) const {
     UBool firstTime = TRUE;
     for (int32_t i = nextSetBit(0); i >= 0; i = nextSetBit(i + 1)) {
         if (!firstTime) {
-            dest.append(0x20);
+            dest.append((UChar)0x20);
         }
         firstTime = FALSE;
         const char *scriptName = uscript_getShortName((UScriptCode(i)));