]> granicus.if.org Git - icu/commitdiff
ICU-7653 move LENGTHOF(array) to common, internal header
authorTom Zhang <tomzhang@svn.icu-project.org>
Thu, 28 Aug 2014 14:55:34 +0000 (14:55 +0000)
committerTom Zhang <tomzhang@svn.icu-project.org>
Thu, 28 Aug 2014 14:55:34 +0000 (14:55 +0000)
X-SVN-Rev: 36265

131 files changed:
icu4c/source/common/cmemory.h
icu4c/source/common/dictbe.cpp
icu4c/source/common/listformatter.cpp
icu4c/source/common/locid.cpp
icu4c/source/common/putil.cpp
icu4c/source/common/rbbiscan.cpp
icu4c/source/common/simplepatternformatter.cpp
icu4c/source/common/uchar.c
icu4c/source/common/ucnv2022.cpp
icu4c/source/common/ucnv_ct.c
icu4c/source/common/ucnv_lmb.c
icu4c/source/common/udata.cpp
icu4c/source/common/uloc_tag.c
icu4c/source/common/unames.cpp
icu4c/source/common/uniset_props.cpp
icu4c/source/common/unorm.cpp
icu4c/source/common/unormcmp.cpp
icu4c/source/common/uprops.cpp
icu4c/source/common/uresdata.c
icu4c/source/common/uscript_props.cpp
icu4c/source/common/ushape.cpp
icu4c/source/common/ustrcase.cpp
icu4c/source/common/ustrtrns.cpp
icu4c/source/common/utrie2_builder.cpp
icu4c/source/common/uts46.cpp
icu4c/source/extra/uconv/uconv.cpp
icu4c/source/extra/uconv/uwmsg.c
icu4c/source/i18n/alphaindex.cpp
icu4c/source/i18n/coll.cpp
icu4c/source/i18n/collationbuilder.cpp
icu4c/source/i18n/collationdatabuilder.cpp
icu4c/source/i18n/collationdatareader.cpp
icu4c/source/i18n/collationruleparser.cpp
icu4c/source/i18n/compactdecimalformat.cpp
icu4c/source/i18n/dtptngen.cpp
icu4c/source/i18n/identifier_info.cpp
icu4c/source/i18n/measfmt.cpp
icu4c/source/i18n/measunit.cpp
icu4c/source/i18n/quantityformatter.cpp
icu4c/source/i18n/reldatefmt.cpp
icu4c/source/i18n/rulebasedcollator.cpp
icu4c/source/i18n/scriptset.cpp
icu4c/source/i18n/ucol_res.cpp
icu4c/source/i18n/ucoleitr.cpp
icu4c/source/i18n/usearch.cpp
icu4c/source/i18n/zonemeta.cpp
icu4c/source/samples/numfmt/main.cpp
icu4c/source/samples/uciter8/uciter8.c
icu4c/source/samples/ustring/ustring.cpp
icu4c/source/test/cintltst/bocu1tst.c
icu4c/source/test/cintltst/capitst.c
icu4c/source/test/cintltst/cbiditst.c
icu4c/source/test/cintltst/ccapitst.c
icu4c/source/test/cintltst/cg7coll.c
icu4c/source/test/cintltst/cg7coll.h
icu4c/source/test/cintltst/cgendtst.c
icu4c/source/test/cintltst/cloctst.c
icu4c/source/test/cintltst/cmsgtst.c
icu4c/source/test/cintltst/cnormtst.c
icu4c/source/test/cintltst/crestst.c
icu4c/source/test/cintltst/cstrcase.c
icu4c/source/test/cintltst/cstrtest.c
icu4c/source/test/cintltst/cucdapi.c
icu4c/source/test/cintltst/cucdtst.c
icu4c/source/test/cintltst/custrtrn.c
icu4c/source/test/cintltst/custrtst.c
icu4c/source/test/cintltst/idnatest.c
icu4c/source/test/cintltst/ncnvtst.c
icu4c/source/test/cintltst/nfsprep.c
icu4c/source/test/cintltst/nucnvtst.c
icu4c/source/test/cintltst/sorttest.c
icu4c/source/test/cintltst/spreptst.c
icu4c/source/test/cintltst/trie2test.c
icu4c/source/test/cintltst/ucnvseltst.c
icu4c/source/test/cintltst/udatatst.c
icu4c/source/test/cintltst/uregiontest.c
icu4c/source/test/cintltst/usettest.c
icu4c/source/test/cintltst/utf16tst.c
icu4c/source/test/cintltst/utf8tst.c
icu4c/source/test/cintltst/utmstest.c
icu4c/source/test/intltest/alphaindextst.cpp
icu4c/source/test/intltest/apicoll.cpp
icu4c/source/test/intltest/bytestrietest.cpp
icu4c/source/test/intltest/citrtest.cpp
icu4c/source/test/intltest/collationtest.cpp
icu4c/source/test/intltest/compactdecimalformattest.cpp
icu4c/source/test/intltest/convtest.cpp
icu4c/source/test/intltest/dcfmapts.cpp
icu4c/source/test/intltest/dtfmttst.cpp
icu4c/source/test/intltest/g7coll.cpp
icu4c/source/test/intltest/genderinfotest.cpp
icu4c/source/test/intltest/itspoof.cpp
icu4c/source/test/intltest/measfmttest.cpp
icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/plurults.cpp
icu4c/source/test/intltest/regextst.cpp
icu4c/source/test/intltest/regiontst.cpp
icu4c/source/test/intltest/reldatefmttest.cpp
icu4c/source/test/intltest/selfmts.cpp
icu4c/source/test/intltest/simplepatternformattertest.cpp
icu4c/source/test/intltest/strcase.cpp
icu4c/source/test/intltest/tfsmalls.cpp
icu4c/source/test/intltest/tmsgfmt.cpp
icu4c/source/test/intltest/tsmthred.cpp
icu4c/source/test/intltest/tstnorm.cpp
icu4c/source/test/intltest/tufmtts.cpp
icu4c/source/test/intltest/tztest.cpp
icu4c/source/test/intltest/ucdtest.cpp
icu4c/source/test/intltest/ucharstrietest.cpp
icu4c/source/test/intltest/usettest.cpp
icu4c/source/test/intltest/ustrtest.cpp
icu4c/source/test/intltest/uts46test.cpp
icu4c/source/test/perf/convperf/convperf.cpp
icu4c/source/test/perf/convperf/convperf.h
icu4c/source/test/perf/dicttrieperf/dicttrieperf.cpp
icu4c/source/test/perf/normperf/normperf.cpp
icu4c/source/test/perf/unisetperf/draft/bitset.cpp
icu4c/source/test/perf/unisetperf/unisetperf.cpp
icu4c/source/test/perf/utfperf/utfperf.cpp
icu4c/source/test/perf/utrie2perf/utrie2perf.cpp
icu4c/source/tools/gennorm2/gennorm2.cpp
icu4c/source/tools/gennorm2/n2builder.cpp
icu4c/source/tools/icupkg/icupkg.cpp
icu4c/source/tools/icuswap/icuswap.cpp
icu4c/source/tools/makeconv/gencnvex.c
icu4c/source/tools/makeconv/makeconv.c
icu4c/source/tools/toolutil/package.cpp
icu4c/source/tools/toolutil/pkg_icu.cpp
icu4c/source/tools/toolutil/pkgitems.cpp
icu4c/source/tools/toolutil/ppucd.cpp
icu4c/source/tools/toolutil/swapimpl.cpp

index f5c063b2ec79ea3c22d0a3719b04e5801f355524..ea57d5fabbe6cd6670265ff93d3c00a7779cf427 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1997-2012, International Business Machines
+*   Copyright (C) 1997-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -59,6 +59,7 @@ U_CAPI void uprv_checkValidMemory(const void *p, size_t n);
 
 #endif  /* U_DEBUG */
 
+#define uprv_lengthof(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 #define uprv_memset(buffer, mark, size) U_STANDARD_CPP_NAMESPACE memset(buffer, mark, size)
 #define uprv_memcmp(buffer1, buffer2, size) U_STANDARD_CPP_NAMESPACE memcmp(buffer1, buffer2,size)
 
index 4d824311ce94423f596f8d5c62e440a1d98b515b..c58a4f1c52854112b3577d276a278e760964609a 100644 (file)
@@ -21,8 +21,6 @@
 #include "cmemory.h"
 #include "dictionarydata.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 /*
@@ -158,7 +156,7 @@ int32_t PossibleWord::candidates( UText *text, DictionaryMatcher *dict, int32_t
     int32_t start = (int32_t)utext_getNativeIndex(text);
     if (start != offset) {
         offset = start;
-        count = dict->matches(text, rangeEnd-start, LENGTHOF(cuLengths), cuLengths, cpLengths, NULL, &prefix);
+        count = dict->matches(text, rangeEnd-start, uprv_lengthof(cuLengths), cuLengths, cpLengths, NULL, &prefix);
         // Dictionary leaves text after longest prefix, not longest word. Back up.
         if (count <= 0) {
             utext_setNativeIndex(text, start);
index bc8aef92e719ffc3e315ea9870d12300594630eb..9dc4b9fd6aefa345d51247d4518cabb5e893b64c 100644 (file)
@@ -24,8 +24,6 @@
 #include "ucln_cmn.h"
 #include "uresimp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 struct ListFormatInternal : public UMemory {
@@ -273,10 +271,10 @@ static void joinStrings(
     int32_t offsets[2];
     pat.format(
             params,
-            LENGTHOF(params),
+            uprv_lengthof(params),
             result,
             offsets,
-            LENGTHOF(offsets),
+            uprv_lengthof(offsets),
             errorCode);
     if (U_FAILURE(errorCode)) {
         return;
index c98eb6c21eba203bd6998d487bc206be60955652..f073aadedc89a11ad9c98eaedbfda39c5462d978 100644 (file)
@@ -42,8 +42,6 @@
 #include "ucln_cmn.h"
 #include "ustr_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_CDECL_BEGIN
 static UBool U_CALLCONV locale_cleanup(void);
 U_CDECL_END
index 0e01355278f64e85e74f7ade07648d3204738b96..4f320d534caf38edd9159929143a4fc92b34992f 100644 (file)
 #   define HAVE_GETTIMEOFDAY 0
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* Define the extension for data files, again... */
 #define DATA_TYPE "dat"
 
@@ -816,7 +814,7 @@ static const char* remapShortTimeZone(const char *stdID, const char *dstID, int3
 #ifdef DEBUG_TZNAME
     fprintf(stderr, "TZ=%s std=%s dst=%s daylight=%d offset=%d\n", getenv("TZ"), stdID, dstID, daylightType, offset);
 #endif
-    for (idx = 0; idx < LENGTHOF(OFFSET_ZONE_MAPPINGS); idx++)
+    for (idx = 0; idx < uprv_lengthof(OFFSET_ZONE_MAPPINGS); idx++)
     {
         if (offset == OFFSET_ZONE_MAPPINGS[idx].offsetSeconds
             && daylightType == OFFSET_ZONE_MAPPINGS[idx].daylightType
index 0113c08ed377d25afca0912c12c261736da6163b..0ca7ede39239343ce8c2be003c6ee1faf2fd8d90 100644 (file)
@@ -2,7 +2,7 @@
 //
 //  file:  rbbiscan.cpp
 //
-//  Copyright (C) 2002-2012, International Business Machines Corporation and others.
+//  Copyright (C) 2002-2014, International Business Machines Corporation and others.
 //  All Rights Reserved.
 //
 //  This file contains the Rule Based Break Iterator Rule Builder functions for
@@ -35,8 +35,6 @@
 
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 //------------------------------------------------------------------------------
 //
 // Unicode Set init strings for each of the character classes needed for parsing a rule file.
@@ -993,7 +991,7 @@ void RBBIRuleScanner::parse() {
             if (tableEl->fCharClass >= 128 && tableEl->fCharClass < 240 &&   // Table specs a char class &&
                 fC.fEscaped == FALSE &&                                      //   char is not escaped &&
                 fC.fChar != (UChar32)-1) {                                   //   char is not EOF
-                U_ASSERT((tableEl->fCharClass-128) < LENGTHOF(fRuleSets));
+                U_ASSERT((tableEl->fCharClass-128) < uprv_lengthof(fRuleSets));
                 if (fRuleSets[tableEl->fCharClass-128].contains(fC.fChar)) {
                     // Table row specified a character class, or set of characters,
                     //   and the current char matches it.
index dd478c2c187759b5e067ccd8f8b0101ef64f4b79..ed8d55aa02bcb4b5bc3ac8357e1da18d8303e68d 100644 (file)
@@ -9,8 +9,6 @@
 #include "cstring.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 typedef enum SimplePatternFormatterCompileState {
@@ -191,7 +189,7 @@ UnicodeString& SimplePatternFormatter::format(
     const UnicodeString *params[] = {&arg0};
     return format(
             params,
-            LENGTHOF(params),
+            uprv_lengthof(params),
             appendTo,
             NULL,
             0,
@@ -206,7 +204,7 @@ UnicodeString& SimplePatternFormatter::format(
     const UnicodeString *params[] = {&arg0, &arg1};
     return format(
             params,
-            LENGTHOF(params),
+            uprv_lengthof(params),
             appendTo,
             NULL,
             0,
@@ -222,7 +220,7 @@ UnicodeString& SimplePatternFormatter::format(
     const UnicodeString *params[] = {&arg0, &arg1, &arg2};
     return format(
             params,
-            LENGTHOF(params),
+            uprv_lengthof(params),
             appendTo,
             NULL,
             0,
index 9a285ccddb2c7a5a2121e6f0af3445b526f69a87..57e00afc10f8b124052cbfdbaf65ea800de39f6a 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ********************************************************************************
-*   Copyright (C) 1996-2012, International Business Machines
+*   Copyright (C) 1996-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ********************************************************************************
 *
@@ -31,8 +31,6 @@
 #include "uprops.h"
 #include "ustr_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* uchar_props_data.h is machine-generated by genprops --csource */
 #define INCLUDED_FROM_UCHAR_C
 #include "uchar_props_data.h"
index 842883574585980ba0e171be6d5a5d53c1f11443..cdde4b04e1c980756a81232c7899dd1a3609407a 100644 (file)
@@ -43,8 +43,6 @@
 #include "cmemory.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #ifdef U_ENABLE_GENERIC_ISO_2022
 /*
  * I am disabling the generic ISO-2022 converter after proposing to do so on
@@ -1719,7 +1717,7 @@ getTrail:
                 }
 
                 /* try all the other possible charsets */
-                for(i = 0; i < LENGTHOF(jpCharsetPref); ++i) {
+                for(i = 0; i < uprv_lengthof(jpCharsetPref); ++i) {
                     cs = (int8_t)jpCharsetPref[i];
                     if(CSM(cs) & csm) {
                         choices[choiceCount++] = cs;
index 7161d139a1e69b4b50341bff6611af0516dfe928..ec0e9c2bb5a90976fefa575889491224e5e6f255 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2010-2012, International Business Machines
+*   Copyright (C) 2010-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   file name:  ucnv_ct.c
@@ -28,8 +28,6 @@
 #include "cstring.h"
 #include "cmemory.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 typedef enum {
     INVALID = -2,
     DO_SEARCH = -1,
index 3df255692d43b30e55a561141c49c57ac9b2b04c..1d921dd7b37874f8a78f575c7140d114b69998e9 100644 (file)
@@ -1,6 +1,6 @@
 /*  
 **********************************************************************
-*   Copyright (C) 2000-2011, International Business Machines
+*   Copyright (C) 2000-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   file name:  ucnv_lmb.cpp
@@ -41,8 +41,6 @@
     #include "ascii_a.h"
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /*
   LMBCS
 
index 139c20bcd79b91ba7fc534b9deada406b47fc3a2..e195191655b567e5f45f2eb94371e410f5c7e3bc 100644 (file)
@@ -71,8 +71,6 @@ might have to #include some other header
 #   include <stdio.h>
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_USE
 
 /*
@@ -122,7 +120,7 @@ udata_cleanup(void)
     }
     gCommonDataCacheInitOnce.reset();
 
-    for (i = 0; i < LENGTHOF(gCommonICUDataArray) && gCommonICUDataArray[i] != NULL; ++i) {
+    for (i = 0; i < uprv_lengthof(gCommonICUDataArray) && gCommonICUDataArray[i] != NULL; ++i) {
         udata_close(gCommonICUDataArray[i]);
         gCommonICUDataArray[i] = NULL;
     }
@@ -141,7 +139,7 @@ findCommonICUDataByName(const char *inBasename)
     if (pData == NULL)
         return FALSE;
 
-    for (i = 0; i < LENGTHOF(gCommonICUDataArray); ++i) {
+    for (i = 0; i < uprv_lengthof(gCommonICUDataArray); ++i) {
         if ((gCommonICUDataArray[i] != NULL) && (gCommonICUDataArray[i]->pHeader == pData->pHeader)) {
             /* The data pointer is already in the array. */
             found = TRUE;
@@ -175,7 +173,7 @@ setCommonICUData(UDataMemory *pData,     /*  The new common data.  Belongs to ca
     /*    their locals.                                                              */
     UDatamemory_assign(newCommonData, pData);
     umtx_lock(NULL);
-    for (i = 0; i < LENGTHOF(gCommonICUDataArray); ++i) {
+    for (i = 0; i < uprv_lengthof(gCommonICUDataArray); ++i) {
         if (gCommonICUDataArray[i] == NULL) {
             gCommonICUDataArray[i] = newCommonData;
             didUpdate = TRUE;
@@ -187,7 +185,7 @@ setCommonICUData(UDataMemory *pData,     /*  The new common data.  Belongs to ca
     }
     umtx_unlock(NULL);
 
-    if (i == LENGTHOF(gCommonICUDataArray) && warn) {
+    if (i == uprv_lengthof(gCommonICUDataArray) && warn) {
         *pErr = U_USING_DEFAULT_WARNING;
     }
     if (didUpdate) {
@@ -662,7 +660,7 @@ openCommonData(const char *path,          /*  Path from OpenChoice?          */
     /* ??????? TODO revisit this */ 
     if (commonDataIndex >= 0) {
         /* "mini-cache" for common ICU data */
-        if(commonDataIndex >= LENGTHOF(gCommonICUDataArray)) {
+        if(commonDataIndex >= uprv_lengthof(gCommonICUDataArray)) {
             return NULL;
         }
         if(gCommonICUDataArray[commonDataIndex] == NULL) {
index ff268bf64ff8c2951d41124777113eb2094a7dc8..27b9329a660bfc30d7be950efbbf850c8d02f47d 100644 (file)
@@ -17,8 +17,6 @@
 #include "ulocimp.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* struct holding a single variant */
 typedef struct VariantListEntry {
     const char              *variant;
@@ -1060,7 +1058,7 @@ _appendLanguageToLanguageTag(const char* localeID, char* appendAt, int32_t capac
         reslen += LANG_UND_LEN;
     } else {
         /* resolve deprecated */
-        for (i = 0; i < LENGTHOF(DEPRECATEDLANGS); i += 2) {
+        for (i = 0; i < uprv_lengthof(DEPRECATEDLANGS); i += 2) {
             if (uprv_compareInvCharsAsAscii(buf, DEPRECATEDLANGS[i]) == 0) {
                 uprv_strcpy(buf, DEPRECATEDLANGS[i + 1]);
                 len = (int32_t)uprv_strlen(buf);
index c8f596931c0f79d6f90243259ed3e0f947025fe7..57ca87e6b56f0a201b731f28bacf8bb9207bfb88 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1999-2013, International Business Machines
+*   Copyright (C) 1999-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -33,8 +33,6 @@ U_NAMESPACE_BEGIN
 
 /* prototypes ------------------------------------------------------------- */
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static const char DATA_NAME[] = "unames";
 static const char DATA_TYPE[] = "icu";
 
@@ -438,7 +436,7 @@ static const char *getCharCatName(UChar32 cp) {
     /* Return unknown if the table of names above is not up to
        date. */
 
-    if (cat >= LENGTHOF(charCatNames)) {
+    if (cat >= uprv_lengthof(charCatNames)) {
         return "unknown";
     } else {
         return charCatNames[cat];
@@ -1277,7 +1275,7 @@ static int32_t
 calcExtNameSetsLengths(int32_t maxNameLength) {
     int32_t i, length;
 
-    for(i=0; i<LENGTHOF(charCatNames); ++i) {
+    for(i=0; i<uprv_lengthof(charCatNames); ++i) {
         /*
          * for each category, count the length of the category name
          * plus 9=
@@ -1584,7 +1582,7 @@ u_charFromName(UCharNameChoice nameChoice,
                        We could use a binary search, or a trie, if
                        we really wanted to. */
 
-                    for (lower[i] = 0, cIdx = 0; cIdx < LENGTHOF(charCatNames); ++cIdx) {
+                    for (lower[i] = 0, cIdx = 0; cIdx < uprv_lengthof(charCatNames); ++cIdx) {
 
                         if (!uprv_strcmp(lower + 1, charCatNames[cIdx])) {
                             if (getCharCat(cp) == cIdx) {
index 1296d089eaafdb983aeadcffbd9dcb68345087ff..d33889395cc8028013819974037b0dd010bdb403 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1999-2013, International Business Machines
+*   Copyright (C) 1999-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -47,8 +47,6 @@
 
 U_NAMESPACE_USE
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // initial storage. Must be >= 0
 // *** same as in uniset.cpp ! ***
 #define START_EXTRA 16
index 9ca56bfae47a1c76944b32b92053abb664103cb8..f0a026f66961242815dc3cac9bde2e08a8a631ec 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ******************************************************************************
-* Copyright (c) 1996-2011, International Business Machines
+* Copyright (c) 1996-2014, International Business Machines
 * Corporation and others. All Rights Reserved.
 ******************************************************************************
 * File unorm.cpp
@@ -37,8 +37,6 @@
 #include "uprops.h"
 #include "ustr_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_USE
 
 /* quick check functions ---------------------------------------------------- */
index 521e355883a04684117c4bc9010aac58d58b977f..d4854f6f171df731bcf9226edf07dbb73a13e9b1 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2001-2011, International Business Machines
+*   Copyright (C) 2001-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -32,8 +32,6 @@
 
 U_NAMESPACE_USE
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* compare canonically equivalent ------------------------------------------- */
 
 /*
index 9743942c5026906f6a0df7ba7bf73901280d13e6..0055341901342a1670ae6337c894674d8b809cce 100644 (file)
@@ -34,8 +34,6 @@
 #include "ucase.h"
 #include "ustr_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_USE
 
 #define GET_BIDI_PROPS() ubidi_getSingleton()
@@ -135,7 +133,7 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP
         /* guess some large but stack-friendly capacity */
         UChar dest[2*UCASE_MAX_STRING_LENGTH];
         int32_t destLength;
-        destLength=u_strFoldCase(dest, LENGTHOF(dest),
+        destLength=u_strFoldCase(dest, uprv_lengthof(dest),
                                   nfd.getBuffer(), nfd.length(),
                                   U_FOLD_CASE_DEFAULT, &errorCode);
         return (UBool)(U_SUCCESS(errorCode) &&
@@ -381,7 +379,7 @@ static const UHangulSyllableType gcbToHst[]={
 static int32_t getHangulSyllableType(const IntProperty &/*prop*/, UChar32 c, UProperty /*which*/) {
     /* see comments on gcbToHst[] above */
     int32_t gcb=(int32_t)(u_getUnicodeProperties(c, 2)&UPROPS_GCB_MASK)>>UPROPS_GCB_SHIFT;
-    if(gcb<LENGTHOF(gcbToHst)) {
+    if(gcb<uprv_lengthof(gcbToHst)) {
         return gcbToHst[gcb];
     } else {
         return U_HST_NOT_APPLICABLE;
index dabde52b87eb324d566247e02c328d775d923f43..bc37c240043783c0480c77b95c873ca07a6248fc 100644 (file)
@@ -31,8 +31,6 @@
 #include "uresimp.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /*
  * Resource access helpers
  */
@@ -749,7 +747,7 @@ ures_swapResource(const UDataSwapper *ds,
             (key!=gUnknownKey ?
                 /* its table key string is "%%CollationBin" */
                 0==ds->compareInvChars(ds, key, -1,
-                                       gCollationBinKey, LENGTHOF(gCollationBinKey)-1) :
+                                       gCollationBinKey, uprv_lengthof(gCollationBinKey)-1) :
                 /* its table key string is unknown but it looks like a collation binary */
                 ucol_looksLikeCollationBinary(ds, p+1, count))
         ) {
index 4631e6a6f5879bfb230cc8232129226bda83ee32..2d3c98110e8aa805a2615f87b41b7d636529edfb 100644 (file)
@@ -17,8 +17,7 @@
 #include "unicode/uscript.h"
 #include "unicode/utf16.h"
 #include "ustr_imp.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 namespace {
 
@@ -214,7 +213,7 @@ const int32_t SCRIPT_PROPS[] = {
 };
 
 int32_t getScriptProps(UScriptCode script) {
-    if (0 <= script && script < LENGTHOF(SCRIPT_PROPS)) {
+    if (0 <= script && script < uprv_lengthof(SCRIPT_PROPS)) {
         return SCRIPT_PROPS[script];
     } else {
         return 0;
index 1799b63e6d8d6b76aa75dbd9fc1529a8071b1332..8ec310cac075f988476cdda445e0897f2ec28a9e 100644 (file)
@@ -26,8 +26,6 @@
 #include "ubidi_props.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /*
  * This implementation is designed for 16-bit Unicode strings.
  * The main assumption is that the Arabic characters and their
@@ -1560,8 +1558,8 @@ u_shapeArabic(const UChar *source, int32_t sourceLength,
         }
 
         /* Start of Arabic letter shaping part */
-        if(outputSize<=LENGTHOF(buffer)) {
-            outputSize=LENGTHOF(buffer);
+        if(outputSize<=uprv_lengthof(buffer)) {
+            outputSize=uprv_lengthof(buffer);
             tempbuffer=buffer;
         } else {
             tempbuffer = (UChar *)uprv_malloc(outputSize*U_SIZEOF_UCHAR);
index fce05c8e69d47b0cbc25b4ca9dbbfede0ff1591d..b5b9b8274c2f3bca6b28f275da4386e572aefcd4 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2001-2011, International Business Machines
+*   Copyright (C) 2001-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -29,8 +29,6 @@
 #include "ucase.h"
 #include "ustr_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_USE
 
 /* string casing ------------------------------------------------------------ */
@@ -399,7 +397,7 @@ ustrcase_map(const UCaseMap *csm,
          (dest>=src && dest<(src+srcLength)))
     ) {
         /* overlap: provide a temporary destination buffer and later copy the result */
-        if(destCapacity<=LENGTHOF(buffer)) {
+        if(destCapacity<=uprv_lengthof(buffer)) {
             /* the stack buffer is large enough */
             temp=buffer;
         } else {
index fbb7b46f309517d4c12c8cb4fb83ce7bc1adda33..a51fb56019b5346a23086ecf17f23314399c6ef6 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 2001-2013, International Business Machines
+*   Copyright (C) 2001-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -34,8 +34,6 @@
 #include "ustr_imp.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_CAPI UChar* U_EXPORT2 
 u_strFromUTF32WithSub(UChar *dest,
                int32_t destCapacity,
@@ -383,7 +381,7 @@ utf8_nextCharSafeBodyPointer(const uint8_t **ps, const uint8_t *limit, UChar32 c
 
     /* correct sequence - all trail bytes have (b7..b6)==(10)? */
     /* illegal is also set if count>=4 */
-    U_ASSERT(illegal || count<LENGTHOF(utf8_minLegal));
+    U_ASSERT(illegal || count<uprv_lengthof(utf8_minLegal));
     if(illegal || c<utf8_minLegal[count] || U_IS_SURROGATE(c)) {
         /* error handling */
         /* don't go beyond this sequence */
index f195453d11e84f16579d76d4f1805c35455fe0a9..41e862d4e4d2ada73a39f494e7e8e6a417303223 100644 (file)
@@ -33,8 +33,6 @@
 
 #include "utrie.h" /* for utrie2_fromUTrie() and utrie_swap() */
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* Implementation notes ----------------------------------------------------- */
 
 /*
@@ -476,7 +474,7 @@ allocIndex2Block(UNewTrie2 *trie) {
 
     newBlock=trie->index2Length;
     newTop=newBlock+UTRIE2_INDEX_2_BLOCK_LENGTH;
-    if(newTop>LENGTHOF(trie->index2)) {
+    if(newTop>uprv_lengthof(trie->index2)) {
         /*
          * Should never occur.
          * Either UTRIE2_MAX_BUILD_TIME_INDEX_LENGTH is incorrect,
index 0a9cc193eb0cecd8d4d4e90397aba9b69c40bfe0..ac9f5b71ce7a37eaac32258bc24c442219986315 100644 (file)
@@ -27,8 +27,6 @@
 #include "ubidi_props.h"
 #include "ustr_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // Note about tests for UIDNA_ERROR_DOMAIN_NAME_TOO_LONG:
 //
 // The domain name length limit is 255 octets in an internal DNS representation
@@ -435,7 +433,7 @@ UTS46::processUTF8(const StringPiece &src,
         char stackArray[256];
         int32_t destCapacity;
         char *destArray=dest.GetAppendBuffer(srcLength, srcLength+20,
-                                             stackArray, LENGTHOF(stackArray), &destCapacity);
+                                             stackArray, uprv_lengthof(stackArray), &destCapacity);
         UBool disallowNonLDHDot=(options&UIDNA_USE_STD3_RULES)!=0;
         int32_t i;
         for(i=0;; ++i) {
index f68b443c6df198f279a037c5ed9fe5b08694e045..258a1bca425657d347092b7ef04b805710116dda 100644 (file)
@@ -66,8 +66,6 @@ U_NAMESPACE_USE
 U_CFUNC char uconvmsg_dat[];
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define DEFAULT_BUFSZ   4096
 #define UCONVMSG "uconvmsg"
 
@@ -946,7 +944,7 @@ ConvertFile::convertFile(const char *pname,
                     int8_t i, length, errorLength;
 
                     UErrorCode localError = U_ZERO_ERROR;
-                    errorLength = (int8_t)LENGTHOF(errorUChars);
+                    errorLength = (int8_t)uprv_lengthof(errorUChars);
                     ucnv_getInvalidUChars(convto, errorUChars, &errorLength, &localError);
                     if (U_FAILURE(localError) || errorLength == 0) {
                         // need at least 1 so that we don't access beyond the length of fromoffsets[]
index 67c12885953deb18b983531ed312e1fae2ebeb4e..dcd9c1e7f625927433eae9d76c63ab192e402cac 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (C) 1998-2012, International Business Machines Corporation
+* Copyright (C) 1998-2014, International Business Machines Corporation
 * and others.  All Rights Reserved.
 **********************************************************************
 *
@@ -26,8 +26,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 #define BUF_SIZE 128
 
 /* Print a ustring to the specified FILE* in the default codepage */
@@ -127,7 +125,7 @@ U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... )
     va_list ap;
 #endif
     UChar   result[4096];
-    int32_t resultLength = LENGTHOF(result);
+    int32_t resultLength = uprv_lengthof(result);
 
     if(gBundle == NULL)
     {
@@ -146,7 +144,7 @@ U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... )
 
 #if UCONFIG_NO_FORMATTING
     resultLength = sizeof(gNoFormatting) / U_SIZEOF_UCHAR;
-    if((msgLen + resultLength) <= LENGTHOF(result)) {
+    if((msgLen + resultLength) <= uprv_lengthof(result)) {
         memcpy(result, msg, msgLen * U_SIZEOF_UCHAR);
         memcpy(result + msgLen, gNoFormatting, resultLength);
         resultLength += msgLen;
index e304faa0e4f51cfc43ee6b40803e57c5ea674302..0bea1dc22fbf8cd6fa9d8620bc985e14e3e31b80 100644 (file)
@@ -30,8 +30,6 @@
 //#include <string>
 //#include <iostream>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 namespace {
index b71bc962ef900969f6b9af3d49e09fe9f0d9141d..f61ea40f37041c87bfa5374897f10bb0940d0f17 100644 (file)
@@ -59,8 +59,6 @@
 #include "uresimp.h"
 #include "ucln_in.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static icu::Locale* availableLocaleList = NULL;
 static int32_t  availableLocaleListCount;
 static icu::ICULocaleService* gService = NULL;
@@ -296,7 +294,7 @@ static const char *collReorderCodes[UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_
 };
 
 int32_t getReorderCode(const char *s) {
-    for (int32_t i = 0; i < LENGTHOF(collReorderCodes); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(collReorderCodes); ++i) {
         if (uprv_stricmp(s, collReorderCodes[i]) == 0) {
             return UCOL_REORDER_CODE_FIRST + i;
         }
@@ -326,7 +324,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
     char value[1024];  // The reordering value could be long.
     // Check for collation keywords that were already deprecated
     // before any were supported in createInstance() (except for "collation").
-    int32_t length = loc.getKeywordValue("colHiraganaQuaternary", value, LENGTHOF(value), errorCode);
+    int32_t length = loc.getKeywordValue("colHiraganaQuaternary", value, uprv_lengthof(value), errorCode);
     if (U_FAILURE(errorCode)) {
         errorCode = U_ILLEGAL_ARGUMENT_ERROR;
         return;
@@ -335,7 +333,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
         errorCode = U_UNSUPPORTED_ERROR;
         return;
     }
-    length = loc.getKeywordValue("variableTop", value, LENGTHOF(value), errorCode);
+    length = loc.getKeywordValue("variableTop", value, uprv_lengthof(value), errorCode);
     if (U_FAILURE(errorCode)) {
         errorCode = U_ILLEGAL_ARGUMENT_ERROR;
         return;
@@ -348,15 +346,15 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
     if (errorCode == U_STRING_NOT_TERMINATED_WARNING) {
         errorCode = U_ZERO_ERROR;
     }
-    for (int32_t i = 0; i < LENGTHOF(collAttributes); ++i) {
-        length = loc.getKeywordValue(collAttributes[i].name, value, LENGTHOF(value), errorCode);
+    for (int32_t i = 0; i < uprv_lengthof(collAttributes); ++i) {
+        length = loc.getKeywordValue(collAttributes[i].name, value, uprv_lengthof(value), errorCode);
         if (U_FAILURE(errorCode) || errorCode == U_STRING_NOT_TERMINATED_WARNING) {
             errorCode = U_ILLEGAL_ARGUMENT_ERROR;
             return;
         }
         if (length == 0) { continue; }
         for (int32_t j = 0;; ++j) {
-            if (j == LENGTHOF(collAttributeValues)) {
+            if (j == uprv_lengthof(collAttributeValues)) {
                 errorCode = U_ILLEGAL_ARGUMENT_ERROR;
                 return;
             }
@@ -366,7 +364,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
             }
         }
     }
-    length = loc.getKeywordValue("colReorder", value, LENGTHOF(value), errorCode);
+    length = loc.getKeywordValue("colReorder", value, uprv_lengthof(value), errorCode);
     if (U_FAILURE(errorCode) || errorCode == U_STRING_NOT_TERMINATED_WARNING) {
         errorCode = U_ILLEGAL_ARGUMENT_ERROR;
         return;
@@ -376,7 +374,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
         int32_t codesLength = 0;
         char *scriptName = value;
         for (;;) {
-            if (codesLength == LENGTHOF(codes)) {
+            if (codesLength == uprv_lengthof(codes)) {
                 errorCode = U_ILLEGAL_ARGUMENT_ERROR;
                 return;
             }
@@ -401,7 +399,7 @@ void setAttributesFromKeywords(const Locale &loc, Collator &coll, UErrorCode &er
         }
         coll.setReorderCodes(codes, codesLength, errorCode);
     }
-    length = loc.getKeywordValue("kv", value, LENGTHOF(value), errorCode);
+    length = loc.getKeywordValue("kv", value, uprv_lengthof(value), errorCode);
     if (U_FAILURE(errorCode) || errorCode == U_STRING_NOT_TERMINATED_WARNING) {
         errorCode = U_ILLEGAL_ARGUMENT_ERROR;
         return;
index 197496da73573c3fc4029360cb81d5f9052d809e..b2d838dc1a1e3bf186c9edce1e2551ba4c0c04b7 100644 (file)
@@ -46,8 +46,6 @@
 #include "ucol_imp.h"
 #include "utf16collationiterator.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 namespace {
@@ -276,7 +274,7 @@ CollationBuilder::parseAndBuild(const UnicodeString &ruleString,
     if(U_FAILURE(errorCode)) { return NULL; }
     ownedSettings.fastLatinOptions = CollationFastLatin::getOptions(
         tailoring->data, ownedSettings,
-        ownedSettings.fastLatinPrimaries, LENGTHOF(ownedSettings.fastLatinPrimaries));
+        ownedSettings.fastLatinPrimaries, uprv_lengthof(ownedSettings.fastLatinPrimaries));
     tailoring->rules = ruleString;
     tailoring->rules.getTerminatedBuffer();  // ensure NUL-termination
     tailoring->setVersion(base->version, rulesVersion);
index 7b97650101676df28ac9a4c5dbeae464a8e8c7c5..b7d82135d1b987f345b7851626021a63562e26d1 100644 (file)
@@ -35,8 +35,6 @@
 #include "uvectr64.h"
 #include "uvector.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 CollationDataBuilder::CEModifier::~CEModifier() {}
index e0d8cb93d00d0a3d39a3b563da83def4ca4974f8..905f3327cf9e8474b6d4af81743faacd1368eb26 100644 (file)
@@ -30,8 +30,6 @@
 #include "ucmndata.h"
 #include "utrie2.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 namespace {
@@ -370,7 +368,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
     int32_t options = inIndexes[IX_OPTIONS] & 0xffff;
     uint16_t fastLatinPrimaries[CollationFastLatin::LATIN_LIMIT];
     int32_t fastLatinOptions = CollationFastLatin::getOptions(
-            tailoring.data, ts, fastLatinPrimaries, LENGTHOF(fastLatinPrimaries));
+            tailoring.data, ts, fastLatinPrimaries, uprv_lengthof(fastLatinPrimaries));
     if(options == ts.options && ts.variableTop != 0 &&
             reorderCodesLength == ts.reorderCodesLength &&
             uprv_memcmp(reorderCodes, ts.reorderCodes, reorderCodesLength * 4) == 0 &&
@@ -409,7 +407,7 @@ CollationDataReader::read(const CollationTailoring *base, const uint8_t *inBytes
 
     settings->fastLatinOptions = CollationFastLatin::getOptions(
         tailoring.data, *settings,
-        settings->fastLatinPrimaries, LENGTHOF(settings->fastLatinPrimaries));
+        settings->fastLatinPrimaries, uprv_lengthof(settings->fastLatinPrimaries));
 }
 
 UBool U_CALLCONV
index 500cf4d7a1fd915be491586de6ab6ac389f4ce1d..f090b1070124c5a0e2ba80cd4a1b5ed3a5229b5a 100644 (file)
@@ -34,8 +34,6 @@
 #include "uassert.h"
 #include "uvectr32.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 namespace {
@@ -463,7 +461,7 @@ CollationRuleParser::parseSpecialPosition(int32_t i, UnicodeString &str, UErrorC
     int32_t j = readWords(i + 1, raw);
     if(j > i && rules->charAt(j) == 0x5d && !raw.isEmpty()) {  // words end with ]
         ++j;
-        for(int32_t pos = 0; pos < LENGTHOF(positions); ++pos) {
+        for(int32_t pos = 0; pos < uprv_lengthof(positions); ++pos) {
             if(raw == UnicodeString(positions[pos], -1, US_INV)) {
                 str.setTo((UChar)POS_LEAD).append((UChar)(POS_BASE + pos));
                 return j;
@@ -727,7 +725,7 @@ static const char *const gSpecialReorderCodes[] = {
 
 int32_t
 CollationRuleParser::getReorderCode(const char *word) {
-    for(int32_t i = 0; i < LENGTHOF(gSpecialReorderCodes); ++i) {
+    for(int32_t i = 0; i < uprv_lengthof(gSpecialReorderCodes); ++i) {
         if(uprv_stricmp(word, gSpecialReorderCodes[i]) == 0) {
             return UCOL_REORDER_CODE_FIRST + i;
         }
index 0e3c45f0b7e26f00bae4156f6e2536889d5ca90e..6bdfca1245b741f8aca276da7299d3b39a3e59d1 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 1997-2012, International Business Machines Corporation and    *
+* Copyright (C) 1997-2014, International Business Machines Corporation and    *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 *
@@ -26,8 +26,6 @@
 #include "unicode/ures.h"
 #include "uresimp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 // Maps locale name to CDFLocaleData struct.
 static UHashtable* gCompactDecimalData = NULL;
 static UMutex gCompactDecimalMetaLock = U_MUTEX_INITIALIZER;
@@ -768,13 +766,13 @@ static int32_t populatePrefixSuffix(
   if (U_FAILURE(status)) {
     return 0;
   }
-  int32_t firstIdx = formatStr.indexOf(kZero, LENGTHOF(kZero), 0);
+  int32_t firstIdx = formatStr.indexOf(kZero, uprv_lengthof(kZero), 0);
   // We must have 0's in format string.
   if (firstIdx == -1) {
     status = U_INTERNAL_PROGRAM_ERROR;
     return 0;
   }
-  int32_t lastIdx = formatStr.lastIndexOf(kZero, LENGTHOF(kZero), firstIdx);
+  int32_t lastIdx = formatStr.lastIndexOf(kZero, uprv_lengthof(kZero), firstIdx);
   CDFUnit* unit = createCDFUnit(variant, log10Value, result, status);
   if (U_FAILURE(status)) {
     return 0;
index 0eb1eee25d417d0fbc1e778af1ffd66c2ad62244..679cee89e3ccc3d40cf4abd4888dc56aeeb3529e 100644 (file)
@@ -35,8 +35,6 @@
 #include "uresimp.h"
 #include "dtptngen_impl.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #if U_CHARSET_FAMILY==U_EBCDIC_FAMILY
 /**
  * If we are on EBCDIC, use an iterator which will
@@ -510,7 +508,7 @@ DateTimePatternGenerator::addCLDRData(const Locale& locale, UErrorCode& err) {
     const char *key=NULL;
     int32_t i;
 
-    UnicodeString defaultItemFormat(TRUE, UDATPG_ItemFormat, LENGTHOF(UDATPG_ItemFormat)-1);  // Read-only alias.
+    UnicodeString defaultItemFormat(TRUE, UDATPG_ItemFormat, uprv_lengthof(UDATPG_ItemFormat)-1);  // Read-only alias.
 
     err = U_ZERO_ERROR;
     
index 87ddda1a793262736fb84670f1ff9a4e9533aa25..a420213cc1d13e22d0d9ffa7ca65547c33915061 100644 (file)
@@ -18,8 +18,6 @@
 
 U_NAMESPACE_BEGIN
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static UnicodeSet *ASCII;
 static ScriptSet *JAPANESE;
 static ScriptSet *CHINESE;
@@ -137,7 +135,7 @@ IdentifierInfo &IdentifierInfo::setIdentifier(const UnicodeString &identifier, U
             fNumerics->add(cp - (UChar32)u_getNumericValue(cp));
         }
         UScriptCode extensions[500];
-        int32_t extensionsCount = uscript_getScriptExtensions(cp, extensions, LENGTHOF(extensions), &status);
+        int32_t extensionsCount = uscript_getScriptExtensions(cp, extensions, uprv_lengthof(extensions), &status);
         if (U_FAILURE(status)) {
             return *this;
         }
index 82d76e79964781b11cb1f348ab18770ca089a1cd..f364dd100f0afbe5686a35a12b2b70963fcc6064 100644 (file)
@@ -35,7 +35,6 @@
 #include "sharedpluralrules.h"
 #include "unifiedcache.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 #define MEAS_UNIT_COUNT 46
 #define WIDTH_INDEX_COUNT (UMEASFMT_WIDTH_NARROW + 1)
 
@@ -112,7 +111,7 @@ private:
 };
 
 MeasureFormatCacheData::MeasureFormatCacheData() {
-    for (int32_t i = 0; i < LENGTHOF(currencyFormats); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(currencyFormats); ++i) {
         currencyFormats[i] = NULL;
     }
     integerFormat = NULL;
@@ -120,7 +119,7 @@ MeasureFormatCacheData::MeasureFormatCacheData() {
 }
 
 MeasureFormatCacheData::~MeasureFormatCacheData() {
-    for (int32_t i = 0; i < LENGTHOF(currencyFormats); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(currencyFormats); ++i) {
         delete currencyFormats[i];
     }
     delete integerFormat;
index 7916889d0406de8f8d4c440ab99d09955bfa6d17..b2a3e3fd1414dc4f0cf8efafd673338f304e7951 100644 (file)
@@ -19,8 +19,6 @@
 #include "cstring.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureUnit)
@@ -641,20 +639,20 @@ int32_t MeasureUnit::getAvailable(
     if (U_FAILURE(errorCode)) {
         return 0;
     }
-    if (destCapacity < LENGTHOF(gSubTypes)) {
+    if (destCapacity < uprv_lengthof(gSubTypes)) {
         errorCode = U_BUFFER_OVERFLOW_ERROR;
-        return LENGTHOF(gSubTypes);
+        return uprv_lengthof(gSubTypes);
     }
     int32_t idx = 0;
-    for (int32_t typeIdx = 0; typeIdx < LENGTHOF(gTypes); ++typeIdx) {
+    for (int32_t typeIdx = 0; typeIdx < uprv_lengthof(gTypes); ++typeIdx) {
         int32_t len = gOffsets[typeIdx + 1] - gOffsets[typeIdx];
         for (int32_t subTypeIdx = 0; subTypeIdx < len; ++subTypeIdx) {
             dest[idx].setTo(typeIdx, subTypeIdx);
             ++idx;
         }
     }
-    U_ASSERT(idx == LENGTHOF(gSubTypes));
-    return LENGTHOF(gSubTypes);
+    U_ASSERT(idx == uprv_lengthof(gSubTypes));
+    return uprv_lengthof(gSubTypes);
 }
 
 int32_t MeasureUnit::getAvailable(
@@ -665,7 +663,7 @@ int32_t MeasureUnit::getAvailable(
     if (U_FAILURE(errorCode)) {
         return 0;
     }
-    int32_t typeIdx = binarySearch(gTypes, 0, LENGTHOF(gTypes), type);
+    int32_t typeIdx = binarySearch(gTypes, 0, uprv_lengthof(gTypes), type);
     if (typeIdx == -1) {
         return 0;
     }
@@ -682,7 +680,7 @@ int32_t MeasureUnit::getAvailable(
 
 StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
     UEnumeration *uenum = uenum_openCharStringsEnumeration(
-            gTypes, LENGTHOF(gTypes), &errorCode);
+            gTypes, uprv_lengthof(gTypes), &errorCode);
     if (U_FAILURE(errorCode)) {
         uenum_close(uenum);
         return NULL;
@@ -697,7 +695,7 @@ StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
 }
 
 int32_t MeasureUnit::getIndexCount() {
-    return gIndexes[LENGTHOF(gIndexes) - 1];
+    return gIndexes[uprv_lengthof(gIndexes) - 1];
 }
 
 MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
@@ -712,7 +710,7 @@ MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status)
 }
 
 void MeasureUnit::initTime(const char *timeId) {
-    int32_t result = binarySearch(gTypes, 0, LENGTHOF(gTypes), "duration");
+    int32_t result = binarySearch(gTypes, 0, uprv_lengthof(gTypes), "duration");
     U_ASSERT(result != -1);
     fTypeId = result;
     result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], timeId);
@@ -721,7 +719,7 @@ void MeasureUnit::initTime(const char *timeId) {
 }
 
 void MeasureUnit::initCurrency(const char *isoCurrency) {
-    int32_t result = binarySearch(gTypes, 0, LENGTHOF(gTypes), "currency");
+    int32_t result = binarySearch(gTypes, 0, uprv_lengthof(gTypes), "currency");
     U_ASSERT(result != -1);
     fTypeId = result;
     result = binarySearch(
@@ -729,7 +727,7 @@ void MeasureUnit::initCurrency(const char *isoCurrency) {
     if (result != -1) {
         fSubTypeId = result - gOffsets[fTypeId];
     } else {
-        uprv_strncpy(fCurrency, isoCurrency, LENGTHOF(fCurrency));
+        uprv_strncpy(fCurrency, isoCurrency, uprv_lengthof(fCurrency));
     }
 }
 
index 4138aee030b5e2e3a578a6c8e4cb61e698d5444d..ae3cf5887ae38fff5285380f61d795dfc4463a17 100644 (file)
@@ -17,8 +17,6 @@
 #include "unicode/fmtable.h"
 #include "unicode/fieldpos.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 #if !UCONFIG_NO_FORMATTING
 
 U_NAMESPACE_BEGIN
@@ -28,7 +26,7 @@ static const char * const gPluralForms[] = {
         "other", "zero", "one", "two", "few", "many"};
 
 static int32_t getPluralIndex(const char *pluralForm) {
-    int32_t len = LENGTHOF(gPluralForms);
+    int32_t len = uprv_lengthof(gPluralForms);
     for (int32_t i = 0; i < len; ++i) {
         if (uprv_strcmp(pluralForm, gPluralForms[i]) == 0) {
             return i;
@@ -38,13 +36,13 @@ static int32_t getPluralIndex(const char *pluralForm) {
 }
 
 QuantityFormatter::QuantityFormatter() {
-    for (int32_t i = 0; i < LENGTHOF(formatters); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(formatters); ++i) {
         formatters[i] = NULL;
     }
 }
 
 QuantityFormatter::QuantityFormatter(const QuantityFormatter &other) {
-    for (int32_t i = 0; i < LENGTHOF(formatters); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(formatters); ++i) {
         if (other.formatters[i] == NULL) {
             formatters[i] = NULL;
         } else {
@@ -58,7 +56,7 @@ QuantityFormatter &QuantityFormatter::operator=(
     if (this == &other) {
         return *this;
     }
-    for (int32_t i = 0; i < LENGTHOF(formatters); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(formatters); ++i) {
         delete formatters[i];
         if (other.formatters[i] == NULL) {
             formatters[i] = NULL;
@@ -70,13 +68,13 @@ QuantityFormatter &QuantityFormatter::operator=(
 }
 
 QuantityFormatter::~QuantityFormatter() {
-    for (int32_t i = 0; i < LENGTHOF(formatters); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(formatters); ++i) {
         delete formatters[i];
     }
 }
 
 void QuantityFormatter::reset() {
-    for (int32_t i = 0; i < LENGTHOF(formatters); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(formatters); ++i) {
         delete formatters[i];
         formatters[i] = NULL;
     }
@@ -166,7 +164,7 @@ UnicodeString &QuantityFormatter::format(
     fmt.format(quantity, formattedNumber, fpos, status);
     const UnicodeString *params[1] = {&formattedNumber};
     int32_t offsets[1];
-    pattern->format(params, LENGTHOF(params), appendTo, offsets, LENGTHOF(offsets), status);
+    pattern->format(params, uprv_lengthof(params), appendTo, offsets, uprv_lengthof(offsets), status);
     if (offsets[0] != -1) {
         if (fpos.getBeginIndex() != 0 || fpos.getEndIndex() != 0) {
             pos.setBeginIndex(fpos.getBeginIndex() + offsets[0]);
index 369a6727eccb7aea9662743f2b01a8f57d4d853e..2a1941a85961a5199abc253c9223cece2c71eed7 100644 (file)
@@ -33,7 +33,6 @@
 #include "unifiedcache.h"
 
 // Copied from uscript_props.cpp
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 static UMutex gBrkIterMutex = U_MUTEX_INITIALIZER;
 
index ca86453644e6fd0932740bb26c8c4b16fb3b3291..5b2185415cc21f2dda847dede91c938f66c2d9a0 100644 (file)
@@ -53,8 +53,6 @@
 #include "utf8collationiterator.h"
 #include "uvectr64.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 namespace {
@@ -705,7 +703,7 @@ void
 RuleBasedCollator::setFastLatinOptions(CollationSettings &ownedSettings) const {
     ownedSettings.fastLatinOptions = CollationFastLatin::getOptions(
             data, ownedSettings,
-            ownedSettings.fastLatinPrimaries, LENGTHOF(ownedSettings.fastLatinPrimaries));
+            ownedSettings.fastLatinPrimaries, uprv_lengthof(ownedSettings.fastLatinPrimaries));
 }
 
 UCollationResult
@@ -1594,21 +1592,21 @@ RuleBasedCollator::internalGetShortDefinitionString(const char *locale,
         appendAttribute(result, 'F', getAttribute(UCOL_FRENCH_COLLATION, errorCode), errorCode);
     }
     // Note: UCOL_HIRAGANA_QUATERNARY_MODE is deprecated and never changes away from default.
-    length = uloc_getKeywordValue(resultLocale, "collation", subtag, LENGTHOF(subtag), &errorCode);
+    length = uloc_getKeywordValue(resultLocale, "collation", subtag, uprv_lengthof(subtag), &errorCode);
     appendSubtag(result, 'K', subtag, length, errorCode);
-    length = uloc_getLanguage(resultLocale, subtag, LENGTHOF(subtag), &errorCode);
+    length = uloc_getLanguage(resultLocale, subtag, uprv_lengthof(subtag), &errorCode);
     appendSubtag(result, 'L', subtag, length, errorCode);
     if(attributeHasBeenSetExplicitly(UCOL_NORMALIZATION_MODE)) {
         appendAttribute(result, 'N', getAttribute(UCOL_NORMALIZATION_MODE, errorCode), errorCode);
     }
-    length = uloc_getCountry(resultLocale, subtag, LENGTHOF(subtag), &errorCode);
+    length = uloc_getCountry(resultLocale, subtag, uprv_lengthof(subtag), &errorCode);
     appendSubtag(result, 'R', subtag, length, errorCode);
     if(attributeHasBeenSetExplicitly(UCOL_STRENGTH)) {
         appendAttribute(result, 'S', getAttribute(UCOL_STRENGTH, errorCode), errorCode);
     }
-    length = uloc_getVariant(resultLocale, subtag, LENGTHOF(subtag), &errorCode);
+    length = uloc_getVariant(resultLocale, subtag, uprv_lengthof(subtag), &errorCode);
     appendSubtag(result, 'V', subtag, length, errorCode);
-    length = uloc_getScript(resultLocale, subtag, LENGTHOF(subtag), &errorCode);
+    length = uloc_getScript(resultLocale, subtag, uprv_lengthof(subtag), &errorCode);
     appendSubtag(result, 'Z', subtag, length, errorCode);
 
     if(U_FAILURE(errorCode)) { return 0; }
index 5f635d030658a4c072cf59df1f516e2900a44bba..753518ff2cc52ddd53ae8ac57a6376445a78a172 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;
index 2bd5a0152f92eff3614bb494e17bcd5e5dc93b11..c26bd4c67311fc7b9ad1bfbe18611ec5866dbff1 100644 (file)
@@ -51,8 +51,6 @@
 #include "ustrenum.h"
 #include "utracimp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 namespace {
@@ -109,7 +107,7 @@ CollationLoader::loadRules(const char *localeID, const char *collationType,
     // Copy the type for lowercasing.
     char type[16];
     int32_t typeLength = uprv_strlen(collationType);
-    if(typeLength >= LENGTHOF(type)) {
+    if(typeLength >= uprv_lengthof(type)) {
         errorCode = U_ILLEGAL_ARGUMENT_ERROR;
         return;
     }
@@ -179,7 +177,7 @@ CollationLoader::CollationLoader(const CollationCacheEntry *re, const Locale &re
 
         // Fetch the collation type from the locale ID.
         int32_t typeLength = requested.getKeywordValue("collation",
-                type, LENGTHOF(type) - 1, errorCode);
+                type, uprv_lengthof(type) - 1, errorCode);
         if(U_FAILURE(errorCode)) {
             errorCode = U_ILLEGAL_ARGUMENT_ERROR;
             return;
@@ -268,7 +266,7 @@ CollationLoader::loadFromBundle(UErrorCode &errorCode) {
                 ures_getByKeyWithFallback(collations, "default", NULL, &internalErrorCode));
         int32_t length;
         const UChar *s = ures_getString(def.getAlias(), &length, &internalErrorCode);
-        if(U_SUCCESS(internalErrorCode) && 0 < length && length < LENGTHOF(defaultType)) {
+        if(U_SUCCESS(internalErrorCode) && 0 < length && length < uprv_lengthof(defaultType)) {
             u_UCharsToChars(s, defaultType, length + 1);
         } else {
             uprv_strcpy(defaultType, "standard");
@@ -426,7 +424,7 @@ CollationLoader::loadFromData(UErrorCode &errorCode) {
                                           &internalErrorCode));
         int32_t length;
         const UChar *s = ures_getString(def.getAlias(), &length, &internalErrorCode);
-        if(U_SUCCESS(internalErrorCode) && length < LENGTHOF(defaultType)) {
+        if(U_SUCCESS(internalErrorCode) && length < uprv_lengthof(defaultType)) {
             u_UCharsToChars(s, defaultType, length + 1);
         } else {
             uprv_strcpy(defaultType, "standard");
@@ -581,7 +579,7 @@ static const char RESOURCE_NAME[] = "collations";
 
 static const char* const KEYWORDS[] = { "collation" };
 
-#define KEYWORD_COUNT LENGTHOF(KEYWORDS)
+#define KEYWORD_COUNT uprv_lengthof(KEYWORDS)
 
 U_CAPI UEnumeration* U_EXPORT2
 ucol_getKeywords(UErrorCode *status) {
index 213038a7a65fd37d8142fc526ebd018b6a3904eb..7849bb9527d63453d89f551c80d02a6ad0bdc31b 100644 (file)
@@ -27,8 +27,6 @@
 #include "cmemory.h"
 #include "usrchimp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_USE
 
 #define BUFFER_LENGTH             100
@@ -74,7 +72,7 @@ RCEBuffer::RCEBuffer()
 {
     buffer = defaultBuffer;
     bufferIndex = 0;
-    bufferSize = LENGTHOF(defaultBuffer);
+    bufferSize = uprv_lengthof(defaultBuffer);
 }
 
 RCEBuffer::~RCEBuffer()
@@ -124,7 +122,7 @@ PCEBuffer::PCEBuffer()
 {
     buffer = defaultBuffer;
     bufferIndex = 0;
-    bufferSize = LENGTHOF(defaultBuffer);
+    bufferSize = uprv_lengthof(defaultBuffer);
 }
 
 PCEBuffer::~PCEBuffer()
index 6baaad555e3f2d7e386a69441a286ddae57b23fa..ccc17da5baf84a0e2df234904cc426d7e952d6ed 100644 (file)
@@ -28,8 +28,6 @@ U_NAMESPACE_USE
 // (and if we decide to turn this on again there are several new TODOs that will need to be addressed)
 #define BOYER_MOORE 0
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // internal definition ---------------------------------------------------
 
 #define LAST_BYTE_MASK_          0xFF
index be71a3b4fd9e38c7999a5fe8184de158723f2e80..4f53b4dc761f197547639a1a3c883b1fcfbfb017 100644 (file)
@@ -27,8 +27,6 @@
 #include "uhash.h"
 #include "olsontz.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static UMutex gZoneMetaLock = U_MUTEX_INITIALIZER;
 
 // CLDR Canonical ID mapping table
@@ -269,7 +267,7 @@ ZoneMeta::getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status) {
     // If not, resolve CLDR canonical ID with resource data
     UBool isInputCanonical = FALSE;
     char id[ZID_KEY_MAX + 1];
-    tzid.extract(0, 0x7fffffff, id, LENGTHOF(id), US_INV);
+    tzid.extract(0, 0x7fffffff, id, uprv_lengthof(id), US_INV);
 
     // replace '/' with ':'
     char *p = id;
index 5adffe3643e58f166de096d16ae5a19a6fac20f3..018970ee9e319cf1a0ff245f2475555ca60fd21c 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1999-2010, International Business Machines Corporation and
+ * Copyright (c) 1999-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -16,8 +16,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 extern "C" void capi();
 void cppapi();
 
@@ -153,12 +151,12 @@ setNumberFormatCurrency_2_4(NumberFormat &nf, const char *currency, UErrorCode &
 
     int32_t i;
 
-    for(i=0; i<LENGTHOF(currencyMap); ++i) {
+    for(i=0; i<uprv_lengthof(currencyMap); ++i) {
         if(strcmp(currency, currencyMap[i].currency)==0) {
             break;
         }
     }
-    if(i==LENGTHOF(currencyMap)) {
+    if(i==uprv_lengthof(currencyMap)) {
         // a more specific error code would be useful in a real application
         errorCode=U_UNSUPPORTED_ERROR;
         return;
@@ -235,7 +233,7 @@ showCurrencyFormatting(UBool useICU26API) {
     // TODO: Using printf() here assumes that the runtime encoding is ASCII-friendly
     // and can therefore be mixed with UTF-8
 
-    for(i=0; i<LENGTHOF(sampleLocaleIDs); ++i) {
+    for(i=0; i<uprv_lengthof(sampleLocaleIDs); ++i) {
         printf("show currency formatting (method for %s) in the locale \"%s\"\n",
                 useICU26API ? "ICU 2.6" : "before ICU 2.6",
                 sampleLocaleIDs[i]);
@@ -249,7 +247,7 @@ showCurrencyFormatting(UBool useICU26API) {
             continue;
         }
 
-        for(j=0; j<LENGTHOF(sampleCurrencies); ++j) {
+        for(j=0; j<uprv_lengthof(sampleCurrencies); ++j) {
             printf("  - format currency \"%s\": ", sampleCurrencies[j]);
 
             // set the actual currency to be formatted
index 6c705538f646f041ee4fa6a2ee4d685659e1d9a3..847fdce54d601ea5e9620438440ec43f58660873 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2003-2007, International Business Machines
+*   Copyright (C) 2003-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -24,8 +24,6 @@
 #include "unicode/uiter.h"
 #include "uit_len8.h"
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 #define log_err printf
 
 /* UCharIterator test ------------------------------------------------------- */
@@ -320,7 +318,7 @@ TestLenient8Iterator() {
     compareIterators(&iter1, "UTF16Iterator", &iter2, "Lenient8Iterator_1");
 
     /* test get/set state */
-    length=LENGTHOF(text)-1;
+    length=uprv_lengthof(text)-1;
     uiter_setLenient8(&iter1, (const char*)bytes, -1);
     testIteratorState(&iter1, &iter2, "Lenient8IteratorState", length/2);
     testIteratorState(&iter1, &iter2, "Lenient8IteratorStatePlus1", length/2+1);
index 52351e47d072642eb21c3bb22638699b5935f00f..1bee2173837a9efabe567a16a9f87cc4054b33bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2000-2002, International Business Machines
+*   Copyright (C) 2000-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -25,8 +25,6 @@
 #include "unicode/ucnv.h"
 #include "unicode/unistr.h"
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 // helper functions -------------------------------------------------------- ***
 
 // default converter for the platform encoding
@@ -107,8 +105,8 @@ demo_utf_h_macros() {
 
     printf("\n* demo_utf_h_macros() -------------- ***\n\n");
 
-    printUString("iterate forward through: ", input, LENGTHOF(input));
-    for(i=0; i<LENGTHOF(input); /* U16_NEXT post-increments */) {
+    printUString("iterate forward through: ", input, uprv_lengthof(input));
+    for(i=0; i<uprv_lengthof(input); /* U16_NEXT post-increments */) {
         /* Iterating forwards 
            Codepoint at offset 0: U+0061
            Codepoint at offset 1: U+10000
@@ -116,7 +114,7 @@ demo_utf_h_macros() {
            Codepoint at offset 5: U+0062
         */
         printf("Codepoint at offset %d: U+", i);
-        U16_NEXT(input, i, LENGTHOF(input), c);
+        U16_NEXT(input, i, uprv_lengthof(input), c);
         printf("%04x\n", c); 
     }
 
@@ -124,10 +122,10 @@ demo_utf_h_macros() {
 
     isError=FALSE;
     i=1; /* write position, gets post-incremented so needs to be in an l-value */
-    U16_APPEND(input, i, LENGTHOF(input), 0x0062, isError);
+    U16_APPEND(input, i, uprv_lengthof(input), 0x0062, isError);
 
-    printUString("iterate backward through: ", input, LENGTHOF(input));
-    for(i=LENGTHOF(input); i>0; /* U16_PREV pre-decrements */) {
+    printUString("iterate backward through: ", input, uprv_lengthof(input));
+    for(i=uprv_lengthof(input); i>0; /* U16_PREV pre-decrements */) {
         U16_PREV(input, 0, i, c);
         /* Iterating backwards
            Codepoint at offset 5: U+0062
@@ -214,57 +212,57 @@ static void demoCaseMapInC() {
 
     /* uppercase */
     isError=FALSE;
-    for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+    for(i=j=0; j<uprv_lengthof(buffer) && !isError; /* U16_NEXT post-increments */) {
         U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
         if(c==0) {
             break; /* stop at terminating NUL, no need to terminate buffer */
         }
         c=u_toupper(c);
-        U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError);
+        U16_APPEND(buffer, j, uprv_lengthof(buffer), c, isError);
     }
     printUString("simple-uppercased: ", buffer, j);
     /* lowercase */
     isError=FALSE;
-    for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+    for(i=j=0; j<uprv_lengthof(buffer) && !isError; /* U16_NEXT post-increments */) {
         U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
         if(c==0) {
             break; /* stop at terminating NUL, no need to terminate buffer */
         }
         c=u_tolower(c);
-        U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError);
+        U16_APPEND(buffer, j, uprv_lengthof(buffer), c, isError);
     }
     printUString("simple-lowercased: ", buffer, j);
     /* titlecase */
     isError=FALSE;
-    for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+    for(i=j=0; j<uprv_lengthof(buffer) && !isError; /* U16_NEXT post-increments */) {
         U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
         if(c==0) {
             break; /* stop at terminating NUL, no need to terminate buffer */
         }
         c=u_totitle(c);
-        U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError);
+        U16_APPEND(buffer, j, uprv_lengthof(buffer), c, isError);
     }
     printUString("simple-titlecased: ", buffer, j);
     /* case-fold/default */
     isError=FALSE;
-    for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+    for(i=j=0; j<uprv_lengthof(buffer) && !isError; /* U16_NEXT post-increments */) {
         U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
         if(c==0) {
             break; /* stop at terminating NUL, no need to terminate buffer */
         }
         c=u_foldCase(c, U_FOLD_CASE_DEFAULT);
-        U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError);
+        U16_APPEND(buffer, j, uprv_lengthof(buffer), c, isError);
     }
     printUString("simple-case-folded/default: ", buffer, j);
     /* case-fold/Turkic */
     isError=FALSE;
-    for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) {
+    for(i=j=0; j<uprv_lengthof(buffer) && !isError; /* U16_NEXT post-increments */) {
         U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */
         if(c==0) {
             break; /* stop at terminating NUL, no need to terminate buffer */
         }
         c=u_foldCase(c, U_FOLD_CASE_EXCLUDE_SPECIAL_I);
-        U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError);
+        U16_APPEND(buffer, j, uprv_lengthof(buffer), c, isError);
     }
     printUString("simple-case-folded/Turkic: ", buffer, j);
 
@@ -285,7 +283,7 @@ static void demoCaseMapInC() {
 
     /* lowercase/English */
     errorCode=U_ZERO_ERROR;
-    length=u_strToLower(buffer, LENGTHOF(buffer), input, -1, "en", &errorCode);
+    length=u_strToLower(buffer, uprv_lengthof(buffer), input, -1, "en", &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-lowercased/en: ", buffer, length);
     } else {
@@ -293,7 +291,7 @@ static void demoCaseMapInC() {
     }
     /* lowercase/Turkish */
     errorCode=U_ZERO_ERROR;
-    length=u_strToLower(buffer, LENGTHOF(buffer), input, -1, "tr", &errorCode);
+    length=u_strToLower(buffer, uprv_lengthof(buffer), input, -1, "tr", &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-lowercased/tr: ", buffer, length);
     } else {
@@ -301,7 +299,7 @@ static void demoCaseMapInC() {
     }
     /* uppercase/English */
     errorCode=U_ZERO_ERROR;
-    length=u_strToUpper(buffer, LENGTHOF(buffer), input, -1, "en", &errorCode);
+    length=u_strToUpper(buffer, uprv_lengthof(buffer), input, -1, "en", &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-uppercased/en: ", buffer, length);
     } else {
@@ -309,7 +307,7 @@ static void demoCaseMapInC() {
     }
     /* uppercase/Turkish */
     errorCode=U_ZERO_ERROR;
-    length=u_strToUpper(buffer, LENGTHOF(buffer), input, -1, "tr", &errorCode);
+    length=u_strToUpper(buffer, uprv_lengthof(buffer), input, -1, "tr", &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-uppercased/tr: ", buffer, length);
     } else {
@@ -317,7 +315,7 @@ static void demoCaseMapInC() {
     }
     /* titlecase/English */
     errorCode=U_ZERO_ERROR;
-    length=u_strToTitle(buffer, LENGTHOF(buffer), input, -1, NULL, "en", &errorCode);
+    length=u_strToTitle(buffer, uprv_lengthof(buffer), input, -1, NULL, "en", &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-titlecased/en: ", buffer, length);
     } else {
@@ -325,7 +323,7 @@ static void demoCaseMapInC() {
     }
     /* titlecase/Turkish */
     errorCode=U_ZERO_ERROR;
-    length=u_strToTitle(buffer, LENGTHOF(buffer), input, -1, NULL, "tr", &errorCode);
+    length=u_strToTitle(buffer, uprv_lengthof(buffer), input, -1, NULL, "tr", &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-titlecased/tr: ", buffer, length);
     } else {
@@ -333,7 +331,7 @@ static void demoCaseMapInC() {
     }
     /* case-fold/default */
     errorCode=U_ZERO_ERROR;
-    length=u_strFoldCase(buffer, LENGTHOF(buffer), input, -1, U_FOLD_CASE_DEFAULT, &errorCode);
+    length=u_strFoldCase(buffer, uprv_lengthof(buffer), input, -1, U_FOLD_CASE_DEFAULT, &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-case-folded/default: ", buffer, length);
     } else {
@@ -341,7 +339,7 @@ static void demoCaseMapInC() {
     }
     /* case-fold/Turkic */
     errorCode=U_ZERO_ERROR;
-    length=u_strFoldCase(buffer, LENGTHOF(buffer), input, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode);
+    length=u_strFoldCase(buffer, uprv_lengthof(buffer), input, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode);
     if(U_SUCCESS(errorCode)) {
         printUString("full-case-folded/Turkic: ", buffer, length);
     } else {
@@ -428,11 +426,11 @@ demoUnicodeStringStorage() {
     printf("length of short string copy: %d\n", two.length());
     // set "one" to contain the 3 UChars from readonly
     // this setTo() variant copies the characters
-    one.setTo(readonly, LENGTHOF(readonly));
+    one.setTo(readonly, uprv_lengthof(readonly));
 
     // * UnicodeString with allocated contents
     // build a longer string that will not fit into the object's buffer
-    one+=UnicodeString(writeable, LENGTHOF(writeable));
+    one+=UnicodeString(writeable, uprv_lengthof(writeable));
     one+=one;
     one+=one;
     printf("length of longer string: %d\n", one.length());
@@ -443,7 +441,7 @@ demoUnicodeStringStorage() {
 
     // * UnicodeString using readonly-alias to a const UChar array
     // construct a string that aliases a readonly buffer
-    UnicodeString three(FALSE, readonly, LENGTHOF(readonly));
+    UnicodeString three(FALSE, readonly, uprv_lengthof(readonly));
     printUnicodeString("readonly-alias string: ", three);
     // copy-on-write: any modification to the string results in
     // a copy to either the internal buffer or to a newly allocated one
@@ -455,7 +453,7 @@ demoUnicodeStringStorage() {
                i, readonly[i]);
     }
     // setTo() readonly alias
-    one.setTo(FALSE, writeable, LENGTHOF(writeable));
+    one.setTo(FALSE, writeable, uprv_lengthof(writeable));
     // copying the readonly-alias object with fastCopyFrom() (new in ICU 2.4)
     // will readonly-alias the same buffer
     two.fastCopyFrom(one);
@@ -468,7 +466,7 @@ demoUnicodeStringStorage() {
         one.getBuffer()==two.getBuffer());
 
     // * UnicodeString using writeable-alias to a non-const UChar array
-    UnicodeString four(writeable, LENGTHOF(writeable), LENGTHOF(writeable));
+    UnicodeString four(writeable, uprv_lengthof(writeable), uprv_lengthof(writeable));
     printUnicodeString("writeable-alias string: ", four);
     // a modification writes through to the buffer
     four.setCharAt(1, 0x39);
@@ -485,7 +483,7 @@ demoUnicodeStringStorage() {
                "modification of string copy\n", i, writeable[i]);
     }
     // setTo() writeable alias, capacity==length
-    one.setTo(writeable, LENGTHOF(writeable), LENGTHOF(writeable));
+    one.setTo(writeable, uprv_lengthof(writeable), uprv_lengthof(writeable));
     // grow the string - it will not fit into the backing buffer any more
     // and will get copied before modification
     one.append((UChar)0x40);
@@ -499,13 +497,13 @@ demoUnicodeStringStorage() {
     // if we need it in the original buffer, then extract() to it
     // extract() does not do anything if the string aliases that same buffer
     // i=min(one.length(), length of array)
-    if(one.length()<LENGTHOF(writeable)) {
+    if(one.length()<uprv_lengthof(writeable)) {
         i=one.length();
     } else {
-        i=LENGTHOF(writeable);
+        i=uprv_lengthof(writeable);
     }
     one.extract(0, i, writeable);
-    for(i=0; i<LENGTHOF(writeable); ++i) {
+    for(i=0; i<uprv_lengthof(writeable); ++i) {
         printf("writeable-alias backing buffer[%d]=0x%lx after re-extract\n",
                i, writeable[i]);
     }
@@ -568,7 +566,7 @@ demoUnicodeStringInit() {
     int32_t length;
     length=u_unescape(
         "Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\n",
-        buffer, LENGTHOF(buffer));
+        buffer, uprv_lengthof(buffer));
     printf("german C Unicode string from char * unescaping: (length %d)\n    ", length);
     printUnicodeString("", UnicodeString(buffer));
 }
index 9b0befc97101c54a9e12ac15306e607d8826c0be..9fabe7ea7e96f17a41a26d1439e5b579f985fd76 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 2002-2011, International Business Machines
+*   Copyright (C) 2002-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -35,8 +35,6 @@
 #include "cmemory.h"
 #include "cintltst.h"
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 /* icuhtml/design/conversion/bocu1/bocu1.h ---------------------------------- */
 
 /* BOCU-1 constants and macros ---------------------------------------------- */
@@ -951,21 +949,21 @@ static const struct {
     const UChar *s;
     int32_t length;
 } strings[]={
-    { feff,         LENGTHOF(feff) },
-    { ascii,        LENGTHOF(ascii) },
-    { crlf,         LENGTHOF(crlf) },
-    { nul,          LENGTHOF(nul) },
-    { latin,        LENGTHOF(latin) },
-    { devanagari,   LENGTHOF(devanagari) },
-    { hiragana,     LENGTHOF(hiragana) },
-    { unihan,       LENGTHOF(unihan) },
-    { hangul,       LENGTHOF(hangul) },
-    { surrogates,   LENGTHOF(surrogates) },
-    { plane1,       LENGTHOF(plane1) },
-    { plane2,       LENGTHOF(plane2) },
-    { plane15,      LENGTHOF(plane15) },
-    { plane16,      LENGTHOF(plane16) },
-    { c0,           LENGTHOF(c0) }
+    { feff,         uprv_lengthof(feff) },
+    { ascii,        uprv_lengthof(ascii) },
+    { crlf,         uprv_lengthof(crlf) },
+    { nul,          uprv_lengthof(nul) },
+    { latin,        uprv_lengthof(latin) },
+    { devanagari,   uprv_lengthof(devanagari) },
+    { hiragana,     uprv_lengthof(hiragana) },
+    { unihan,       uprv_lengthof(unihan) },
+    { hangul,       uprv_lengthof(hangul) },
+    { surrogates,   uprv_lengthof(surrogates) },
+    { plane1,       uprv_lengthof(plane1) },
+    { plane2,       uprv_lengthof(plane2) },
+    { plane15,      uprv_lengthof(plane15) },
+    { plane16,      uprv_lengthof(plane16) },
+    { c0,           uprv_lengthof(c0) }
 };
 
 /*
@@ -993,7 +991,7 @@ TestBOCU1(void) {
 
     /* text 1: each of strings[] once */
     length=0;
-    for(i=0; i<LENGTHOF(strings); ++i) {
+    for(i=0; i<uprv_lengthof(strings); ++i) {
         u_memcpy(text+length, strings[i].s, strings[i].length);
         length+=strings[i].length;
     }
@@ -1001,7 +999,7 @@ TestBOCU1(void) {
 
     /* text 2: each of strings[] twice */
     length=0;
-    for(i=0; i<LENGTHOF(strings); ++i) {
+    for(i=0; i<uprv_lengthof(strings); ++i) {
         u_memcpy(text+length, strings[i].s, strings[i].length);
         length+=strings[i].length;
         u_memcpy(text+length, strings[i].s, strings[i].length);
@@ -1012,8 +1010,8 @@ TestBOCU1(void) {
     /* text 3: each of strings[] many times (set step vs. |strings| so that all strings are used) */
     length=0;
     for(i=1; length<5000; i+=7) {
-        if(i>=LENGTHOF(strings)) {
-            i-=LENGTHOF(strings);
+        if(i>=uprv_lengthof(strings)) {
+            i-=uprv_lengthof(strings);
         }
         u_memcpy(text+length, strings[i].s, strings[i].length);
         length+=strings[i].length;
index b85b95ca79694cb1a72488a5cb1b9622b821252e..64ead15c00c112ddabedae0f1d97cdfe38061376 100644 (file)
@@ -33,8 +33,6 @@
 #include "cstring.h"
 #include "ucol_imp.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static void TestAttribute(void);
 static void TestDefault(void);
 static void TestDefaultKeyword(void);
@@ -1860,7 +1858,7 @@ void TestGetTailoredSet() {
   int32_t buffLen = 0;
   USet *set = NULL;
 
-  for(i = 0; i < LENGTHOF(setTest); i++) {
+  for(i = 0; i < uprv_lengthof(setTest); i++) {
     buffLen = u_unescape(setTest[i].rules, buff, 1024);
     coll = ucol_openRules(buff, buffLen, UCOL_DEFAULT, UCOL_DEFAULT, &pError, &status);
     if(U_SUCCESS(status)) {
@@ -2128,9 +2126,9 @@ doSetsTest(const char *locale, const USet *ref, USet *set, const char* inSet, co
     if(!uset_containsAll(ref, set)) {
         log_err("%s: Some stuff from %s is not present in the set\n", locale, inSet);
         uset_removeAll(set, ref);
-        bufLen = uset_toPattern(set, buffer, LENGTHOF(buffer), TRUE, status);
+        bufLen = uset_toPattern(set, buffer, uprv_lengthof(buffer), TRUE, status);
         log_info("    missing: %s\n", aescstrdup(buffer, bufLen));
-        bufLen = uset_toPattern(ref, buffer, LENGTHOF(buffer), TRUE, status);
+        bufLen = uset_toPattern(ref, buffer, uprv_lengthof(buffer), TRUE, status);
         log_info("    total: size=%i  %s\n", uset_getItemCount(ref), aescstrdup(buffer, bufLen));
     }
 
@@ -2427,7 +2425,7 @@ static void TestGetKeywordValuesForLocale(void) {
     const char *locale = NULL, *value = NULL;
     UBool errorOccurred = FALSE;
 
-    for (i = 0; i < LENGTHOF(PREFERRED) && !errorOccurred; i++) {
+    for (i = 0; i < uprv_lengthof(PREFERRED) && !errorOccurred; i++) {
         locale = PREFERRED[i][0];
         value = NULL;
         valueLength = 0;
index 5d85dffbee0711e58de871d56a67a86689e5c5a9..0788977dd75e6be2f259052b4a79c168e05d093d 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdio.h>
 
 #define MAXLEN      MAX_STRING_LENGTH
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
 
 /* prototypes ---------------------------------------------------------------*/
 
@@ -730,7 +729,7 @@ testReorder(void) {
 
     log_verbose("\nEntering TestReorder\n\n");
 
-    for(i=0;i<LENGTHOF(logicalOrder);i++){
+    for(i=0;i<uprv_lengthof(logicalOrder);i++){
         int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
         int32_t destSize = srcSize*2;
         UChar src[MAXLEN];
@@ -765,7 +764,7 @@ testReorder(void) {
         checkWhatYouCan(bidi, logicalOrder[i], chars);
     }
 
-    for(i=0;i<LENGTHOF(logicalOrder);i++){
+    for(i=0;i<uprv_lengthof(logicalOrder);i++){
         int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
         int32_t destSize = srcSize*2;
         UChar src[MAXLEN];
@@ -799,7 +798,7 @@ testReorder(void) {
         }
     }
 
-    for(i=0;i<LENGTHOF(logicalOrder);i++){
+    for(i=0;i<uprv_lengthof(logicalOrder);i++){
         int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
         int32_t destSize = srcSize*2;
         UChar src[MAXLEN];
@@ -830,7 +829,7 @@ testReorder(void) {
         }
     }
         /* Max Explicit level */
-    for(i=0;i<LENGTHOF(logicalOrder);i++){
+    for(i=0;i<uprv_lengthof(logicalOrder);i++){
         int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
         int32_t destSize = srcSize*2;
         UChar src[MAXLEN];
@@ -864,7 +863,7 @@ testReorder(void) {
                     logicalOrder[i],visualOrder3[i],chars,formatLevels(bidi, formatChars),i);
         }
     }
-    for(i=0;i<LENGTHOF(logicalOrder);i++){
+    for(i=0;i<uprv_lengthof(logicalOrder);i++){
         int32_t srcSize = (int32_t)strlen(logicalOrder[i]);
         int32_t destSize = srcSize*2;
         UChar src[MAXLEN];
@@ -992,7 +991,7 @@ testReorderArabicMathSymbols(void) {
 
     log_verbose("\nEntering TestReorderArabicMathSymbols\n\n");
 
-    for(i=0;i<LENGTHOF(logicalOrder);i++){
+    for(i=0;i<uprv_lengthof(logicalOrder);i++){
         int32_t srcSize = u_strlen(logicalOrder[i]);
         int32_t destSize = srcSize*2;
         UChar dest[MAXLEN];
@@ -1284,7 +1283,7 @@ _testReordering(UBiDi *pBiDi, int testNumber) {
         return;     \
     }               \
 
-#define STRING_TEST_CASE(s) { (s), LENGTHOF(s) }
+#define STRING_TEST_CASE(s) { (s), uprv_lengthof(s) }
 
 static void testGetBaseDirection(void) {
     UBiDiDirection dir;
@@ -1354,9 +1353,9 @@ static void testGetBaseDirection(void) {
     };
 
     log_verbose("testGetBaseDirection() with %u test cases ---\n",
-    LENGTHOF(testCases));
+    uprv_lengthof(testCases));
 /* Run Tests */
-     for(i=0; i<LENGTHOF(testCases); ++i) {
+     for(i=0; i<uprv_lengthof(testCases); ++i) {
         dir = ubidi_getBaseDirection(testCases[i].s, testCases[i].length );
         log_verbose("Testing case %d\tReceived dir %d\n", i, dir);
         if (dir != expectedDir[i])
@@ -2131,7 +2130,7 @@ testMultipleParagraphs(void) {
      */
     pBidi = ubidi_open();
     errorCode = U_ZERO_ERROR;
-    ubidi_setPara(pBidi, multiparaTestString, LENGTHOF(multiparaTestString),
+    ubidi_setPara(pBidi, multiparaTestString, uprv_lengthof(multiparaTestString),
                   UBIDI_DEFAULT_LTR, NULL, &errorCode);
     if (U_FAILURE(errorCode)) {
         log_err("ubidi_setPara failed for multiparaTestString\n");
@@ -2144,7 +2143,7 @@ testMultipleParagraphs(void) {
         ubidi_close(pBidi);
         return;
     }
-    for (i = 0; i < LENGTHOF(multiparaTestString); i++) {
+    for (i = 0; i < uprv_lengthof(multiparaTestString); i++) {
         if (gotLevels[i] != multiparaTestLevels[i]) {
             log_err("Error on level for multiparaTestString at index %d, "
                     "expected=%d, actual=%d\n",
@@ -2160,7 +2159,7 @@ testMultipleParagraphs(void) {
 
 static int countRoundtrips=0, countNonRoundtrips=0;
 
-#define STRING_TEST_CASE(s) { (s), LENGTHOF(s) }
+#define STRING_TEST_CASE(s) { (s), uprv_lengthof(s) }
 
 static void
 testInverse(void) {
@@ -2193,15 +2192,15 @@ testInverse(void) {
         return;
     }
 
-    log_verbose("inverse Bidi: testInverse(L) with %u test cases ---\n", LENGTHOF(testCases));
-     for(i=0; i<LENGTHOF(testCases); ++i) {
+    log_verbose("inverse Bidi: testInverse(L) with %u test cases ---\n", uprv_lengthof(testCases));
+     for(i=0; i<uprv_lengthof(testCases); ++i) {
         log_verbose("Testing case %d\n", i);
         errorCode=U_ZERO_ERROR;
         _testInverseBidi(pBiDi, testCases[i].s, testCases[i].length, 0, &errorCode);
     }
 
-    log_verbose("inverse Bidi: testInverse(R) with %u test cases ---\n", LENGTHOF(testCases));
-    for(i=0; i<LENGTHOF(testCases); ++i) {
+    log_verbose("inverse Bidi: testInverse(R) with %u test cases ---\n", uprv_lengthof(testCases));
+    for(i=0; i<uprv_lengthof(testCases); ++i) {
         log_verbose("Testing case %d\n", i);
         errorCode=U_ZERO_ERROR;
         _testInverseBidi(pBiDi, testCases[i].s, testCases[i].length, 1, &errorCode);
@@ -2278,7 +2277,7 @@ _testInverseBidi(UBiDi *pBiDi, const UChar *src, int32_t srcLength,
         if (src != ubidi_getText(pBiDi)) {
             log_err("Wrong value returned by ubidi_getText\n");
         }
-        logicalLength=ubidi_writeReordered(pBiDi, logicalDest, LENGTHOF(logicalDest),
+        logicalLength=ubidi_writeReordered(pBiDi, logicalDest, uprv_lengthof(logicalDest),
                                            UBIDI_DO_MIRRORING|UBIDI_INSERT_LRM_FOR_NUMERIC, pErrorCode);
         log_verbose("  v ");
         printUnicode(src, srcLength, ubidi_getLevels(pBiDi, pErrorCode));
@@ -2290,13 +2289,13 @@ _testInverseBidi(UBiDi *pBiDi, const UChar *src, int32_t srcLength,
             log_err("Error while doing ubidi_setInverse(FALSE)\n");
         }
         ubidi_setPara(pBiDi, logicalDest, logicalLength, 0, NULL, pErrorCode);
-        visualLength=ubidi_writeReordered(pBiDi, visualDest, LENGTHOF(visualDest),
+        visualLength=ubidi_writeReordered(pBiDi, visualDest, uprv_lengthof(visualDest),
                                           UBIDI_DO_MIRRORING|UBIDI_REMOVE_BIDI_CONTROLS, pErrorCode);
     } else {
         log_verbose("inverse Bidi: testInverse(R)\n");
 
         /* reverse visual from RTL to LTR */
-        ltrLength=ubidi_writeReverse(src, srcLength, visualLTR, LENGTHOF(visualLTR), 0, pErrorCode);
+        ltrLength=ubidi_writeReverse(src, srcLength, visualLTR, uprv_lengthof(visualLTR), 0, pErrorCode);
         log_verbose("  vr");
         printUnicode(src, srcLength, NULL);
         log_verbose("\n");
@@ -2304,7 +2303,7 @@ _testInverseBidi(UBiDi *pBiDi, const UChar *src, int32_t srcLength,
         /* convert visual RTL to logical */
         ubidi_setInverse(pBiDi, TRUE);
         ubidi_setPara(pBiDi, visualLTR, ltrLength, 0, NULL, pErrorCode);
-        logicalLength=ubidi_writeReordered(pBiDi, logicalDest, LENGTHOF(logicalDest),
+        logicalLength=ubidi_writeReordered(pBiDi, logicalDest, uprv_lengthof(logicalDest),
                                            UBIDI_DO_MIRRORING|UBIDI_INSERT_LRM_FOR_NUMERIC, pErrorCode);
         log_verbose("  vl");
         printUnicode(visualLTR, ltrLength, ubidi_getLevels(pBiDi, pErrorCode));
@@ -2313,7 +2312,7 @@ _testInverseBidi(UBiDi *pBiDi, const UChar *src, int32_t srcLength,
         /* convert back to visual RTL */
         ubidi_setInverse(pBiDi, FALSE);
         ubidi_setPara(pBiDi, logicalDest, logicalLength, 0, NULL, pErrorCode);
-        visualLength=ubidi_writeReordered(pBiDi, visualDest, LENGTHOF(visualDest),
+        visualLength=ubidi_writeReordered(pBiDi, visualDest, uprv_lengthof(visualDest),
                                           UBIDI_DO_MIRRORING|UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_OUTPUT_REVERSE, pErrorCode);
     }
     log_verbose("  l ");
@@ -2354,25 +2353,25 @@ _testWriteReverse(void) {
 
     /* test ubidi_writeReverse() with "interesting" options */
     errorCode=U_ZERO_ERROR;
-    length=ubidi_writeReverse(forward, LENGTHOF(forward),
-                              reverse, LENGTHOF(reverse),
+    length=ubidi_writeReverse(forward, uprv_lengthof(forward),
+                              reverse, uprv_lengthof(reverse),
                               UBIDI_KEEP_BASE_COMBINING,
                               &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(reverseKeepCombining) || memcmp(reverse, reverseKeepCombining, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(reverseKeepCombining) || memcmp(reverse, reverseKeepCombining, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in ubidi_writeReverse(UBIDI_KEEP_BASE_COMBINING): length=%d (should be %d), error code %s\n",
-                length, LENGTHOF(reverseKeepCombining), u_errorName(errorCode));
+                length, uprv_lengthof(reverseKeepCombining), u_errorName(errorCode));
     }
 
-    memset(reverse, 0xa5, LENGTHOF(reverse)*U_SIZEOF_UCHAR);
+    memset(reverse, 0xa5, uprv_lengthof(reverse)*U_SIZEOF_UCHAR);
     errorCode=U_ZERO_ERROR;
-    length=ubidi_writeReverse(forward, LENGTHOF(forward),
-                              reverse, LENGTHOF(reverse),
+    length=ubidi_writeReverse(forward, uprv_lengthof(forward),
+                              reverse, uprv_lengthof(reverse),
                               UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING|UBIDI_KEEP_BASE_COMBINING,
                               &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(reverseRemoveControlsKeepCombiningDoMirror) || memcmp(reverse, reverseRemoveControlsKeepCombiningDoMirror, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(reverseRemoveControlsKeepCombiningDoMirror) || memcmp(reverse, reverseRemoveControlsKeepCombiningDoMirror, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in ubidi_writeReverse(UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING|UBIDI_KEEP_BASE_COMBINING):\n"
                 "    length=%d (should be %d), error code %s\n",
-                length, LENGTHOF(reverseRemoveControlsKeepCombiningDoMirror), u_errorName(errorCode));
+                length, uprv_lengthof(reverseRemoveControlsKeepCombiningDoMirror), u_errorName(errorCode));
     }
 }
 
@@ -2381,16 +2380,16 @@ static void _testManyAddedPoints(void) {
     UBiDi *bidi = ubidi_open();
     UChar text[90], dest[MAXLEN], expected[120];
     int destLen, i;
-    for (i = 0; i < LENGTHOF(text); i+=3) {
+    for (i = 0; i < uprv_lengthof(text); i+=3) {
         text[i] = 0x0061; /* 'a' */
         text[i+1] = 0x05d0;
         text[i+2] = 0x0033; /* '3' */
     }
     ubidi_setReorderingMode(bidi, UBIDI_REORDER_INVERSE_LIKE_DIRECT);
     ubidi_setReorderingOptions(bidi, UBIDI_OPTION_INSERT_MARKS);
-    ubidi_setPara(bidi, text, LENGTHOF(text), UBIDI_LTR, NULL, &errorCode);
+    ubidi_setPara(bidi, text, uprv_lengthof(text), UBIDI_LTR, NULL, &errorCode);
     destLen = ubidi_writeReordered(bidi, dest, MAXLEN, 0, &errorCode);
-    for (i = 0; i < LENGTHOF(expected); i+=4) {
+    for (i = 0; i < uprv_lengthof(expected); i+=4) {
         expected[i] = 0x0061; /* 'a' */
         expected[i+1] = 0x05d0;
         expected[i+2] = 0x200e;
@@ -2399,7 +2398,7 @@ static void _testManyAddedPoints(void) {
     if (memcmp(dest, expected, destLen * sizeof(UChar))) {
         log_err("\nInvalid output with many added points, "
                 "expected '%s', got '%s'\n",
-                aescstrdup(expected, LENGTHOF(expected)),
+                aescstrdup(expected, uprv_lengthof(expected)),
                 aescstrdup(dest, destLen));
     }
     ubidi_close(bidi);
@@ -2412,7 +2411,7 @@ static void _testMisc(void) {
     int destLen;
     ubidi_setInverse(bidi, TRUE);
     src[0] = src[1] = src[2] = 0x0020;
-    ubidi_setPara(bidi, src, LENGTHOF(src), UBIDI_RTL, NULL, &errorCode);
+    ubidi_setPara(bidi, src, uprv_lengthof(src), UBIDI_RTL, NULL, &errorCode);
     destLen = ubidi_writeReordered(bidi, dest, MAXLEN,
               UBIDI_OUTPUT_REVERSE | UBIDI_INSERT_LRM_FOR_NUMERIC,
               &errorCode);
@@ -2420,7 +2419,7 @@ static void _testMisc(void) {
     if (memcmp(dest, expected, destLen * sizeof(UChar))) {
         log_err("\nInvalid output with RLM at both sides, "
                 "expected '%s', got '%s'\n",
-                aescstrdup(expected, LENGTHOF(expected)),
+                aescstrdup(expected, uprv_lengthof(expected)),
                 aescstrdup(dest, destLen));
     }
     ubidi_close(bidi);
@@ -2462,18 +2461,18 @@ doArabicShapingTest(void) {
 
     /* european->arabic */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, en2an, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(source) || memcmp(dest, en2an, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(en2an)\n");
     }
 
     /* arabic->european */
     errorCode=U_ZERO_ERROR;
     length=u_shapeArabic(source, -1,
-                         dest, LENGTHOF(dest),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_AN2EN|U_SHAPE_DIGIT_TYPE_AN_EXTENDED,
                          &errorCode);
     if(U_FAILURE(errorCode) || length!=u_strlen(source) || memcmp(dest, an2en, length*U_SIZEOF_UCHAR)!=0) {
@@ -2482,78 +2481,78 @@ doArabicShapingTest(void) {
 
     /* european->arabic with context, logical order, initial state not AL */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_ALEN2AN_INIT_LR|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, logical_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(source) || memcmp(dest, logical_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(logical_alen2an_init_lr)\n");
     }
 
     /* european->arabic with context, logical order, initial state AL */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_ALEN2AN_INIT_AL|U_SHAPE_DIGIT_TYPE_AN_EXTENDED,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, logical_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(source) || memcmp(dest, logical_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(logical_alen2an_init_al)\n");
     }
 
     /* european->arabic with context, reverse order, initial state not AL */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_ALEN2AN_INIT_LR|U_SHAPE_DIGIT_TYPE_AN|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, reverse_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(source) || memcmp(dest, reverse_alen2an_init_lr, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(reverse_alen2an_init_lr)\n");
     }
 
     /* european->arabic with context, reverse order, initial state AL */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_ALEN2AN_INIT_AL|U_SHAPE_DIGIT_TYPE_AN_EXTENDED|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, reverse_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(source) || memcmp(dest, reverse_alen2an_init_al, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(reverse_alen2an_init_al)\n");
     }
 
     /* test noop */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          0,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(source) || memcmp(dest, source, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(source) || memcmp(dest, source, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(noop)\n");
     }
 
     errorCode=U_ZERO_ERROR;
     length=u_shapeArabic(source, 0,
-                         dest, LENGTHOF(dest),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
     if(U_FAILURE(errorCode) || length!=0) {
-        log_err("failure in u_shapeArabic(en2an, sourceLength=0), returned %d/%s\n", u_errorName(errorCode), LENGTHOF(source));
+        log_err("failure in u_shapeArabic(en2an, sourceLength=0), returned %d/%s\n", u_errorName(errorCode), uprv_lengthof(source));
     }
 
     /* preflight digit shaping */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
+    length=u_shapeArabic(source, uprv_lengthof(source),
                          NULL, 0,
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
-    if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=LENGTHOF(source)) {
+    if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=uprv_lengthof(source)) {
         log_err("failure in u_shapeArabic(en2an preflighting), returned %d/%s instead of %d/U_BUFFER_OVERFLOW_ERROR\n",
-                length, u_errorName(errorCode), LENGTHOF(source));
+                length, u_errorName(errorCode), uprv_lengthof(source));
     }
 
     /* test illegal arguments */
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(NULL, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(NULL, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
@@ -2562,7 +2561,7 @@ doArabicShapingTest(void) {
 
     errorCode=U_ZERO_ERROR;
     length=u_shapeArabic(source, -2,
-                         dest, LENGTHOF(dest),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
@@ -2570,8 +2569,8 @@ doArabicShapingTest(void) {
     }
 
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         NULL, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         NULL, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
@@ -2579,7 +2578,7 @@ doArabicShapingTest(void) {
     }
 
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
+    length=u_shapeArabic(source, uprv_lengthof(source),
                          dest, -1,
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
@@ -2588,8 +2587,8 @@ doArabicShapingTest(void) {
     }
 
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_RESERVED|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
@@ -2597,8 +2596,8 @@ doArabicShapingTest(void) {
     }
 
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_RESERVED,
                          &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
@@ -2606,8 +2605,8 @@ doArabicShapingTest(void) {
     }
 
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         (UChar *)(source+2), LENGTHOF(dest), /* overlap source and destination */
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         (UChar *)(source+2), uprv_lengthof(dest), /* overlap source and destination */
                          U_SHAPE_DIGITS_EN2AN|U_SHAPE_DIGIT_TYPE_AN,
                          &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
@@ -2615,11 +2614,11 @@ doArabicShapingTest(void) {
     }
 
     errorCode=U_ZERO_ERROR;
-    length=u_shapeArabic(lamalef, LENGTHOF(lamalef),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(lamalef, uprv_lengthof(lamalef),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_UNSHAPE | U_SHAPE_LENGTH_GROW_SHRINK | U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
-    if(U_FAILURE(errorCode) || length == LENGTHOF(lamalef)) {
+    if(U_FAILURE(errorCode) || length == uprv_lengthof(lamalef)) {
         log_err("failure in u_shapeArabic(U_SHAPE_LETTERS_UNSHAPE | U_SHAPE_LENGTH_GROW_SHRINK | U_SHAPE_TEXT_DIRECTION_VISUAL_LTR)\n");
         log_err("returned %s instead of U_ZERO_ERROR or returned length %d instead of 3\n", u_errorName(errorCode), length);
     }
@@ -2679,44 +2678,44 @@ doLamAlefSpecialVLTRArabicShapingTest(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_LENGTH_FIXED_SPACES_NEAR|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_near) || memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_near) || memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(LAMALEF shape_near)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_LENGTH_FIXED_SPACES_AT_END|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_at_end) || memcmp(dest, shape_at_end, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_at_end) || memcmp(dest, shape_at_end, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(LAMALEF shape_at_end)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_at_begin) || memcmp(dest, shape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_at_begin) || memcmp(dest, shape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(LAMALEF shape_at_begin)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_LENGTH_GROW_SHRINK|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
@@ -2729,44 +2728,44 @@ doLamAlefSpecialVLTRArabicShapingTest(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED|U_SHAPE_LENGTH_FIXED_SPACES_NEAR|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_near) || memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_excepttashkeel_near) || memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_near)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED|U_SHAPE_LENGTH_FIXED_SPACES_AT_END|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_at_end) || memcmp(dest,shape_excepttashkeel_at_end , length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_excepttashkeel_at_end) || memcmp(dest,shape_excepttashkeel_at_end , length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_at_end)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED|U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_at_begin) || memcmp(dest, shape_excepttashkeel_at_begin, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_excepttashkeel_at_begin) || memcmp(dest, shape_excepttashkeel_at_begin, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(LAMALEF shape_excepttashkeel_at_begin)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED|U_SHAPE_LENGTH_GROW_SHRINK|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
@@ -2805,25 +2804,25 @@ doTashkeelSpecialVLTRArabicShapingTest(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_LENGTH_FIXED_SPACES_NEAR|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_near) || memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_near) || memcmp(dest, shape_near, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(TASHKEEL shape_near)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED|U_SHAPE_LENGTH_FIXED_SPACES_NEAR|
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(shape_excepttashkeel_near) || memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(shape_excepttashkeel_near) || memcmp(dest, shape_excepttashkeel_near, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(TASHKEEL shape_excepttashkeel_near)\n");
     }
 }
@@ -2859,44 +2858,44 @@ doLOGICALArabicDeShapingTest(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_UNSHAPE|U_SHAPE_LENGTH_FIXED_SPACES_NEAR|
                          U_SHAPE_TEXT_DIRECTION_LOGICAL,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_near) || memcmp(dest, unshape_near, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(unshape_near) || memcmp(dest, unshape_near, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(unshape_near)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_UNSHAPE|U_SHAPE_LENGTH_FIXED_SPACES_AT_END|
                          U_SHAPE_TEXT_DIRECTION_LOGICAL,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_at_end) || memcmp(dest, unshape_at_end, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(unshape_at_end) || memcmp(dest, unshape_at_end, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(unshape_at_end)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_UNSHAPE|U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING|
                          U_SHAPE_TEXT_DIRECTION_LOGICAL,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(unshape_at_begin) || memcmp(dest, unshape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(unshape_at_begin) || memcmp(dest, unshape_at_begin, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(unshape_at_begin)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(source, LENGTHOF(source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(source, uprv_lengthof(source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_UNSHAPE|U_SHAPE_LENGTH_GROW_SHRINK|
                          U_SHAPE_TEXT_DIRECTION_LOGICAL,
                          &errorCode);
@@ -2920,13 +2919,13 @@ doTailTest(void) {
 
   log_verbose("Trying old tail\n");
   status = U_ZERO_ERROR;
-  length = u_shapeArabic(src, -1, dst, LENGTHOF(dst),
+  length = u_shapeArabic(src, -1, dst, uprv_lengthof(dst),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_SEEN_TWOCELL_NEAR, &status);
   if(U_FAILURE(status)) {
     log_err("Fail: status %s\n", u_errorName(status));
   } else if(length!=2) {
     log_err("Fail: len %d expected 3\n", length);
-  } else if(u_strncmp(dst,dst_old,LENGTHOF(dst))) {
+  } else if(u_strncmp(dst,dst_old,uprv_lengthof(dst))) {
     log_err("Fail: got U+%04X U+%04X expected U+%04X U+%04X\n",
             dst[0],dst[1],dst_old[0],dst_old[1]);
   } else {
@@ -2937,13 +2936,13 @@ doTailTest(void) {
 
   log_verbose("Trying new tail\n");
   status = U_ZERO_ERROR;
-  length = u_shapeArabic(src, -1, dst, LENGTHOF(dst),
+  length = u_shapeArabic(src, -1, dst, uprv_lengthof(dst),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_SEEN_TWOCELL_NEAR|U_SHAPE_TAIL_NEW_UNICODE, &status);
   if(U_FAILURE(status)) {
     log_err("Fail: status %s\n", u_errorName(status));
   } else if(length!=2) {
     log_err("Fail: len %d expected 3\n", length);
-  } else if(u_strncmp(dst,dst_new,LENGTHOF(dst))) {
+  } else if(u_strncmp(dst,dst_new,uprv_lengthof(dst))) {
     log_err("Fail: got U+%04X U+%04X expected U+%04X U+%04X\n",
             dst[0],dst[1],dst_new[0],dst_new[1]);
   } else {
@@ -2981,48 +2980,48 @@ doArabicShapingTestForBug5421(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(persian_letters_source, LENGTHOF(persian_letters_source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(persian_letters_source, uprv_lengthof(persian_letters_source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(persian_letters) || memcmp(dest, persian_letters, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(persian_letters) || memcmp(dest, persian_letters, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(persian_letters)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(tashkeel_aggregation_source, LENGTHOF(tashkeel_aggregation_source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(tashkeel_aggregation_source, uprv_lengthof(tashkeel_aggregation_source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_AGGREGATE_TASHKEEL|U_SHAPE_PRESERVE_PRESENTATION|
                          U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(tashkeel_aggregation) || memcmp(dest, tashkeel_aggregation, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(tashkeel_aggregation) || memcmp(dest, tashkeel_aggregation, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(tashkeel_aggregation)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(untouched_presentation_source, LENGTHOF(untouched_presentation_source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(untouched_presentation_source, uprv_lengthof(untouched_presentation_source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_PRESERVE_PRESENTATION|
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_TEXT_DIRECTION_VISUAL_LTR,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(untouched_presentation) || memcmp(dest, untouched_presentation, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(untouched_presentation) || memcmp(dest, untouched_presentation, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(untouched_presentation)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(untouched_presentation_r_source, LENGTHOF(untouched_presentation_r_source),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(untouched_presentation_r_source, uprv_lengthof(untouched_presentation_r_source),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_PRESERVE_PRESENTATION|
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_TEXT_DIRECTION_LOGICAL,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(untouched_presentation_r) || memcmp(dest, untouched_presentation_r, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(untouched_presentation_r) || memcmp(dest, untouched_presentation_r, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(untouched_presentation_r)\n");
     }
 }
@@ -3070,89 +3069,89 @@ doArabicShapingTestForBug8703(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source1, LENGTHOF(letters_source1),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source1, uprv_lengthof(letters_source1),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_BEGIN | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest1) || memcmp(dest, letters_dest1, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest1) || memcmp(dest, letters_dest1, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source1)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source2, LENGTHOF(letters_source2),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source2, uprv_lengthof(letters_source2),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_END | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest2) || memcmp(dest, letters_dest2, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest2) || memcmp(dest, letters_dest2, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source2)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source3, LENGTHOF(letters_source3),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source3, uprv_lengthof(letters_source3),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_RESIZE | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest3) || memcmp(dest, letters_dest3, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest3) || memcmp(dest, letters_dest3, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source3)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source4, LENGTHOF(letters_source4),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source4, uprv_lengthof(letters_source4),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_REPLACE_BY_TATWEEL | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest4) || memcmp(dest, letters_dest4, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest4) || memcmp(dest, letters_dest4, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source4)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source5, LENGTHOF(letters_source5),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source5, uprv_lengthof(letters_source5),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_TASHKEEL_BEGIN | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest5) || memcmp(dest, letters_dest5, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest5) || memcmp(dest, letters_dest5, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source5)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source6, LENGTHOF(letters_source6),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source6, uprv_lengthof(letters_source6),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_TASHKEEL_END | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest6) || memcmp(dest, letters_dest6, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest6) || memcmp(dest, letters_dest6, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source6)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source7, LENGTHOF(letters_source7),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source7, uprv_lengthof(letters_source7),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_TASHKEEL_RESIZE | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest7) || memcmp(dest, letters_dest7, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest7) || memcmp(dest, letters_dest7, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source7)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source8, LENGTHOF(letters_source8),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source8, uprv_lengthof(letters_source8),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_TASHKEEL_REPLACE_BY_TATWEEL | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest8) || memcmp(dest, letters_dest8, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest8) || memcmp(dest, letters_dest8, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source8)\n");
     }
 }
@@ -3252,67 +3251,67 @@ doArabicShapingTestForBug9024(void) {
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source1, LENGTHOF(letters_source1),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source1, uprv_lengthof(letters_source1),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_BEGIN | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest1) || memcmp(dest, letters_dest1, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest1) || memcmp(dest, letters_dest1, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source1)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source2, LENGTHOF(letters_source2),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source2, uprv_lengthof(letters_source2),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_END | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest2) || memcmp(dest, letters_dest2, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest2) || memcmp(dest, letters_dest2, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source2)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source3, LENGTHOF(letters_source3),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source3, uprv_lengthof(letters_source3),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_RESIZE | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest3) || memcmp(dest, letters_dest3, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest3) || memcmp(dest, letters_dest3, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source3)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source4, LENGTHOF(letters_source4),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source4, uprv_lengthof(letters_source4),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_RTL | U_SHAPE_TASHKEEL_REPLACE_BY_TATWEEL | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest4) || memcmp(dest, letters_dest4, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest4) || memcmp(dest, letters_dest4, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source4)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source5, LENGTHOF(letters_source5),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source5, uprv_lengthof(letters_source5),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_TASHKEEL_BEGIN | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest5) || memcmp(dest, letters_dest5, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest5) || memcmp(dest, letters_dest5, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source5)\n");
     }
 
     errorCode=U_ZERO_ERROR;
 
-    length=u_shapeArabic(letters_source6, LENGTHOF(letters_source6),
-                         dest, LENGTHOF(dest),
+    length=u_shapeArabic(letters_source6, uprv_lengthof(letters_source6),
+                         dest, uprv_lengthof(dest),
                          U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_TASHKEEL_END | U_SHAPE_LETTERS_SHAPE,
                          &errorCode);
 
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(letters_dest6) || memcmp(dest, letters_dest6, length*U_SIZEOF_UCHAR)!=0) {
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(letters_dest6) || memcmp(dest, letters_dest6, length*U_SIZEOF_UCHAR)!=0) {
         log_err("failure in u_shapeArabic(letters_source6)\n");
     }
 
@@ -3551,7 +3550,7 @@ doArabicShapingTestForNewCharacters(void) {
     { 0x06D2, 0xFBAE, 0xFBAF, 0, 0, },           /* YEH BARREE */
     { 0x06D3, 0xFBB0, 0xFBB1, 0, 0, }};          /* YEH BARREE WITH HAMZA ABOVE */
   int32_t i;
-  for (i = 0; i < LENGTHOF(letterForms); ++i) {
+  for (i = 0; i < uprv_lengthof(letterForms); ++i) {
     _testPresentationForms(letterForms[i]);
   }
 }
@@ -3668,10 +3667,10 @@ options[] = {
     { MAKE_ITEMS(0) }
 };
 
-#define TC_COUNT                LENGTHOF(textIn)
-#define MODES_COUNT             LENGTHOF(modes)
-#define OPTIONS_COUNT           LENGTHOF(options)
-#define LEVELS_COUNT            LENGTHOF(paraLevels)
+#define TC_COUNT                uprv_lengthof(textIn)
+#define MODES_COUNT             uprv_lengthof(modes)
+#define OPTIONS_COUNT           uprv_lengthof(options)
+#define LEVELS_COUNT            uprv_lengthof(paraLevels)
 
 static const char* const textIn[] = {
 /* (0) 123 */
@@ -4196,7 +4195,7 @@ testReorderRunsOnly(void) {
     for (option = 0; option < 2; option++) {
         ubidi_setReorderingOptions(pBiDi, option==0 ? UBIDI_OPTION_REMOVE_CONTROLS
                                                     : UBIDI_OPTION_INSERT_MARKS);
-        for (i = 0, nCases = LENGTHOF(testCases); i < nCases; i++) {
+        for (i = 0, nCases = uprv_lengthof(testCases); i < nCases; i++) {
             srcLen = strlen(testCases[i].textIn);
             pseudoToU16(srcLen, testCases[i].textIn, src);
             for(j = 0; j < 2; j++) {
@@ -4435,7 +4434,7 @@ testStreaming(void) {
     int32_t srcLen, processedLen, chunk, len, nPortions;
     int i, j, levelIndex;
     UBiDiLevel level;
-    int nTests = LENGTHOF(testData), nLevels = LENGTHOF(paraLevels);
+    int nTests = uprv_lengthof(testData), nLevels = uprv_lengthof(paraLevels);
     UBool mismatch, testOK = TRUE;
    char processedLenStr[MAXPORTIONS * 5];
 
@@ -4525,7 +4524,7 @@ overrideBidiClass(const void *context, UChar32 c) {
           DEF,   DEF,   DEF,   DEF,   DEF,   DEF,   DEF,   DEF, /* 70-77 */
           DEF,   DEF,   DEF,   LRO,     B,   RLO,    BN,   DEF  /* 78-7F */
     };
-    static const int nEntries = LENGTHOF(customClasses);
+    static const int nEntries = uprv_lengthof(customClasses);
     const char *dummy = context;        /* just to avoid a compiler warning */
     dummy++;
 
@@ -4813,7 +4812,7 @@ static const contextCase contextData[] = {
     /*24*/  {"x|G", ".-=", "", "=-.", UBIDI_DEFAULT_LTR},
     /*25*/  {"x|G", ".-=|-+*", "", "=-.|-+*", UBIDI_DEFAULT_LTR},
 };
-#define CONTEXT_COUNT       LENGTHOF(contextData)
+#define CONTEXT_COUNT       uprv_lengthof(contextData)
 
 static void
 testContext(void) {
index 9d529e3deab0544a3fd015f63dcfbacfdaa1908d..2927cc34f62e521f300f4407ff0e7206bd428d45 100644 (file)
@@ -28,8 +28,6 @@
 #include "ccapitst.h"
 #include "cstring.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define NUM_CODEPAGE 1
 #define MAX_FILE_LEN 1024*20
 #define UCS_FILE_NAME_SIZE 512
@@ -1680,7 +1678,7 @@ static void TestConvertSafeClone()
     };
 
     /* store the actual sizes of each converter */
-    int32_t actualSizes[LENGTHOF(names)];
+    int32_t actualSizes[uprv_lengthof(names)];
 
     static const int32_t bufferSizes[] = {
         U_CNV_SAFECLONE_BUFFERSIZE,
@@ -1794,8 +1792,8 @@ static void TestConvertSafeClone()
 
     /* Do these cloned converters work at all - shuffle UChars to chars & back again..*/
 
-    for(j = 0; j < LENGTHOF(bufferSizes); ++j) {
-        for (idx = 0; idx < LENGTHOF(names); idx++)
+    for(j = 0; j < uprv_lengthof(bufferSizes); ++j) {
+        for (idx = 0; idx < uprv_lengthof(names); idx++)
         {
             err = U_ZERO_ERROR;
             cnv = ucnv_open(names[idx], &err);
@@ -2519,7 +2517,7 @@ static void testFromTruncatedUTF8(UConverter *utf8Cnv, UConverter *cnv, const ch
 
     memcpy(utf8, charUTF8, charUTF8Length);
 
-    for(i=0; i<LENGTHOF(badUTF8); ++i) {
+    for(i=0; i<uprv_lengthof(badUTF8); ++i) {
         /* truncated sequence? */
         int32_t length=strlen(badUTF8[i]);
         if(length>=(1+U8_COUNT_TRAIL_BYTES(badUTF8[i][0]))) {
@@ -2538,7 +2536,7 @@ static void testFromTruncatedUTF8(UConverter *utf8Cnv, UConverter *cnv, const ch
         ucnv_convertEx(cnv, utf8Cnv,
                        &target, output+sizeof(output),
                        &source, utf8+utf8Length,
-                       pivotBuffer, &pivotSource, &pivotTarget, pivotBuffer+LENGTHOF(pivotBuffer),
+                       pivotBuffer, &pivotSource, &pivotTarget, pivotBuffer+uprv_lengthof(pivotBuffer),
                        TRUE, TRUE, /* reset & flush */
                        &errorCode);
         outputLength=(int32_t)(target-output);
@@ -2583,7 +2581,7 @@ static void testFromBadUTF8(UConverter *utf8Cnv, UConverter *cnv, const char *co
     memcpy(expect, char0, char0Length);
     expectLength=char0Length;
 
-    for(i=0; i<LENGTHOF(badUTF8); ++i) {
+    for(i=0; i<uprv_lengthof(badUTF8); ++i) {
         int32_t length=strlen(badUTF8[i]);
         memcpy(utf8+utf8Length, badUTF8[i], length);
         utf8Length+=length;
@@ -2633,7 +2631,7 @@ static void TestConvertExFromUTF8() {
         return;
     }
 
-    for(i=0; i<LENGTHOF(converterNames); ++i) {
+    for(i=0; i<uprv_lengthof(converterNames); ++i) {
         errorCode=U_ZERO_ERROR;
         cnv=ucnv_open(converterNames[i], &errorCode);
         if(U_FAILURE(errorCode)) {
@@ -2692,7 +2690,7 @@ static void TestConvertExFromUTF8_C5F0() {
         return;
     }
 
-    for(i=0; i<LENGTHOF(converterNames); ++i) {
+    for(i=0; i<uprv_lengthof(converterNames); ++i) {
         errorCode=U_ZERO_ERROR;
         cnv=ucnv_open(converterNames[i], &errorCode);
         ucnv_setFromUCallBack(cnv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC,
@@ -2705,7 +2703,7 @@ static void TestConvertExFromUTF8_C5F0() {
         src=bad_utf8;
         target=dest;
         uprv_memset(dest, 9, sizeof(dest));
-        if(i==LENGTHOF(converterNames)-1) {
+        if(i==uprv_lengthof(converterNames)-1) {
             /* conversion to UTF-8 yields two U+FFFD directly */
             expected=twoFFFD;
             expectedLength=6;
@@ -2722,7 +2720,7 @@ static void TestConvertExFromUTF8_C5F0() {
             cnv, utf8Cnv,
             &target, dest+expectedLength,
             &src, bad_utf8+sizeof(bad_utf8),
-            pivotBuffer, &pivotSource, &pivotTarget, pivotBuffer+LENGTHOF(pivotBuffer),
+            pivotBuffer, &pivotSource, &pivotTarget, pivotBuffer+uprv_lengthof(pivotBuffer),
             TRUE, TRUE, &errorCode);
         if( errorCode!=U_STRING_NOT_TERMINATED_WARNING || src!=bad_utf8+2 ||
             target!=dest+expectedLength || 0!=uprv_memcmp(dest, expected, expectedLength) ||
@@ -2913,7 +2911,7 @@ static void TestLMBCSMaxChar(void) {
     };
     int32_t idx;
 
-    for (idx = 0; idx < LENGTHOF(converter); idx++) {
+    for (idx = 0; idx < uprv_lengthof(converter); idx++) {
         UErrorCode status = U_ZERO_ERROR;
         UConverter *cnv = cnv_open(converter[idx].name, &status);
         if (U_FAILURE(status)) {
@@ -3075,12 +3073,12 @@ testSwap(const char *name, UBool swap) {
     /* convert to EBCDIC */
     pcu=text;
     pc=normal;
-    ucnv_fromUnicode(cnv, &pc, normal+LENGTHOF(normal), &pcu, text+LENGTHOF(text), NULL, TRUE, &errorCode);
+    ucnv_fromUnicode(cnv, &pc, normal+uprv_lengthof(normal), &pcu, text+uprv_lengthof(text), NULL, TRUE, &errorCode);
     normalLength=(int32_t)(pc-normal);
 
     pcu=text;
     pc=swapped;
-    ucnv_fromUnicode(swapCnv, &pc, swapped+LENGTHOF(swapped), &pcu, text+LENGTHOF(text), NULL, TRUE, &errorCode);
+    ucnv_fromUnicode(swapCnv, &pc, swapped+uprv_lengthof(swapped), &pcu, text+uprv_lengthof(text), NULL, TRUE, &errorCode);
     swappedLength=(int32_t)(pc-swapped);
 
     if(U_FAILURE(errorCode)) {
@@ -3113,12 +3111,12 @@ testSwap(const char *name, UBool swap) {
     /* convert back to Unicode (may not roundtrip) */
     pc=normal;
     pu=uNormal;
-    ucnv_toUnicode(cnv, &pu, uNormal+LENGTHOF(uNormal), (const char **)&pc, normal+normalLength, NULL, TRUE, &errorCode);
+    ucnv_toUnicode(cnv, &pu, uNormal+uprv_lengthof(uNormal), (const char **)&pc, normal+normalLength, NULL, TRUE, &errorCode);
     normalLength=(int32_t)(pu-uNormal);
 
     pc=normal;
     pu=uSwapped;
-    ucnv_toUnicode(swapCnv, &pu, uSwapped+LENGTHOF(uSwapped), (const char **)&pc, normal+swappedLength, NULL, TRUE, &errorCode);
+    ucnv_toUnicode(swapCnv, &pu, uSwapped+uprv_lengthof(uSwapped), (const char **)&pc, normal+swappedLength, NULL, TRUE, &errorCode);
     swappedLength=(int32_t)(pu-uSwapped);
 
     if(U_FAILURE(errorCode)) {
@@ -3169,7 +3167,7 @@ TestEBCDICSwapLFNL() {
 
     int i;
 
-    for(i=0; i<LENGTHOF(tests); ++i) {
+    for(i=0; i<uprv_lengthof(tests); ++i) {
         testSwap(tests[i].name, tests[i].swap);
     }
 }
@@ -3200,7 +3198,7 @@ static void TestFromUCountPending(){
         log_data_err("Could not create converter for test3. Error: %s\n", u_errorName(status));
         return;
     }
-    for(i=0; i<LENGTHOF(fromUnicodeTests); ++i) {
+    for(i=0; i<uprv_lengthof(fromUnicodeTests); ++i) {
         char tgt[10];
         char* target = tgt;
         char* targetLimit = target + 10;
@@ -3306,7 +3304,7 @@ TestToUCountPending(){
         return;
     }
     ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_STOP, NULL, oldToUAction, NULL, &status);
-    for(i=0; i<LENGTHOF(toUnicodeTests); ++i) {
+    for(i=0; i<uprv_lengthof(toUnicodeTests); ++i) {
         UChar tgt[20];
         UChar* target = tgt;
         UChar* targetLimit = target + 20;
@@ -3544,7 +3542,7 @@ TestSubstString() {
         log_data_err("ucnv_open(ISO-8859-1) failed - %s\n", u_errorName(errorCode));
         return;
     }
-    ucnv_setSubstString(cnv, sub, LENGTHOF(sub), &errorCode);
+    ucnv_setSubstString(cnv, sub, uprv_lengthof(sub), &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("ucnv_setSubstString(ISO-8859-1, sub[5]) failed - %s\n", u_errorName(errorCode));
     } else {
@@ -3564,7 +3562,7 @@ TestSubstString() {
         log_data_err("ucnv_open(HZ) failed - %s\n", u_errorName(errorCode));
         return;
     }
-    ucnv_setSubstString(cnv, sub, LENGTHOF(sub), &errorCode);
+    ucnv_setSubstString(cnv, sub, uprv_lengthof(sub), &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("ucnv_setSubstString(HZ, sub[5]) failed - %s\n", u_errorName(errorCode));
     } else {
@@ -3649,7 +3647,7 @@ static void TestGetName() {
         "x-UTF-16LE-BOM",           "UTF-16LE,version=1"
     };
     int32_t i;
-    for(i = 0; i < LENGTHOF(names); i += 2) {
+    for(i = 0; i < uprv_lengthof(names); i += 2) {
         UErrorCode errorCode = U_ZERO_ERROR;
         UConverter *cnv = ucnv_open(names[i], &errorCode);
         if(U_SUCCESS(errorCode)) {
@@ -3692,7 +3690,7 @@ static void TestUTFBOM() {
     char bytes[10];
     int32_t i;
 
-    for(i = 0; i < LENGTHOF(names); ++i) {
+    for(i = 0; i < uprv_lengthof(names); ++i) {
         UErrorCode errorCode = U_ZERO_ERROR;
         UConverter *cnv = ucnv_open(names[i], &errorCode);
         int32_t length = 0;
index af0edc5180e5f6d016ef9a80e0777712ef0a1591..76a0e2235cdf027ff17bd888afb5115df3e56cf5 100644 (file)
@@ -50,8 +50,6 @@
 #include "callcoll.h"
 #include "unicode/ustring.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 const char* locales[8] = {
         "en_US",
         "en_GB",
@@ -142,7 +140,7 @@ static void TestG7Locales()
     const UChar *defRules;
     int32_t i, rlen, j, n;
     log_verbose("Testing  ucol_openRules for all the locales\n");
-    for (i = 0; i < LENGTHOF(locales); i++)
+    for (i = 0; i < uprv_lengthof(locales); i++)
     {
         const char *locale = locales[i];
         status = U_ZERO_ERROR;
index d45461cdb129c96f6e4500321ae8f3d91d2e87f6..5bfa16b860e6517720bd117d39cbb323ba1e5d63 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2001, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -39,6 +39,7 @@
 #define _CG7COLLTST
 
 #include "unicode/utypes.h"
+#include "cmemory.h"
 
 #if !UCONFIG_NO_COLLATION
 
index ff3131fefefdc33e3a64823c8e4441e15d6a9d9a..d1f365ae698477844e7464e6dc527056b9562d8b 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -12,6 +12,7 @@
 /* C API TEST FOR GENDER INFO */
 
 #include "unicode/utypes.h"
+#include "cmemory.h"
 
 #if !UCONFIG_NO_FORMATTING
 
@@ -20,8 +21,6 @@
 
 static const UGender kAllFemale[] = {UGENDER_FEMALE, UGENDER_FEMALE};
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 void addGendInfoForTest(TestNode** root);
 static void TestGenderInfo(void);
 
@@ -40,7 +39,7 @@ static void TestGenderInfo(void) {
     log_err_status(status, "Fail to create UGenderInfo - %s (Are you missing data?)", u_errorName(status));
     return;
   }
-  actual = ugender_getListGender(actual_gi, kAllFemale, LENGTHOF(kAllFemale), &status);
+  actual = ugender_getListGender(actual_gi, kAllFemale, uprv_lengthof(kAllFemale), &status);
   if (U_FAILURE(status)) {
     log_err("Fail to get gender of list - %s\n", u_errorName(status));
     return;
index 37f3c61b47a8f548d79c5c459a4199d2d329b424..edd820fbec75334e44d2f98574b08dc2aa922578 100644 (file)
@@ -36,7 +36,6 @@
 #include "unicode/uldnames.h"
 #include "unicode/parseerr.h" /* may not be included with some uconfig switches */
 #include "udbgutil.h"
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 static void TestNullDefault(void);
 static void TestNonexistentLanguageExemplars(void);
@@ -665,7 +664,7 @@ static void TestDisplayNames()
 
     /* test that the default locale has a display name for its own language */
     errorCode=U_ZERO_ERROR;
-    length=uloc_getDisplayLanguage(NULL, NULL, buffer, LENGTHOF(buffer), &errorCode);
+    length=uloc_getDisplayLanguage(NULL, NULL, buffer, uprv_lengthof(buffer), &errorCode);
     if(U_FAILURE(errorCode) || (length<=3 && buffer[0]<=0x7f)) {
         /* check <=3 to reject getting the language code as a display name */
         log_data_err("unable to get a display string for the language of the default locale - %s (Are you missing data?)\n", u_errorName(errorCode));
@@ -673,14 +672,14 @@ static void TestDisplayNames()
 
     /* test that we get the language code itself for an unknown language, and a default warning */
     errorCode=U_ZERO_ERROR;
-    length=uloc_getDisplayLanguage("qq", "rr", buffer, LENGTHOF(buffer), &errorCode);
+    length=uloc_getDisplayLanguage("qq", "rr", buffer, uprv_lengthof(buffer), &errorCode);
     if(errorCode!=U_USING_DEFAULT_WARNING || length!=2 || buffer[0]!=0x71 || buffer[1]!=0x71) {
         log_err("error getting the display string for an unknown language - %s\n", u_errorName(errorCode));
     }
     
     /* test that we get a default warning for a display name where one component is unknown (4255) */
     errorCode=U_ZERO_ERROR;
-    length=uloc_getDisplayName("qq_US_POSIX", "en_US", buffer, LENGTHOF(buffer), &errorCode);
+    length=uloc_getDisplayName("qq_US_POSIX", "en_US", buffer, uprv_lengthof(buffer), &errorCode);
     if(errorCode!=U_USING_DEFAULT_WARNING) {
         log_err("error getting the display name for a locale with an unknown language - %s\n", u_errorName(errorCode));
     }
@@ -698,9 +697,9 @@ static void TestDisplayNames()
             "\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03b9\\u03ba\\u03ac (\\u0397\\u03bc\\u03b5\\u03c1\\u03bf\\u03bb\\u03cc\\u03b3\\u03b9\\u03bf=\\u0399\\u03b1\\u03c0\\u03c9\\u03bd\\u03b9\\u03ba\\u03cc \\u03b7\\u03bc\\u03b5\\u03c1\\u03bf\\u03bb\\u03cc\\u03b3\\u03b9\\u03bf, \\u03a3\\u03b5\\u03b9\\u03c1\\u03ac \\u03c4\\u03b1\\u03be\\u03b9\\u03bd\\u03cc\\u03bc\\u03b7\\u03c3\\u03b7\\u03c2=\\u03a0\\u03b1\\u03c1\\u03b1\\u03b4\\u03bf\\u03c3\\u03b9\\u03b1\\u03ba\\u03ae \\u03c3\\u03b5\\u03b9\\u03c1\\u03ac \\u03c4\\u03b1\\u03be\\u03b9\\u03bd\\u03cc\\u03bc\\u03b7\\u03c3\\u03b7\\u03c2)" };
         UChar *expectBuffer;
 
-        for(i=0;i<LENGTHOF(testL);i++) {
+        for(i=0;i<uprv_lengthof(testL);i++) {
             errorCode = U_ZERO_ERROR;
-            uloc_getDisplayName(aLocale, testL[i], buffer, LENGTHOF(buffer), &errorCode);
+            uloc_getDisplayName(aLocale, testL[i], buffer, uprv_lengthof(buffer), &errorCode);
             if(U_FAILURE(errorCode)) {
                 log_err("FAIL in uloc_getDisplayName(%s,%s,..) -> %s\n", aLocale, testL[i], u_errorName(errorCode));
             } else {
@@ -732,7 +731,7 @@ static void TestDisplayNames()
         if(ec==U_BUFFER_OVERFLOW_ERROR) {
             ec=U_ZERO_ERROR;
         }
-        len=uloc_getDisplayName(locale, displayLocale, result, LENGTHOF(result), &ec);
+        len=uloc_getDisplayName(locale, displayLocale, result, uprv_lengthof(result), &ec);
         if(U_FAILURE(ec)) {
             log_err("uloc_getDisplayName(%s, %s...) returned error: %s",
                     locale, displayLocale, u_errorName(ec));
@@ -2779,7 +2778,7 @@ static void TestCalendar() {
         log_err_status(status, "Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
         return;
     }
-    for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+    for (i=0; i<uprv_lengthof(LOCALE_ALIAS); i++) {
         const char* oldLoc = LOCALE_ALIAS[i][0];
         const char* newLoc = LOCALE_ALIAS[i][1];
         UCalendar* c1 = NULL;
@@ -2815,7 +2814,7 @@ static void TestDateFormat() {
         log_err_status(status, "Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
         return;
     }
-    for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+    for (i=0; i<uprv_lengthof(LOCALE_ALIAS); i++) {
         const char* oldLoc = LOCALE_ALIAS[i][0];
         const char* newLoc = LOCALE_ALIAS[i][1];
         UDateFormat* df1 = NULL;
@@ -2858,7 +2857,7 @@ static void TestCollation() {
         log_err_status(status, "Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
         return;
     }
-    for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+    for (i=0; i<uprv_lengthof(LOCALE_ALIAS); i++) {
         const char* oldLoc = LOCALE_ALIAS[i][0];
         const char* newLoc = LOCALE_ALIAS[i][1];
         UCollator* c1 = NULL;
@@ -2982,7 +2981,7 @@ static void  TestULocale() {
         log_err_status(status, "Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
         return;
     }
-    for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+    for (i=0; i<uprv_lengthof(LOCALE_ALIAS); i++) {
         const char* oldLoc = LOCALE_ALIAS[i][0];
         const char* newLoc = LOCALE_ALIAS[i][1];
         UChar name1[256], name2[256];
@@ -3028,7 +3027,7 @@ static void TestUResourceBundle() {
         return;
     }
     resIndex = ures_open(NULL,"res_index", &status);
-    for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+    for (i=0; i<uprv_lengthof(LOCALE_ALIAS); i++) {
 
         const char* oldLoc = LOCALE_ALIAS[i][0];
         const char* newLoc = LOCALE_ALIAS[i][1];
@@ -3073,7 +3072,7 @@ static void TestDisplayName() {
     int32_t capacity = 256;
     int i =0;
     int j=0;
-    for (i=0; i<LENGTHOF(LOCALE_ALIAS); i++) {
+    for (i=0; i<uprv_lengthof(LOCALE_ALIAS); i++) {
         const char* oldLoc = LOCALE_ALIAS[i][0];
         const char* newLoc = LOCALE_ALIAS[i][1];
         UErrorCode status = U_ZERO_ERROR;
index a1351440b1160f3bf8bb781293d86928c4b1ddd5..69c45335a5057b1cc279a8e34b509065ba420575 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************
  *
@@ -27,8 +27,7 @@
 #include "cintltst.h"
 #include "cmsgtst.h"
 #include "cformtst.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 static const char* const txt_testCasePatterns[] = {
    "Quotes '', '{', a {0,number,integer} '{'0}",
@@ -1128,7 +1127,7 @@ static void TestMessageWithUnusedArgNumber() {
 
     U_STRING_INIT(pattern, "abc {1} def", 11);
     U_STRING_INIT(expected, "abc y def", 9);
-    length = u_formatMessage("en", pattern, -1, result, LENGTHOF(result), &errorCode, x, y);
+    length = u_formatMessage("en", pattern, -1, result, uprv_lengthof(result), &errorCode, x, y);
     if (U_FAILURE(errorCode) || length != u_strlen(expected) || u_strcmp(result, expected) != 0) {
         log_err("u_formatMessage(pattern with only {1}, 2 args) failed: result length %d, UErrorCode %s \n",
                 (int)length, u_errorName(errorCode));
index 1979167d8debea508df78e6e505919911a924d5e..27b78f8be307576aab6ae321cfee7e0a06b0867e 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -18,6 +18,7 @@
 #include "unicode/unorm.h"
 #include "unicode/utf16.h"
 #include "cintltst.h"
+#include "cmemory.h"
 
 #if !UCONFIG_NO_NORMALIZATION
 
@@ -28,8 +29,6 @@
 #include "unicode/unorm.h"
 #include "cnormtst.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof ((array)[0]))
-
 static void
 TestAPI(void);
 
@@ -189,14 +188,14 @@ static void TestNormCases(UNormalizationMode mode,
         {
             status=U_ZERO_ERROR;
         }
-        length2=unorm_normalize(source, u_strlen(source), mode, 0, result, LENGTHOF(result), &status); 
+        length2=unorm_normalize(source, u_strlen(source), mode, 0, result, uprv_lengthof(result), &status); 
         if(U_FAILURE(status) || neededLen!=length2) {
             log_data_err("ERROR in unorm_normalize(%s/NUL) at %s:  %s - (Are you missing data?)\n",
                          modeStrings[mode], austrdup(source), myErrorName(status));
         } else {
             assertEqual(result, cases[x][expIndex], x);
         }
-        length2=unorm_normalize(source, -1, mode, 0, result, LENGTHOF(result), &status); 
+        length2=unorm_normalize(source, -1, mode, 0, result, uprv_lengthof(result), &status); 
         if(U_FAILURE(status) || neededLen!=length2) {
             log_data_err("ERROR in unorm_normalize(%s/srcLength) at %s:  %s - (Are you missing data?)\n",
                          modeStrings[mode], austrdup(source), myErrorName(status));
@@ -208,23 +207,23 @@ static void TestNormCases(UNormalizationMode mode,
 }
 
 void TestDecomp() {
-    TestNormCases(UNORM_NFD, canonTests, LENGTHOF(canonTests));
+    TestNormCases(UNORM_NFD, canonTests, uprv_lengthof(canonTests));
 }
 
 void TestCompatDecomp() {
-    TestNormCases(UNORM_NFKD, compatTests, LENGTHOF(compatTests));
+    TestNormCases(UNORM_NFKD, compatTests, uprv_lengthof(compatTests));
 }
 
 void TestCanonDecompCompose() {
-    TestNormCases(UNORM_NFC, canonTests, LENGTHOF(canonTests));
+    TestNormCases(UNORM_NFC, canonTests, uprv_lengthof(canonTests));
 }
 
 void TestCompatDecompCompose() {
-    TestNormCases(UNORM_NFKC, compatTests, LENGTHOF(compatTests));
+    TestNormCases(UNORM_NFKC, compatTests, uprv_lengthof(compatTests));
 }
 
 void TestFCD() {
-    TestNormCases(UNORM_FCD, fcdTests, LENGTHOF(fcdTests));
+    TestNormCases(UNORM_FCD, fcdTests, uprv_lengthof(fcdTests));
 }
 
 static void assertEqual(const UChar* result, const char* expected, int32_t index)
@@ -474,7 +473,7 @@ static void TestQuickCheckStringResult()
   UChar *c = NULL;
   UErrorCode error = U_ZERO_ERROR;
 
-  for (count = 0; count < LENGTHOF(canonTests); count ++)
+  for (count = 0; count < uprv_lengthof(canonTests); count ++)
   {
     d = CharsToUChars(canonTests[count][1]);
     c = CharsToUChars(canonTests[count][2]);
@@ -496,7 +495,7 @@ static void TestQuickCheckStringResult()
     free(c);
   }
 
-  for (count = 0; count < LENGTHOF(compatTests); count ++)
+  for (count = 0; count < uprv_lengthof(compatTests); count ++)
   {
     d = CharsToUChars(compatTests[count][1]);
     c = CharsToUChars(compatTests[count][2]);
@@ -578,7 +577,7 @@ static void TestIsNormalized(void) {
     }
 
     /* specific cases */
-    for(i=0; i<LENGTHOF(notNFC); ++i) {
+    for(i=0; i<uprv_lengthof(notNFC); ++i) {
         errorCode=U_ZERO_ERROR;
         if(unorm_isNormalized(notNFC[i], -1, UNORM_NFC, &errorCode) || U_FAILURE(errorCode)) {
             log_data_err("error: isNormalized(notNFC[%d], NFC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode));
@@ -588,7 +587,7 @@ static void TestIsNormalized(void) {
             log_data_err("error: isNormalized(notNFC[%d], NFKC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode));
         }
     }
-    for(i=0; i<LENGTHOF(notNFKC); ++i) {
+    for(i=0; i<uprv_lengthof(notNFKC); ++i) {
         errorCode=U_ZERO_ERROR;
         if(unorm_isNormalized(notNFKC[i], -1, UNORM_NFKC, &errorCode) || U_FAILURE(errorCode)) {
             log_data_err("error: isNormalized(notNFKC[%d], NFKC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode));
@@ -1332,9 +1331,9 @@ TestFCNFKCClosure(void) {
     UErrorCode errorCode;
     int32_t i, length;
 
-    for(i=0; i<LENGTHOF(tests); ++i) {
+    for(i=0; i<uprv_lengthof(tests); ++i) {
         errorCode=U_ZERO_ERROR;
-        length=u_getFC_NFKC_Closure(tests[i].c, buffer, LENGTHOF(buffer), &errorCode);
+        length=u_getFC_NFKC_Closure(tests[i].c, buffer, uprv_lengthof(buffer), &errorCode);
         if(U_FAILURE(errorCode) || length!=u_strlen(buffer) || 0!=u_strcmp(tests[i].s, buffer)) {
             log_data_err("u_getFC_NFKC_Closure(U+%04lx) is wrong (%s) - (Are you missing data?)\n", tests[i].c, u_errorName(errorCode));
         }
@@ -1342,12 +1341,12 @@ TestFCNFKCClosure(void) {
 
     /* error handling */
     errorCode=U_ZERO_ERROR;
-    length=u_getFC_NFKC_Closure(0x5c, NULL, LENGTHOF(buffer), &errorCode);
+    length=u_getFC_NFKC_Closure(0x5c, NULL, uprv_lengthof(buffer), &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
         log_err("u_getFC_NFKC_Closure(dest=NULL) is wrong (%s)\n", u_errorName(errorCode));
     }
 
-    length=u_getFC_NFKC_Closure(0x5c, buffer, LENGTHOF(buffer), &errorCode);
+    length=u_getFC_NFKC_Closure(0x5c, buffer, uprv_lengthof(buffer), &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
         log_err("u_getFC_NFKC_Closure(U_FAILURE) is wrong (%s)\n", u_errorName(errorCode));
     }
@@ -1406,7 +1405,7 @@ TestQuickCheckPerCP() {
             log_data_err("u_getIntPropertyValue(NFKD)=%d != %d=unorm_quickCheck(NFKD) for U+%04x - (Are you missing data?)\n", qc1, qc2, c);
         }
 
-        length=unorm_normalize(s, length, UNORM_NFD, 0, nfd, LENGTHOF(nfd), &errorCode);
+        length=unorm_normalize(s, length, UNORM_NFD, 0, nfd, uprv_lengthof(nfd), &errorCode);
         /* length-length == 0 is used to get around a compiler warning. */
         U16_GET(nfd, 0, length-length, length, lead);
         U16_GET(nfd, 0, length-1, length, trail);
@@ -1456,12 +1455,12 @@ TestComposition(void) {
     UErrorCode errorCode;
     int32_t i, length;
 
-    for(i=0; i<LENGTHOF(cases); ++i) {
+    for(i=0; i<uprv_lengthof(cases); ++i) {
         errorCode=U_ZERO_ERROR;
         length=unorm_normalize(
                     cases[i].input, -1,
                     cases[i].mode, cases[i].options,
-                    output, LENGTHOF(output),
+                    output, uprv_lengthof(output),
                     &errorCode);
         if( U_FAILURE(errorCode) ||
             length!=u_strlen(cases[i].expect) ||
@@ -1484,17 +1483,17 @@ TestGetDecomposition() {
         return;
     }
 
-    length=unorm2_getDecomposition(n2, 0x20, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getDecomposition(n2, 0x20, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length>=0) {
         log_err("unorm2_getDecomposition(fcc, space) failed\n");
     }
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getDecomposition(n2, 0xe4, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getDecomposition(n2, 0xe4, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x61 || decomp[1]!=0x308 || decomp[2]!=0) {
         log_err("unorm2_getDecomposition(fcc, a-umlaut) failed\n");
     }
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getDecomposition(n2, 0xac01, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getDecomposition(n2, 0xac01, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=3 || decomp[0]!=0x1100 || decomp[1]!=0x1161 || decomp[2]!=0x11a8 || decomp[3]!=0) {
         log_err("unorm2_getDecomposition(fcc, Hangul syllable U+AC01) failed\n");
     }
@@ -1531,35 +1530,35 @@ TestGetRawDecomposition() {
      * without recursive decomposition.
      */
 
-    length=unorm2_getRawDecomposition(n2, 0x20, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getRawDecomposition(n2, 0x20, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length>=0) {
         log_err("unorm2_getDecomposition(nfkc, space) failed\n");
     }
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getRawDecomposition(n2, 0xe4, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getRawDecomposition(n2, 0xe4, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x61 || decomp[1]!=0x308 || decomp[2]!=0) {
         log_err("unorm2_getDecomposition(nfkc, a-umlaut) failed\n");
     }
     /* U+1E08 LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE */
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getRawDecomposition(n2, 0x1e08, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getRawDecomposition(n2, 0x1e08, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0xc7 || decomp[1]!=0x301 || decomp[2]!=0) {
         log_err("unorm2_getDecomposition(nfkc, c-cedilla-acute) failed\n");
     }
     /* U+212B ANGSTROM SIGN */
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getRawDecomposition(n2, 0x212b, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getRawDecomposition(n2, 0x212b, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=1 || decomp[0]!=0xc5 || decomp[1]!=0) {
         log_err("unorm2_getDecomposition(nfkc, angstrom sign) failed\n");
     }
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getRawDecomposition(n2, 0xac00, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getRawDecomposition(n2, 0xac00, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x1100 || decomp[1]!=0x1161 || decomp[2]!=0) {
         log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC00) failed\n");
     }
     /* A Hangul LVT syllable has a raw decomposition of an LV syllable + T. */
     errorCode=U_ZERO_ERROR;
-    length=unorm2_getRawDecomposition(n2, 0xac01, decomp, LENGTHOF(decomp), &errorCode);
+    length=unorm2_getRawDecomposition(n2, 0xac01, decomp, uprv_lengthof(decomp), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0xac00 || decomp[1]!=0x11a8 || decomp[2]!=0) {
         log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC01) failed\n");
     }
@@ -1600,7 +1599,7 @@ TestAppendRestoreMiddle() {
      * (Let it modify the destination buffer before reallocating internally.)
      */
     length=unorm2_append(n2, a, -1, 6, b, -1, &errorCode);
-    if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=LENGTHOF(expected)) {
+    if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=uprv_lengthof(expected)) {
         log_err("unorm2_append(preflight) returned wrong length of %d\n", (int)length);
         return;
     }
@@ -1610,8 +1609,8 @@ TestAppendRestoreMiddle() {
         return;
     }
     errorCode=U_ZERO_ERROR;
-    length=unorm2_append(n2, a, -1, LENGTHOF(a), b, -1, &errorCode);
-    if(U_FAILURE(errorCode) || length!=LENGTHOF(expected) || 0!=u_memcmp(a, expected, length)) {
+    length=unorm2_append(n2, a, -1, uprv_lengthof(a), b, -1, &errorCode);
+    if(U_FAILURE(errorCode) || length!=uprv_lengthof(expected) || 0!=u_memcmp(a, expected, length)) {
         log_err("unorm2_append(real) failed - %s, length %d\n", u_errorName(errorCode), (int)length);
         return;
     }
@@ -1632,7 +1631,7 @@ TestGetEasyToUseInstance() {
         log_err_status(errorCode, "unorm2_getNFCInstance() failed: %s\n", u_errorName(errorCode));
         return;
     }
-    length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode);
+    length=unorm2_normalize(n2, in, uprv_lengthof(in), out, uprv_lengthof(out), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || out[0]!=0xa0 || out[1]!=0x1e08) {
         log_err("unorm2_getNFCInstance() did not return an NFC instance (normalized length=%d; %s)\n",
                 (int)length, u_errorName(errorCode));
@@ -1644,7 +1643,7 @@ TestGetEasyToUseInstance() {
         log_err_status(errorCode, "unorm2_getNFDInstance() failed: %s\n", u_errorName(errorCode));
         return;
     }
-    length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode);
+    length=unorm2_normalize(n2, in, uprv_lengthof(in), out, uprv_lengthof(out), &errorCode);
     if(U_FAILURE(errorCode) || length!=4 || out[0]!=0xa0 || out[1]!=0x43 || out[2]!=0x327 || out[3]!=0x301) {
         log_err("unorm2_getNFDInstance() did not return an NFD instance (normalized length=%d; %s)\n",
                 (int)length, u_errorName(errorCode));
@@ -1656,7 +1655,7 @@ TestGetEasyToUseInstance() {
         log_err_status(errorCode, "unorm2_getNFKCInstance() failed: %s\n", u_errorName(errorCode));
         return;
     }
-    length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode);
+    length=unorm2_normalize(n2, in, uprv_lengthof(in), out, uprv_lengthof(out), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || out[0]!=0x20 || out[1]!=0x1e08) {
         log_err("unorm2_getNFKCInstance() did not return an NFKC instance (normalized length=%d; %s)\n",
                 (int)length, u_errorName(errorCode));
@@ -1668,7 +1667,7 @@ TestGetEasyToUseInstance() {
         log_err_status(errorCode, "unorm2_getNFKDInstance() failed: %s\n", u_errorName(errorCode));
         return;
     }
-    length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode);
+    length=unorm2_normalize(n2, in, uprv_lengthof(in), out, uprv_lengthof(out), &errorCode);
     if(U_FAILURE(errorCode) || length!=4 || out[0]!=0x20 || out[1]!=0x43 || out[2]!=0x327 || out[3]!=0x301) {
         log_err("unorm2_getNFKDInstance() did not return an NFKD instance (normalized length=%d; %s)\n",
                 (int)length, u_errorName(errorCode));
@@ -1680,7 +1679,7 @@ TestGetEasyToUseInstance() {
         log_err_status(errorCode, "unorm2_getNFKCCasefoldInstance() failed: %s\n", u_errorName(errorCode));
         return;
     }
-    length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode);
+    length=unorm2_normalize(n2, in, uprv_lengthof(in), out, uprv_lengthof(out), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || out[0]!=0x20 || out[1]!=0x1e09) {
         log_err("unorm2_getNFKCCasefoldInstance() did not return an NFKC_Casefold instance (normalized length=%d; %s)\n",
                 (int)length, u_errorName(errorCode));
index bd7193dd301c5a98473c0de2313b6cb4c4e8ad36..0e8fd482a9a77a48f7ce8902eb40f1fa14bd5f9e 100644 (file)
@@ -28,8 +28,6 @@
 #include "crestst.h"
 #include "unicode/ctest.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static void TestOpenDirect(void);
 static void TestFallback(void);
 static void TestTable32(void);
@@ -714,7 +712,7 @@ TestTable32(void) {
     }
 
     /* search for some items by key */
-    for(i=0; i<LENGTHOF(testcases); ++i) {
+    for(i=0; i<uprv_lengthof(testcases); ++i) {
         item=ures_getByKey(res, testcases[i].key, item, &errorCode);
         if(U_FAILURE(errorCode)) {
             log_err("unable to find the key \"%s\" in testdata/testtable32.res - %s\n",
index 41fc542611cc23539972323da059b1bda013a83a..d618f7dd8d4708468a39914fde1d251febd52b57 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2002-2013, International Business Machines
+*   Copyright (C) 2002-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -26,8 +26,6 @@
 #include "cmemory.h"
 #include "cintltst.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* test string case mapping functions --------------------------------------- */
 
 static void
@@ -891,9 +889,9 @@ TestUCaseMapToTitle(void) {
     }
 
     /* Use default UBreakIterator: Word breaks. */
-    length=ucasemap_toTitle(csm, buffer, LENGTHOF(buffer), beforeTitle, LENGTHOF(beforeTitle), &errorCode);
+    length=ucasemap_toTitle(csm, buffer, uprv_lengthof(buffer), beforeTitle, uprv_lengthof(beforeTitle), &errorCode);
     if( U_FAILURE(errorCode) ||
-        length!=LENGTHOF(titleWord) ||
+        length!=uprv_lengthof(titleWord) ||
         0!=u_memcmp(buffer, titleWord, length) ||
         buffer[length]!=0
     ) {
@@ -913,9 +911,9 @@ TestUCaseMapToTitle(void) {
         return;
     }
 
-    length=ucasemap_toTitle(csm, buffer, LENGTHOF(buffer), beforeTitle, LENGTHOF(beforeTitle), &errorCode);
+    length=ucasemap_toTitle(csm, buffer, uprv_lengthof(buffer), beforeTitle, uprv_lengthof(beforeTitle), &errorCode);
     if( U_FAILURE(errorCode) ||
-        length!=LENGTHOF(titleWordNoAdjust) ||
+        length!=uprv_lengthof(titleWordNoAdjust) ||
         0!=u_memcmp(buffer, titleWordNoAdjust, length) ||
         buffer[length]!=0
     ) {
@@ -949,18 +947,18 @@ TestUCaseMapToTitle(void) {
     }
 
     /* Use the sentence break iterator with the option. Preflight first. */
-    length=ucasemap_toTitle(csm, NULL, 0, beforeTitle, LENGTHOF(beforeTitle), &errorCode);
+    length=ucasemap_toTitle(csm, NULL, 0, beforeTitle, uprv_lengthof(beforeTitle), &errorCode);
     if( errorCode!=U_BUFFER_OVERFLOW_ERROR ||
-        length!=LENGTHOF(titleSentNoLower)
+        length!=uprv_lengthof(titleSentNoLower)
     ) {
         log_err("ucasemap_toTitle(preflight sentence break iterator, no lowercasing)=%ld failed - %s\n", (long)length, u_errorName(errorCode));
     }
 
     errorCode=U_ZERO_ERROR;
     buffer[0]=0;
-    length=ucasemap_toTitle(csm, buffer, LENGTHOF(buffer), beforeTitle, LENGTHOF(beforeTitle), &errorCode);
+    length=ucasemap_toTitle(csm, buffer, uprv_lengthof(buffer), beforeTitle, uprv_lengthof(beforeTitle), &errorCode);
     if( U_FAILURE(errorCode) ||
-        length!=LENGTHOF(titleSentNoLower) ||
+        length!=uprv_lengthof(titleSentNoLower) ||
         0!=u_memcmp(buffer, titleSentNoLower, length) ||
         buffer[length]!=0
     ) {
@@ -973,8 +971,8 @@ TestUCaseMapToTitle(void) {
         int32_t utf8BeforeTitleLength, utf8TitleSentNoLowerLength;
 
         errorCode=U_ZERO_ERROR;
-        u_strToUTF8(utf8BeforeTitle, (int32_t)sizeof(utf8BeforeTitle), &utf8BeforeTitleLength, beforeTitle, LENGTHOF(beforeTitle), &errorCode);
-        u_strToUTF8(utf8TitleSentNoLower, (int32_t)sizeof(utf8TitleSentNoLower), &utf8TitleSentNoLowerLength, titleSentNoLower, LENGTHOF(titleSentNoLower), &errorCode);
+        u_strToUTF8(utf8BeforeTitle, (int32_t)sizeof(utf8BeforeTitle), &utf8BeforeTitleLength, beforeTitle, uprv_lengthof(beforeTitle), &errorCode);
+        u_strToUTF8(utf8TitleSentNoLower, (int32_t)sizeof(utf8TitleSentNoLower), &utf8TitleSentNoLowerLength, titleSentNoLower, uprv_lengthof(titleSentNoLower), &errorCode);
 
         length=ucasemap_utf8ToTitle(csm, utf8, (int32_t)sizeof(utf8), utf8BeforeTitle, utf8BeforeTitleLength, &errorCode);
         if( U_FAILURE(errorCode) ||
index 7ab989ab359bb372d79be2a744262da9618abccf..bdd5326e39a0907b61da42471ec9ccacd6e1bddd 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (C) 1998-2011, International Business Machines Corporation
+* Copyright (C) 1998-2014, International Business Machines Corporation
 * and others.  All Rights Reserved.
 **********************************************************************
 *
@@ -20,8 +20,6 @@
 #include "cintltst.h"
 #include "cmemory.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static void TestAPI(void);
 void addCStringTest(TestNode** root);
 
@@ -249,10 +247,10 @@ TestInvariant() {
             }
 
             errorCode=U_ZERO_ERROR;
-            length=ucnv_toUChars(cnv, us, LENGTHOF(us), invariantChars, -1, &errorCode);
+            length=ucnv_toUChars(cnv, us, uprv_lengthof(us), invariantChars, -1, &errorCode);
             if(U_FAILURE(errorCode)) {
                 log_err("ucnv_toUChars(invariantChars) failed - %s\n", u_errorName(errorCode));
-            } else if(length!=LENGTHOF(invariantUChars)-1 || u_strcmp(us, invariantUChars)!=0) {
+            } else if(length!=uprv_lengthof(invariantUChars)-1 || u_strcmp(us, invariantUChars)!=0) {
                 log_err("ucnv_toUChars(invariantChars) failed\n");
             }
 
@@ -280,7 +278,7 @@ TestInvariant() {
         }
     }
 
-    for(i=0; i<LENGTHOF(nonASCIIUChars); ++i) {
+    for(i=0; i<uprv_lengthof(nonASCIIUChars); ++i) {
         if(uprv_isInvariantUString(nonASCIIUChars+i, 1)) {
             log_err("uprv_isInvariantUString(nonASCIIUChars[%d]) failed\n", i);
         }
@@ -323,7 +321,7 @@ TestCompareInvEbcdicAsAscii() {
         { "\x81\x81\x82", "aab" }
     };
     int32_t i;
-    for(i=1; i<LENGTHOF(invStrings); ++i) {
+    for(i=1; i<uprv_lengthof(invStrings); ++i) {
         int32_t diff1, diff2;
         /* compare previous vs. current */
         diff1=getSign(uprv_compareInvEbcdicAsAscii(invStrings[i-1][0], invStrings[i][0]));
index 0d85599d7189682f2b34435c3a8b45f0f5fa0124..159c38ca76476331f7eaa16c327d969ffa328e36 100644 (file)
@@ -9,8 +9,7 @@
 #include "unicode/uchar.h"
 #include "cintltst.h"
 #include "cucdapi.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
+#include "cmemory.h"
 
 void TestUScriptCodeAPI(){
     int i =0;
@@ -241,7 +240,7 @@ void TestUScriptCodeAPI(){
         UErrorCode status = U_ZERO_ERROR;
         UBool passed = TRUE;
 
-        for(i=0; i<LENGTHOF(codepoints); ++i){
+        for(i=0; i<uprv_lengthof(codepoints); ++i){
             code = uscript_getScript(codepoints[i],&status);
             if(U_SUCCESS(status)){
                 if( code != expected[i] ||
@@ -361,7 +360,7 @@ void TestUScriptCodeAPI(){
             "Ahom", "Hatr", "Modi", "Mult", "Pauc", "Sidd"
         };
         int32_t j = 0;
-        if(LENGTHOF(expectedLong)!=(USCRIPT_CODE_LIMIT-USCRIPT_BALINESE)) {
+        if(uprv_lengthof(expectedLong)!=(USCRIPT_CODE_LIMIT-USCRIPT_BALINESE)) {
             log_err("need to add new script codes in cucdapi.c!\n");
             return;
         }
@@ -375,11 +374,11 @@ void TestUScriptCodeAPI(){
                 log_err("uscript_getShortName failed for code %i: %s!=%s\n", i, name, expectedShort[j]);
             }
         }
-        for(i=0; i<LENGTHOF(expectedLong); i++){
+        for(i=0; i<uprv_lengthof(expectedLong); i++){
             UScriptCode fillIn[5] = {USCRIPT_INVALID_CODE};
             UErrorCode status = U_ZERO_ERROR;
             int32_t len = 0;
-            len = uscript_getCode(expectedShort[i], fillIn, LENGTHOF(fillIn), &status);
+            len = uscript_getCode(expectedShort[i], fillIn, uprv_lengthof(fillIn), &status);
             if(U_FAILURE(status)){
                 log_err("uscript_getCode failed for script name %s. Error: %s\n",expectedShort[i], u_errorName(status));
             }
@@ -473,13 +472,13 @@ void TestGetScriptExtensions() {
 
     /* errors and overflows */
     errorCode=U_PARSE_ERROR;
-    length=uscript_getScriptExtensions(0x0640, scripts, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(0x0640, scripts, uprv_lengthof(scripts), &errorCode);
     if(errorCode!=U_PARSE_ERROR) {
         log_err("uscript_getScriptExtensions(U+0640, U_PARSE_ERROR) did not preserve the UErrorCode - %s\n",
               u_errorName(errorCode));
     }
     errorCode=U_ZERO_ERROR;
-    length=uscript_getScriptExtensions(0x0640, NULL, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(0x0640, NULL, uprv_lengthof(scripts), &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
         log_err("uscript_getScriptExtensions(U+0640, NULL) did not set U_ILLEGAL_ARGUMENT_ERROR - %s\n",
               u_errorName(errorCode));
@@ -512,13 +511,13 @@ void TestGetScriptExtensions() {
 
     /* invalid code points */
     errorCode=U_ZERO_ERROR;
-    length=uscript_getScriptExtensions(-1, scripts, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(-1, scripts, uprv_lengthof(scripts), &errorCode);
     if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_UNKNOWN) {
         log_err("uscript_getScriptExtensions(-1)=%d does not return {UNKNOWN} - %s\n",
               (int)length, u_errorName(errorCode));
     }
     errorCode=U_ZERO_ERROR;
-    length=uscript_getScriptExtensions(0x110000, scripts, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(0x110000, scripts, uprv_lengthof(scripts), &errorCode);
     if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_UNKNOWN) {
         log_err("uscript_getScriptExtensions(0x110000)=%d does not return {UNKNOWN} - %s\n",
               (int)length, u_errorName(errorCode));
@@ -532,7 +531,7 @@ void TestGetScriptExtensions() {
               (int)length, u_errorName(errorCode));
     }
     errorCode=U_ZERO_ERROR;
-    length=uscript_getScriptExtensions(0x0640, scripts, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(0x0640, scripts, uprv_lengthof(scripts), &errorCode);
     if(U_FAILURE(errorCode) || length<3 ||
             !scriptsContain(scripts, length, USCRIPT_ARABIC) ||
             !scriptsContain(scripts, length, USCRIPT_SYRIAC) ||
@@ -541,13 +540,13 @@ void TestGetScriptExtensions() {
               (int)length, u_errorName(errorCode));
     }
     errorCode=U_ZERO_ERROR;
-    length=uscript_getScriptExtensions(0xfdf2, scripts, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(0xfdf2, scripts, uprv_lengthof(scripts), &errorCode);
     if(U_FAILURE(errorCode) || length!=2 || scripts[0]!=USCRIPT_ARABIC || scripts[1]!=USCRIPT_THAANA) {
         log_err("uscript_getScriptExtensions(U+FDF2)=%d failed - %s\n",
               (int)length, u_errorName(errorCode));
     }
     errorCode=U_ZERO_ERROR;
-    length=uscript_getScriptExtensions(0xff65, scripts, LENGTHOF(scripts), &errorCode);
+    length=uscript_getScriptExtensions(0xff65, scripts, uprv_lengthof(scripts), &errorCode);
     if(U_FAILURE(errorCode) || length!=6 || scripts[0]!=USCRIPT_BOPOMOFO || scripts[5]!=USCRIPT_YI) {
         log_err("uscript_getScriptExtensions(U+FF65)=%d failed - %s\n",
               (int)length, u_errorName(errorCode));
@@ -559,7 +558,7 @@ void TestScriptMetadataAPI() {
     UErrorCode errorCode=U_ZERO_ERROR;
     UChar sample[8];
 
-    if(uscript_getSampleString(USCRIPT_LATIN, sample, LENGTHOF(sample), &errorCode)!=1 ||
+    if(uscript_getSampleString(USCRIPT_LATIN, sample, uprv_lengthof(sample), &errorCode)!=1 ||
             U_FAILURE(errorCode) ||
             uscript_getScript(sample[0], &errorCode)!=USCRIPT_LATIN ||
             sample[1]!=0) {
@@ -572,7 +571,7 @@ void TestScriptMetadataAPI() {
         log_err("uscript_getSampleString(Latn, capacity=0) failed - %s\n", u_errorName(errorCode));
     }
     errorCode=U_ZERO_ERROR;
-    if(uscript_getSampleString(USCRIPT_INVALID_CODE, sample, LENGTHOF(sample), &errorCode)!=0 ||
+    if(uscript_getSampleString(USCRIPT_INVALID_CODE, sample, uprv_lengthof(sample), &errorCode)!=0 ||
             U_FAILURE(errorCode) ||
             sample[0]!=0) {
         log_err("uscript_getSampleString(invalid) failed - %s\n", u_errorName(errorCode));
@@ -624,12 +623,12 @@ void TestBinaryValues() {
     static const char *const falseValues[]={ "N", "No", "F", "False" };
     static const char *const trueValues[]={ "Y", "Yes", "T", "True" };
     int32_t i;
-    for(i=0; i<LENGTHOF(falseValues); ++i) {
+    for(i=0; i<uprv_lengthof(falseValues); ++i) {
         if(FALSE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, falseValues[i])) {
             log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, \"%s\")!=FALSE (Are you missing data?)\n", falseValues[i]);
         }
     }
-    for(i=0; i<LENGTHOF(trueValues); ++i) {
+    for(i=0; i<uprv_lengthof(trueValues); ++i) {
         if(TRUE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, trueValues[i])) {
             log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, \"%s\")!=TRUE (Are you missing data?)\n", trueValues[i]);
         }
index 3cc775f7e16d4588b4a9980ee65955cc5a357853..4fe2f9e185c42273004cc2b7d47f2baf0477f2ee 100644 (file)
@@ -34,8 +34,7 @@
 #include "usc_impl.h"
 #include "udatamem.h" /* for testing ucase_openBinary() */
 #include "cucdapi.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 /* prototypes --------------------------------------------------------------- */
 
@@ -559,31 +558,31 @@ static void TestMisc()
 
     memset(icuVersion, 0, U_MAX_VERSION_STRING_LENGTH);
 
-    testSampleCharProps(u_isspace, "u_isspace", sampleSpaces, LENGTHOF(sampleSpaces), TRUE);
-    testSampleCharProps(u_isspace, "u_isspace", sampleNonSpaces, LENGTHOF(sampleNonSpaces), FALSE);
+    testSampleCharProps(u_isspace, "u_isspace", sampleSpaces, uprv_lengthof(sampleSpaces), TRUE);
+    testSampleCharProps(u_isspace, "u_isspace", sampleNonSpaces, uprv_lengthof(sampleNonSpaces), FALSE);
 
     testSampleCharProps(u_isJavaSpaceChar, "u_isJavaSpaceChar",
-                        sampleSpaces, LENGTHOF(sampleSpaces), TRUE);
+                        sampleSpaces, uprv_lengthof(sampleSpaces), TRUE);
     testSampleCharProps(u_isJavaSpaceChar, "u_isJavaSpaceChar",
-                        sampleNonSpaces, LENGTHOF(sampleNonSpaces), FALSE);
+                        sampleNonSpaces, uprv_lengthof(sampleNonSpaces), FALSE);
 
     testSampleCharProps(u_isWhitespace, "u_isWhitespace",
-                        sampleWhiteSpaces, LENGTHOF(sampleWhiteSpaces), TRUE);
+                        sampleWhiteSpaces, uprv_lengthof(sampleWhiteSpaces), TRUE);
     testSampleCharProps(u_isWhitespace, "u_isWhitespace",
-                        sampleNonWhiteSpaces, LENGTHOF(sampleNonWhiteSpaces), FALSE);
+                        sampleNonWhiteSpaces, uprv_lengthof(sampleNonWhiteSpaces), FALSE);
 
     testSampleCharProps(u_isdefined, "u_isdefined",
-                        sampleDefined, LENGTHOF(sampleDefined), TRUE);
+                        sampleDefined, uprv_lengthof(sampleDefined), TRUE);
     testSampleCharProps(u_isdefined, "u_isdefined",
-                        sampleUndefined, LENGTHOF(sampleUndefined), FALSE);
+                        sampleUndefined, uprv_lengthof(sampleUndefined), FALSE);
 
-    testSampleCharProps(u_isbase, "u_isbase", sampleBase, LENGTHOF(sampleBase), TRUE);
-    testSampleCharProps(u_isbase, "u_isbase", sampleNonBase, LENGTHOF(sampleNonBase), FALSE);
+    testSampleCharProps(u_isbase, "u_isbase", sampleBase, uprv_lengthof(sampleBase), TRUE);
+    testSampleCharProps(u_isbase, "u_isbase", sampleNonBase, uprv_lengthof(sampleNonBase), FALSE);
 
-    testSampleCharProps(u_isdigit, "u_isdigit", sampleDigits, LENGTHOF(sampleDigits), TRUE);
-    testSampleCharProps(u_isdigit, "u_isdigit", sampleNonDigits, LENGTHOF(sampleNonDigits), FALSE);
+    testSampleCharProps(u_isdigit, "u_isdigit", sampleDigits, uprv_lengthof(sampleDigits), TRUE);
+    testSampleCharProps(u_isdigit, "u_isdigit", sampleNonDigits, uprv_lengthof(sampleNonDigits), FALSE);
 
-    for (i = 0; i < LENGTHOF(sampleDigits); i++) {
+    for (i = 0; i < uprv_lengthof(sampleDigits); i++) {
         if (u_charDigitValue(sampleDigits[i]) != sampleDigitValues[i]) {
             log_err("error: u_charDigitValue(U+04x)=%d != %d\n",
                     sampleDigits[i], u_charDigitValue(sampleDigits[i]), sampleDigitValues[i]);
@@ -721,7 +720,7 @@ static void TestMisc()
             { 0xff3a, 37, -1 }
         };
 
-        for(i=0; i<LENGTHOF(data); ++i) {
+        for(i=0; i<uprv_lengthof(data); ++i) {
             if(u_digit(data[i].c, data[i].radix)!=data[i].value) {
                 log_err("u_digit(U+%04x, %d)=%d expected %d\n",
                         data[i].c,
@@ -822,7 +821,7 @@ TestPOSIX() {
 
     mask=1;
     for(cl=0; cl<12; ++cl) {
-        for(i=0; i<LENGTHOF(posixData); ++i) {
+        for(i=0; i<uprv_lengthof(posixData); ++i) {
             expect=(UBool)((posixData[i].posixResults&mask)!=0);
             if(posixClasses[cl].fn(posixData[i].c)!=expect) {
                 log_err("u_%s(U+%04x)=%s is wrong\n",
@@ -842,13 +841,13 @@ static void TestControlPrint()
     const UChar32 sampleNonPrintable[] = {0x200c, 0x009f, 0x001b};
     UChar32 c;
 
-    testSampleCharProps(u_iscntrl, "u_iscntrl", sampleControl, LENGTHOF(sampleControl), TRUE);
-    testSampleCharProps(u_iscntrl, "u_iscntrl", sampleNonControl, LENGTHOF(sampleNonControl), FALSE);
+    testSampleCharProps(u_iscntrl, "u_iscntrl", sampleControl, uprv_lengthof(sampleControl), TRUE);
+    testSampleCharProps(u_iscntrl, "u_iscntrl", sampleNonControl, uprv_lengthof(sampleNonControl), FALSE);
 
     testSampleCharProps(u_isprint, "u_isprint",
-                        samplePrintable, LENGTHOF(samplePrintable), TRUE);
+                        samplePrintable, uprv_lengthof(samplePrintable), TRUE);
     testSampleCharProps(u_isprint, "u_isprint",
-                        sampleNonPrintable, LENGTHOF(sampleNonPrintable), FALSE);
+                        sampleNonPrintable, uprv_lengthof(sampleNonPrintable), FALSE);
 
     /* test all ISO 8 controls */
     for(c=0; c<=0x9f; ++c) {
@@ -896,37 +895,37 @@ static void TestIdentifier()
     const UChar32 sampleNonIDIgnore[] = {0x0075, 0x00a3, 0x0061};
 
     testSampleCharProps(u_isJavaIDStart, "u_isJavaIDStart",
-                        sampleJavaIDStart, LENGTHOF(sampleJavaIDStart), TRUE);
+                        sampleJavaIDStart, uprv_lengthof(sampleJavaIDStart), TRUE);
     testSampleCharProps(u_isJavaIDStart, "u_isJavaIDStart",
-                        sampleNonJavaIDStart, LENGTHOF(sampleNonJavaIDStart), FALSE);
+                        sampleNonJavaIDStart, uprv_lengthof(sampleNonJavaIDStart), FALSE);
 
     testSampleCharProps(u_isJavaIDPart, "u_isJavaIDPart",
-                        sampleJavaIDPart, LENGTHOF(sampleJavaIDPart), TRUE);
+                        sampleJavaIDPart, uprv_lengthof(sampleJavaIDPart), TRUE);
     testSampleCharProps(u_isJavaIDPart, "u_isJavaIDPart",
-                        sampleNonJavaIDPart, LENGTHOF(sampleNonJavaIDPart), FALSE);
+                        sampleNonJavaIDPart, uprv_lengthof(sampleNonJavaIDPart), FALSE);
 
     /* IDPart should imply IDStart */
     testSampleCharProps(u_isJavaIDPart, "u_isJavaIDPart",
-                        sampleJavaIDStart, LENGTHOF(sampleJavaIDStart), TRUE);
+                        sampleJavaIDStart, uprv_lengthof(sampleJavaIDStart), TRUE);
 
     testSampleCharProps(u_isIDStart, "u_isIDStart",
-                        sampleUnicodeIDStart, LENGTHOF(sampleUnicodeIDStart), TRUE);
+                        sampleUnicodeIDStart, uprv_lengthof(sampleUnicodeIDStart), TRUE);
     testSampleCharProps(u_isIDStart, "u_isIDStart",
-                        sampleNonUnicodeIDStart, LENGTHOF(sampleNonUnicodeIDStart), FALSE);
+                        sampleNonUnicodeIDStart, uprv_lengthof(sampleNonUnicodeIDStart), FALSE);
 
     testSampleCharProps(u_isIDPart, "u_isIDPart",
-                        sampleUnicodeIDPart, LENGTHOF(sampleUnicodeIDPart), TRUE);
+                        sampleUnicodeIDPart, uprv_lengthof(sampleUnicodeIDPart), TRUE);
     testSampleCharProps(u_isIDPart, "u_isIDPart",
-                        sampleNonUnicodeIDPart, LENGTHOF(sampleNonUnicodeIDPart), FALSE);
+                        sampleNonUnicodeIDPart, uprv_lengthof(sampleNonUnicodeIDPart), FALSE);
 
     /* IDPart should imply IDStart */
     testSampleCharProps(u_isIDPart, "u_isIDPart",
-                        sampleUnicodeIDStart, LENGTHOF(sampleUnicodeIDStart), TRUE);
+                        sampleUnicodeIDStart, uprv_lengthof(sampleUnicodeIDStart), TRUE);
 
     testSampleCharProps(u_isIDIgnorable, "u_isIDIgnorable",
-                        sampleIDIgnore, LENGTHOF(sampleIDIgnore), TRUE);
+                        sampleIDIgnore, uprv_lengthof(sampleIDIgnore), TRUE);
     testSampleCharProps(u_isIDIgnorable, "u_isIDIgnorable",
-                        sampleNonIDIgnore, LENGTHOF(sampleNonIDIgnore), FALSE);
+                        sampleNonIDIgnore, uprv_lengthof(sampleNonIDIgnore), FALSE);
 }
 
 /* for each line of UnicodeData.txt, check some of the properties */
@@ -1188,7 +1187,7 @@ enumTypeRange(const void *context, UChar32 start, UChar32 limit, UCharCategory t
         return FALSE;
     }
 
-    count=LENGTHOF(test);
+    count=uprv_lengthof(test);
     for(i=0; i<count; ++i) {
         if(start<=test[i][0] && test[i][0]<limit) {
             if(type!=(UCharCategory)test[i][1]) {
@@ -1277,7 +1276,7 @@ enumDefaultsRange(const void *context, UChar32 start, UChar32 limit, UCharCatego
     if(type==U_UNASSIGNED || type==U_PRIVATE_USE_CHAR) {
         /* enumerate the intersections of defaultBidi ranges with [start..limit[ */
         c=start;
-        for(i=0; i<LENGTHOF(defaultBidi) && c<limit; ++i) {
+        for(i=0; i<uprv_lengthof(defaultBidi) && c<limit; ++i) {
             if((int32_t)c<defaultBidi[i][0]) {
                 while(c<limit && (int32_t)c<defaultBidi[i][0]) {
                     if(U_IS_UNICODE_NONCHAR(c) || u_hasBinaryProperty(c, UCHAR_DEFAULT_IGNORABLE_CODE_POINT)) {
@@ -2076,11 +2075,11 @@ TestUScriptRunAPI()
       const RunTestData *testData;
       int32_t nRuns;
     } testDataEntries[] = {
-        {testData1, LENGTHOF(testData1)},
-        {testData2, LENGTHOF(testData2)}
+        {testData1, uprv_lengthof(testData1)},
+        {testData2, uprv_lengthof(testData2)}
     };
     
-    static const int32_t nTestEntries = LENGTHOF(testDataEntries);
+    static const int32_t nTestEntries = uprv_lengthof(testDataEntries);
     int32_t testEntry;
     
     for (testEntry = 0; testEntry < nTestEntries; testEntry += 1) {
@@ -2887,7 +2886,7 @@ TestNumericProperties(void) {
     UChar32 c;
     int32_t i, type;
 
-    for(i=0; i<LENGTHOF(values); ++i) {
+    for(i=0; i<uprv_lengthof(values); ++i) {
         c=values[i].c;
         type=u_getIntPropertyValue(c, UCHAR_NUMERIC_TYPE);
         nv=u_getNumericValue(c);
@@ -3334,7 +3333,7 @@ testFold(UChar32 c, int which,
         log_err("u_foldCase(U+%04lx, default)=U+%04lx != U+%04lx\n", (long)c, (long)c2, (long)simple);
     }
     if((which&CF_FULL)!=0) {
-        length2=u_strFoldCase(t, LENGTHOF(t), s, length, 0, &errorCode);
+        length2=u_strFoldCase(t, uprv_lengthof(t), s, length, 0, &errorCode);
         if(length2!=fullLength || 0!=u_memcmp(t, full, fullLength)) {
             log_err("u_strFoldCase(U+%04lx, default) does not fold properly\n", (long)c);
         }
@@ -3344,7 +3343,7 @@ testFold(UChar32 c, int which,
             log_err("u_foldCase(U+%04lx, turkic)=U+%04lx != U+%04lx\n", (long)c, (long)c2, (long)simple);
         }
 
-        length2=u_strFoldCase(t, LENGTHOF(t), s, length, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode);
+        length2=u_strFoldCase(t, uprv_lengthof(t), s, length, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode);
         if(length2!=turkicFullLength || 0!=u_memcmp(t, turkicFull, length2)) {
             log_err("u_strFoldCase(U+%04lx, turkic) does not fold properly\n", (long)c);
         }
index c30f76d487ae0765f842d978c080155e1be0ecd2..0d2946b71cb12b0fff2680492a9b642b64ec4d43 100644 (file)
@@ -27,8 +27,6 @@
 #include "cstring.h"
 #include "cwchar.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void addUCharTransformTest(TestNode** root);
 
 static void Test_strToUTF32(void);
@@ -149,20 +147,20 @@ static void Test_strToUTF32(void){
 
     /* first with length */
     u32DestLen = -2;
-    u_strToUTF32(u32Target, 0, &u32DestLen, src16, LENGTHOF(src16),&err);
-    if(err != U_BUFFER_OVERFLOW_ERROR || u32DestLen != LENGTHOF(src32)) {
+    u_strToUTF32(u32Target, 0, &u32DestLen, src16, uprv_lengthof(src16),&err);
+    if(err != U_BUFFER_OVERFLOW_ERROR || u32DestLen != uprv_lengthof(src32)) {
         log_err("u_strToUTF32(preflight with length): "
                 "length %ld != %ld and %s != U_BUFFER_OVERFLOW_ERROR\n",
-                (long)u32DestLen, (long)LENGTHOF(src32), u_errorName(err));
+                (long)u32DestLen, (long)uprv_lengthof(src32), u_errorName(err));
         return;
     }
     err = U_ZERO_ERROR; 
     u32DestLen = -2;
-    u_strToUTF32(u32Target, LENGTHOF(src32)+1, &u32DestLen, src16, LENGTHOF(src16),&err);
-    if(err != U_ZERO_ERROR || u32DestLen != LENGTHOF(src32)) {
+    u_strToUTF32(u32Target, uprv_lengthof(src32)+1, &u32DestLen, src16, uprv_lengthof(src16),&err);
+    if(err != U_ZERO_ERROR || u32DestLen != uprv_lengthof(src32)) {
         log_err("u_strToUTF32(with length): "
                 "length %ld != %ld and %s != U_ZERO_ERROR\n",
-                (long)u32DestLen, (long)LENGTHOF(src32), u_errorName(err));
+                (long)u32DestLen, (long)uprv_lengthof(src32), u_errorName(err));
         return;
     }
     /*for(i=0; i< u32DestLen; i++){
@@ -171,7 +169,7 @@ static void Test_strToUTF32(void){
             printf("\n");
         }
     }*/
-    for(i=0; i< LENGTHOF(src32); i++){
+    for(i=0; i< uprv_lengthof(src32); i++){
         if(u32Target[i] != src32[i]){
             log_verbose("u_strToUTF32(with length) failed expected: %04X got: %04X at index: %i \n", src32[i], u32Target[i],i);
         }
@@ -183,23 +181,23 @@ static void Test_strToUTF32(void){
     /* now NUL-terminated */
     u32DestLen = -2;
     u_strToUTF32(NULL,0, &u32DestLen, src16, -1,&err);
-    if(err != U_BUFFER_OVERFLOW_ERROR || u32DestLen != LENGTHOF(src32)-1) {
+    if(err != U_BUFFER_OVERFLOW_ERROR || u32DestLen != uprv_lengthof(src32)-1) {
         log_err("u_strToUTF32(preflight with NUL-termination): "
                 "length %ld != %ld and %s != U_BUFFER_OVERFLOW_ERROR\n",
-                (long)u32DestLen, (long)LENGTHOF(src32)-1, u_errorName(err));
+                (long)u32DestLen, (long)uprv_lengthof(src32)-1, u_errorName(err));
         return;
     }
     err = U_ZERO_ERROR; 
     u32DestLen = -2;
-    u_strToUTF32(u32Target, LENGTHOF(src32), &u32DestLen, src16, -1,&err);
-    if(err != U_ZERO_ERROR || u32DestLen != LENGTHOF(src32)-1) {
+    u_strToUTF32(u32Target, uprv_lengthof(src32), &u32DestLen, src16, -1,&err);
+    if(err != U_ZERO_ERROR || u32DestLen != uprv_lengthof(src32)-1) {
         log_err("u_strToUTF32(with NUL-termination): "
                 "length %ld != %ld and %s != U_ZERO_ERROR\n",
-                (long)u32DestLen, (long)LENGTHOF(src32)-1, u_errorName(err));
+                (long)u32DestLen, (long)uprv_lengthof(src32)-1, u_errorName(err));
         return;
     }
 
-    for(i=0; i< LENGTHOF(src32); i++){
+    for(i=0; i< uprv_lengthof(src32); i++){
         if(u32Target[i] != src32[i]){
             log_verbose("u_strToUTF32(NUL-termination) failed expected: %04X got: %04X \n", src32[i], u32Target[i]);
         }
@@ -218,7 +216,7 @@ static void Test_strToUTF32_surrogates() {
     static const UChar32 expected[] = { 0x5a, 0x50000, 0x7a, 0 };
     static const UChar32 expected_FFFD[] = { 0x41, 0xfffd, 0x61, 0xfffd, 0x5a, 0x50000, 0x7a, 0 };
     static const UChar32 expected_12345[] = { 0x41, 0x12345, 0x61, 0x12345, 0x5a, 0x50000, 0x7a, 0 };
-    len16 = LENGTHOF(surr16);
+    len16 = uprv_lengthof(surr16);
     for(i = 0; i < 4; ++i) {
         err = U_ZERO_ERROR;
         u_strToUTF32(u32Target, 0, &u32DestLen, surr16+i, len16-i, &err);
@@ -229,7 +227,7 @@ static void Test_strToUTF32_surrogates() {
         }
 
         err = U_ZERO_ERROR;
-        u_strToUTF32(u32Target, LENGTHOF(u32Target), &u32DestLen, surr16+i, len16-i, &err);
+        u_strToUTF32(u32Target, uprv_lengthof(u32Target), &u32DestLen, surr16+i, len16-i, &err);
         if(err != U_INVALID_CHAR_FOUND) {
             log_err("u_strToUTF32(surr16+%ld) sets %s != U_INVALID_CHAR_FOUND\n",
                     (long)i, u_errorName(err));
@@ -245,7 +243,7 @@ static void Test_strToUTF32_surrogates() {
         }
 
         err = U_ZERO_ERROR;
-        u_strToUTF32(u32Target, LENGTHOF(u32Target), &u32DestLen, surr16+i, -1, &err);
+        u_strToUTF32(u32Target, uprv_lengthof(u32Target), &u32DestLen, surr16+i, -1, &err);
         if(err != U_INVALID_CHAR_FOUND) {
             log_err("u_strToUTF32(surr16+%ld/NUL) sets %s != U_INVALID_CHAR_FOUND\n",
                     (long)i, u_errorName(err));
@@ -262,7 +260,7 @@ static void Test_strToUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strToUTF32(u32Target, LENGTHOF(u32Target), &u32DestLen, surr16+4, len16-4-1, &err);
+    u_strToUTF32(u32Target, uprv_lengthof(u32Target), &u32DestLen, surr16+4, len16-4-1, &err);
     if(err != U_ZERO_ERROR || u32DestLen != 3 || uprv_memcmp(u32Target, expected, 4*4)) {
         log_err("u_strToUTF32(surr16+4) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -278,7 +276,7 @@ static void Test_strToUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strToUTF32(u32Target, LENGTHOF(u32Target), &u32DestLen, surr16+4, -1, &err);
+    u_strToUTF32(u32Target, uprv_lengthof(u32Target), &u32DestLen, surr16+4, -1, &err);
     if(err != U_ZERO_ERROR || u32DestLen != 3 || uprv_memcmp(u32Target, expected, 4*4)) {
         log_err("u_strToUTF32(surr16+4/NUL) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -296,7 +294,7 @@ static void Test_strToUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strToUTF32WithSub(u32Target, LENGTHOF(u32Target), &u32DestLen, surr16, len16-1, 0xfffd, &numSubstitutions, &err);
+    u_strToUTF32WithSub(u32Target, uprv_lengthof(u32Target), &u32DestLen, surr16, len16-1, 0xfffd, &numSubstitutions, &err);
     if(err != U_ZERO_ERROR || u32DestLen != 7 || numSubstitutions != 2 || uprv_memcmp(u32Target, expected_FFFD, 8*4)) {
         log_err("u_strToUTF32WithSub(surr16) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -312,7 +310,7 @@ static void Test_strToUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strToUTF32WithSub(u32Target, LENGTHOF(u32Target), &u32DestLen, surr16, -1, 0x12345, &numSubstitutions, &err);
+    u_strToUTF32WithSub(u32Target, uprv_lengthof(u32Target), &u32DestLen, surr16, -1, 0x12345, &numSubstitutions, &err);
     if(err != U_ZERO_ERROR || u32DestLen != 7 || numSubstitutions != 2 || uprv_memcmp(u32Target, expected_12345, 8*4)) {
         log_err("u_strToUTF32WithSub(surr16/NUL) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -328,20 +326,20 @@ static void Test_strFromUTF32(void){
 
     /* first with length */
     uDestLen = -2;
-    u_strFromUTF32(uTarget,0,&uDestLen,src32,LENGTHOF(src32),&err);
-    if(err != U_BUFFER_OVERFLOW_ERROR || uDestLen != LENGTHOF(src16)) {
+    u_strFromUTF32(uTarget,0,&uDestLen,src32,uprv_lengthof(src32),&err);
+    if(err != U_BUFFER_OVERFLOW_ERROR || uDestLen != uprv_lengthof(src16)) {
         log_err("u_strFromUTF32(preflight with length): "
                 "length %ld != %ld and %s != U_BUFFER_OVERFLOW_ERROR\n",
-                (long)uDestLen, (long)LENGTHOF(src16), u_errorName(err));
+                (long)uDestLen, (long)uprv_lengthof(src16), u_errorName(err));
         return;
     }
     err = U_ZERO_ERROR; 
     uDestLen = -2;
-    u_strFromUTF32(uTarget, LENGTHOF(src16)+1,&uDestLen,src32,LENGTHOF(src32),&err);
-    if(err != U_ZERO_ERROR || uDestLen != LENGTHOF(src16)) {
+    u_strFromUTF32(uTarget, uprv_lengthof(src16)+1,&uDestLen,src32,uprv_lengthof(src32),&err);
+    if(err != U_ZERO_ERROR || uDestLen != uprv_lengthof(src16)) {
         log_err("u_strFromUTF32(with length): "
                 "length %ld != %ld and %s != U_ZERO_ERROR\n",
-                (long)uDestLen, (long)LENGTHOF(src16), u_errorName(err));
+                (long)uDestLen, (long)uprv_lengthof(src16), u_errorName(err));
         return;
     }
     /*for(i=0; i< uDestLen; i++){
@@ -363,19 +361,19 @@ static void Test_strFromUTF32(void){
     /* now NUL-terminated */
     uDestLen = -2;
     u_strFromUTF32(NULL,0,&uDestLen,src32,-1,&err);
-    if(err != U_BUFFER_OVERFLOW_ERROR || uDestLen != LENGTHOF(src16)-1) {
+    if(err != U_BUFFER_OVERFLOW_ERROR || uDestLen != uprv_lengthof(src16)-1) {
         log_err("u_strFromUTF32(preflight with NUL-termination): "
                 "length %ld != %ld and %s != U_BUFFER_OVERFLOW_ERROR\n",
-                (long)uDestLen, (long)LENGTHOF(src16)-1, u_errorName(err));
+                (long)uDestLen, (long)uprv_lengthof(src16)-1, u_errorName(err));
         return;
     }
     err = U_ZERO_ERROR; 
     uDestLen = -2;
-    u_strFromUTF32(uTarget, LENGTHOF(src16),&uDestLen,src32,-1,&err);
-    if(err != U_ZERO_ERROR || uDestLen != LENGTHOF(src16)-1) {
+    u_strFromUTF32(uTarget, uprv_lengthof(src16),&uDestLen,src32,-1,&err);
+    if(err != U_ZERO_ERROR || uDestLen != uprv_lengthof(src16)-1) {
         log_err("u_strFromUTF32(with NUL-termination): "
                 "length %ld != %ld and %s != U_ZERO_ERROR\n",
-                (long)uDestLen, (long)LENGTHOF(src16)-1, u_errorName(err));
+                (long)uDestLen, (long)uprv_lengthof(src16)-1, u_errorName(err));
         return;
     }
 
@@ -399,7 +397,7 @@ static void Test_strFromUTF32_surrogates() {
     static const UChar expected_FFFD[] = { 0x41, 0xfffd, 0x61, 0xfffd, 0xfffd, 0xfffd, 0x5a, 0xd900, 0xdc00, 0x7a, 0 };
     static const UChar expected_12345[] = { 0x41, 0xd808, 0xdf45, 0x61, 0xd808, 0xdf45, 0xd808, 0xdf45, 0xd808, 0xdf45,
                                             0x5a, 0xd900, 0xdc00, 0x7a, 0 };
-    len32 = LENGTHOF(surr32);
+    len32 = uprv_lengthof(surr32);
     for(i = 0; i < 6; ++i) {
         err = U_ZERO_ERROR;
         u_strFromUTF32(uTarget, 0, &uDestLen, surr32+i, len32-i, &err);
@@ -410,7 +408,7 @@ static void Test_strFromUTF32_surrogates() {
         }
 
         err = U_ZERO_ERROR;
-        u_strFromUTF32(uTarget, LENGTHOF(uTarget), &uDestLen, surr32+i, len32-i, &err);
+        u_strFromUTF32(uTarget, uprv_lengthof(uTarget), &uDestLen, surr32+i, len32-i, &err);
         if(err != U_INVALID_CHAR_FOUND) {
             log_err("u_strFromUTF32(surr32+%ld) sets %s != U_INVALID_CHAR_FOUND\n",
                     (long)i, u_errorName(err));
@@ -426,7 +424,7 @@ static void Test_strFromUTF32_surrogates() {
         }
 
         err = U_ZERO_ERROR;
-        u_strFromUTF32(uTarget, LENGTHOF(uTarget), &uDestLen, surr32+i, -1, &err);
+        u_strFromUTF32(uTarget, uprv_lengthof(uTarget), &uDestLen, surr32+i, -1, &err);
         if(err != U_INVALID_CHAR_FOUND) {
             log_err("u_strFromUTF32(surr32+%ld/NUL) sets %s != U_INVALID_CHAR_FOUND\n",
                     (long)i, u_errorName(err));
@@ -443,7 +441,7 @@ static void Test_strFromUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strFromUTF32(uTarget, LENGTHOF(uTarget), &uDestLen, surr32+6, len32-6-1, &err);
+    u_strFromUTF32(uTarget, uprv_lengthof(uTarget), &uDestLen, surr32+6, len32-6-1, &err);
     if(err != U_ZERO_ERROR || uDestLen != 4 || u_memcmp(uTarget, expected, 5)) {
         log_err("u_strFromUTF32(surr32+6) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -459,7 +457,7 @@ static void Test_strFromUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strFromUTF32(uTarget, LENGTHOF(uTarget), &uDestLen, surr32+6, -1, &err);
+    u_strFromUTF32(uTarget, uprv_lengthof(uTarget), &uDestLen, surr32+6, -1, &err);
     if(err != U_ZERO_ERROR || uDestLen != 4 || u_memcmp(uTarget, expected, 5)) {
         log_err("u_strFromUTF32(surr32+6/NUL) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -477,7 +475,7 @@ static void Test_strFromUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strFromUTF32WithSub(uTarget, LENGTHOF(uTarget), &uDestLen, surr32, len32-1, 0xfffd, &numSubstitutions, &err);
+    u_strFromUTF32WithSub(uTarget, uprv_lengthof(uTarget), &uDestLen, surr32, len32-1, 0xfffd, &numSubstitutions, &err);
     if(err != U_ZERO_ERROR || uDestLen != 10 || numSubstitutions != 4 || u_memcmp(uTarget, expected_FFFD, 11)) {
         log_err("u_strFromUTF32WithSub(surr32) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -493,7 +491,7 @@ static void Test_strFromUTF32_surrogates() {
     }
 
     err = U_ZERO_ERROR;
-    u_strFromUTF32WithSub(uTarget, LENGTHOF(uTarget), &uDestLen, surr32, -1, 0x12345, &numSubstitutions, &err);
+    u_strFromUTF32WithSub(uTarget, uprv_lengthof(uTarget), &uDestLen, surr32, -1, 0x12345, &numSubstitutions, &err);
     if(err != U_ZERO_ERROR || uDestLen != 14 || numSubstitutions != 4 || u_memcmp(uTarget, expected_12345, 15)) {
         log_err("u_strFromUTF32WithSub(surr32/NUL) sets %s != U_ZERO_ERROR or does not produce the expected string\n",
                 u_errorName(err));
@@ -685,10 +683,10 @@ static void Test_UChar_UTF8_API(void){
         char out8[10];
 
         if(
-            (err=U_ZERO_ERROR, u_strToUTF8(out8, LENGTHOF(out8), NULL, withLead16, LENGTHOF(withLead16), &err), err!=U_INVALID_CHAR_FOUND) ||
-            (err=U_ZERO_ERROR, u_strToUTF8(out8, LENGTHOF(out8), NULL, withTrail16, -1, &err), err!=U_INVALID_CHAR_FOUND) ||
-            (err=U_ZERO_ERROR, u_strFromUTF8(out16, LENGTHOF(out16), NULL, (const char *)withLead8, LENGTHOF(withLead8), &err), err!=U_INVALID_CHAR_FOUND) ||
-            (err=U_ZERO_ERROR, u_strFromUTF8(out16, LENGTHOF(out16), NULL, (const char *)withTrail8, -1, &err), err!=U_INVALID_CHAR_FOUND)
+            (err=U_ZERO_ERROR, u_strToUTF8(out8, uprv_lengthof(out8), NULL, withLead16, uprv_lengthof(withLead16), &err), err!=U_INVALID_CHAR_FOUND) ||
+            (err=U_ZERO_ERROR, u_strToUTF8(out8, uprv_lengthof(out8), NULL, withTrail16, -1, &err), err!=U_INVALID_CHAR_FOUND) ||
+            (err=U_ZERO_ERROR, u_strFromUTF8(out16, uprv_lengthof(out16), NULL, (const char *)withLead8, uprv_lengthof(withLead8), &err), err!=U_INVALID_CHAR_FOUND) ||
+            (err=U_ZERO_ERROR, u_strFromUTF8(out16, uprv_lengthof(out16), NULL, (const char *)withTrail8, -1, &err), err!=U_INVALID_CHAR_FOUND)
         ) {
             log_err("error: u_strTo/FromUTF8(string with single surrogate) fails to report error\n");
         }
@@ -700,7 +698,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out16[0]=0x55aa;
         uDestLen=0;
-        u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+        u_strFromUTF8WithSub(out16, uprv_lengthof(out16), &uDestLen,
                              (const char *)withTrail8, uprv_strlen((const char *)withTrail8),
                              0x50005, &numSubstitutions,
                              &err);
@@ -715,7 +713,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out16[0]=0x55aa;
         uDestLen=0;
-        u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+        u_strFromUTF8WithSub(out16, uprv_lengthof(out16), &uDestLen,
                              (const char *)withTrail8, -1,
                              0xfffd, &numSubstitutions,
                              &err);
@@ -743,7 +741,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out8[0]=(char)0xf5;
         u8DestLen=0;
-        u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+        u_strToUTF8WithSub(out8, uprv_lengthof(out8), &u8DestLen,
                            withTrail16, u_strlen(withTrail16),
                            0xfffd, &numSubstitutions,
                            &err);
@@ -758,7 +756,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out8[0]=(char)0xf5;
         u8DestLen=0;
-        u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+        u_strToUTF8WithSub(out8, uprv_lengthof(out8), &u8DestLen,
                            withTrail16, -1,
                            0x1a, &numSubstitutions,
                            &err);
@@ -789,7 +787,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out16[0]=0x55aa;
         uDestLen=0;
-        u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+        u_strFromUTF8WithSub(out16, uprv_lengthof(out16), &uDestLen,
                              (const char *)withTrail8, 3,
                              0x50005, &numSubstitutions,
                              &err);
@@ -804,7 +802,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out8[0]=(char)0xf5;
         u8DestLen=0;
-        u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+        u_strToUTF8WithSub(out8, uprv_lengthof(out8), &u8DestLen,
                            withTrail16, 1,
                            0xfffd, &numSubstitutions,
                            &err);
@@ -821,7 +819,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out16[0]=0x55aa;
         uDestLen=0;
-        u_strFromUTF8WithSub(out16, LENGTHOF(out16), &uDestLen,
+        u_strFromUTF8WithSub(out16, uprv_lengthof(out16), &uDestLen,
                              (const char *)withTrail8, 3,
                              U_SENTINEL, &numSubstitutions,
                              &err);
@@ -836,7 +834,7 @@ static void Test_UChar_UTF8_API(void){
         numSubstitutions=-1;
         out8[0]=(char)0xf5;
         u8DestLen=0;
-        u_strToUTF8WithSub(out8, LENGTHOF(out8), &u8DestLen,
+        u_strToUTF8WithSub(out8, uprv_lengthof(out8), &u8DestLen,
                            withTrail16, 1,
                            U_SENTINEL, &numSubstitutions,
                            &err);
@@ -854,7 +852,7 @@ static void Test_UChar_UTF8_API(void){
         static const char src[1]={ (char)0xf8 };
         UChar out16[10];
         err=U_ZERO_ERROR;
-        u_strFromUTF8(out16, LENGTHOF(out16), NULL, src, 1, &err);
+        u_strFromUTF8(out16, uprv_lengthof(out16), NULL, src, 1, &err);
         if(err!=U_INVALID_CHAR_FOUND) {
             log_err("error: u_strFromUTF8(5-byte lead byte) failed\n");
         }
@@ -920,7 +918,7 @@ Test_FromUTF8(void) {
     errorCode=U_ZERO_ERROR;
     dest[0]=dest[1]=99;
     destLength=-99;
-    destPointer=u_strFromUTF8(dest, LENGTHOF(dest), &destLength, (const char *)bytes, 3, &errorCode);
+    destPointer=u_strFromUTF8(dest, uprv_lengthof(dest), &destLength, (const char *)bytes, 3, &errorCode);
     if(U_FAILURE(errorCode) || destPointer!=dest || destLength!=1 || dest[0]!=0x95c || dest[1]!=0) {
         log_err("error: u_strFromUTF8(transform srcLength=3) fails: destLength=%ld - %s\n",
                 (long)destLength, u_errorName(errorCode));
@@ -1061,7 +1059,7 @@ Test_FromUTF8Lenient(void) {
         dest[0]=dest[destLength0]=0x1234;
         destLength=-1;
         errorCode=U_ZERO_ERROR;
-        pDest=u_strFromUTF8Lenient(dest, LENGTHOF(dest), &destLength, pb, -1, &errorCode);
+        pDest=u_strFromUTF8Lenient(dest, uprv_lengthof(dest), &destLength, pb, -1, &errorCode);
         if (errorCode!=U_ZERO_ERROR ||
             pDest!=dest || dest[destLength0]!=0 ||
             destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
@@ -1109,7 +1107,7 @@ Test_FromUTF8Lenient(void) {
         dest[0]=dest[destLength0]=0x1234;
         destLength=-1;
         errorCode=U_ZERO_ERROR;
-        pDest=u_strFromUTF8Lenient(dest, LENGTHOF(dest), &destLength, pb, srcLength, &errorCode);
+        pDest=u_strFromUTF8Lenient(dest, uprv_lengthof(dest), &destLength, pb, srcLength, &errorCode);
         if (errorCode!=U_ZERO_ERROR ||
             pDest!=dest || dest[destLength0]!=0 ||
             destLength!=destLength0 || !equalAnyFFFD(dest, pu, destLength)
@@ -1352,7 +1350,7 @@ static void Test_UChar_WCHART_API(void){
 
         err=U_ZERO_ERROR;
         buffer[3]=0x20ac;
-        wDestLen=u_terminateWChars(buffer, LENGTHOF(buffer), 3, &err);
+        wDestLen=u_terminateWChars(buffer, uprv_lengthof(buffer), 3, &err);
         if(err!=U_ZERO_ERROR || wDestLen!=3 || buffer[3]!=0) {
             log_err("u_terminateWChars(buffer, all, 3, zero) failed: %s length %d [3]==U+%04x\n",
                     u_errorName(err), wDestLen, buffer[3]);
@@ -1368,7 +1366,7 @@ static void Test_UChar_WCHART_API(void){
 
         err=U_STRING_NOT_TERMINATED_WARNING;
         buffer[3]=0x20ac;
-        wDestLen=u_terminateWChars(buffer, LENGTHOF(buffer), 3, &err);
+        wDestLen=u_terminateWChars(buffer, uprv_lengthof(buffer), 3, &err);
         if(err!=U_ZERO_ERROR || wDestLen!=3 || buffer[3]!=0) {
             log_err("u_terminateWChars(buffer, all, 3, not-terminated) failed: %s length %d [3]==U+%04x\n",
                     u_errorName(err), wDestLen, buffer[3]);
@@ -1558,9 +1556,9 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(dest, (int32_t)sizeof(dest), &length,
-                              src, LENGTHOF(src), &errorCode);
+                              src, uprv_lengthof(src), &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(expected) || 0!=memcmp(dest, expected, length) ||
+        length!=uprv_lengthof(expected) || 0!=memcmp(dest, expected, length) ||
         dest[length]!=0
     ) {
         log_err("u_strToJavaModifiedUTF8(normal) failed - %s\n", u_errorName(errorCode));
@@ -1569,20 +1567,20 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(dest, (int32_t)sizeof(dest), NULL,
-                              src, LENGTHOF(src), &errorCode);
+                              src, uprv_lengthof(src), &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        0!=memcmp(dest, expected, LENGTHOF(expected)) ||
-        dest[LENGTHOF(expected)]!=0
+        0!=memcmp(dest, expected, uprv_lengthof(expected)) ||
+        dest[uprv_lengthof(expected)]!=0
     ) {
         log_err("u_strToJavaModifiedUTF8(normal, pLength=NULL) failed - %s\n", u_errorName(errorCode));
     }
     memset(dest, 0xff, sizeof(dest));
     errorCode=U_ZERO_ERROR;
     length=-5;
-    p=u_strToJavaModifiedUTF8(dest, LENGTHOF(expected), &length,
-                              src, LENGTHOF(src), &errorCode);
+    p=u_strToJavaModifiedUTF8(dest, uprv_lengthof(expected), &length,
+                              src, uprv_lengthof(src), &errorCode);
     if( errorCode!=U_STRING_NOT_TERMINATED_WARNING || p!=dest ||
-        length!=LENGTHOF(expected) || 0!=memcmp(dest, expected, length) ||
+        length!=uprv_lengthof(expected) || 0!=memcmp(dest, expected, length) ||
         dest[length]!=(char)0xff
     ) {
         log_err("u_strToJavaModifiedUTF8(tight) failed - %s\n", u_errorName(errorCode));
@@ -1610,10 +1608,10 @@ static void Test_strToJavaModifiedUTF8() {
     memset(dest, 0xff, sizeof(dest));
     errorCode=U_ZERO_ERROR;
     length=-5;
-    p=u_strToJavaModifiedUTF8(dest, LENGTHOF(expected)/2, &length,
-                              src, LENGTHOF(src), &errorCode);
+    p=u_strToJavaModifiedUTF8(dest, uprv_lengthof(expected)/2, &length,
+                              src, uprv_lengthof(src), &errorCode);
     if( errorCode!=U_BUFFER_OVERFLOW_ERROR ||
-        length!=LENGTHOF(expected) || dest[LENGTHOF(expected)/2]!=(char)0xff
+        length!=uprv_lengthof(expected) || dest[uprv_lengthof(expected)/2]!=(char)0xff
     ) {
         log_err("u_strToJavaModifiedUTF8(overflow) failed - %s\n", u_errorName(errorCode));
     }
@@ -1621,9 +1619,9 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(NULL, 0, &length,
-                              src, LENGTHOF(src), &errorCode);
+                              src, uprv_lengthof(src), &errorCode);
     if( errorCode!=U_BUFFER_OVERFLOW_ERROR ||
-        length!=LENGTHOF(expected) || dest[0]!=(char)0xff
+        length!=uprv_lengthof(expected) || dest[0]!=(char)0xff
     ) {
         log_err("u_strToJavaModifiedUTF8(pure preflighting) failed - %s\n", u_errorName(errorCode));
     }
@@ -1631,9 +1629,9 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(dest, (int32_t)sizeof(dest), &length,
-                              shortSrc, LENGTHOF(shortSrc), &errorCode);
+                              shortSrc, uprv_lengthof(shortSrc), &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(shortExpected) || 0!=memcmp(dest, shortExpected, length) ||
+        length!=uprv_lengthof(shortExpected) || 0!=memcmp(dest, shortExpected, length) ||
         dest[length]!=0
     ) {
         log_err("u_strToJavaModifiedUTF8(short) failed - %s\n", u_errorName(errorCode));
@@ -1644,7 +1642,7 @@ static void Test_strToJavaModifiedUTF8() {
     p=u_strToJavaModifiedUTF8(dest, (int32_t)sizeof(dest), &length,
                               asciiNul, -1, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(asciiNulExpected) || 0!=memcmp(dest, asciiNulExpected, length) ||
+        length!=uprv_lengthof(asciiNulExpected) || 0!=memcmp(dest, asciiNulExpected, length) ||
         dest[length]!=0
     ) {
         log_err("u_strToJavaModifiedUTF8(asciiNul) failed - %s\n", u_errorName(errorCode));
@@ -1665,7 +1663,7 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(NULL, sizeof(dest), &length,
-                              src, LENGTHOF(src), &errorCode);
+                              src, uprv_lengthof(src), &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=(char)0xff) {
         log_err("u_strToJavaModifiedUTF8(dest=NULL) failed - %s\n", u_errorName(errorCode));
     }
@@ -1673,7 +1671,7 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(dest, -1, &length,
-                              src, LENGTHOF(src), &errorCode);
+                              src, uprv_lengthof(src), &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=(char)0xff) {
         log_err("u_strToJavaModifiedUTF8(destCapacity<0) failed - %s\n", u_errorName(errorCode));
     }
@@ -1681,7 +1679,7 @@ static void Test_strToJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=-5;
     p=u_strToJavaModifiedUTF8(dest, sizeof(dest), &length,
-                              NULL, LENGTHOF(src), &errorCode);
+                              NULL, uprv_lengthof(src), &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=(char)0xff) {
         log_err("u_strToJavaModifiedUTF8(src=NULL) failed - %s\n", u_errorName(errorCode));
     }
@@ -1749,12 +1747,12 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(expected) || 0!=memcmp(dest, expected, length) ||
+        length!=uprv_lengthof(expected) || 0!=memcmp(dest, expected, length) ||
         dest[length]!=0 ||
-        numSubstitutions!=LENGTHOF(invalidExpectedFFFD)
+        numSubstitutions!=uprv_lengthof(invalidExpectedFFFD)
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(normal) failed - %s\n", u_errorName(errorCode));
     }
@@ -1762,12 +1760,12 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), NULL,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        0!=memcmp(dest, expected, LENGTHOF(expected)) ||
-        dest[LENGTHOF(expected)]!=0 ||
-        numSubstitutions!=LENGTHOF(invalidExpectedFFFD)
+        0!=memcmp(dest, expected, uprv_lengthof(expected)) ||
+        dest[uprv_lengthof(expected)]!=0 ||
+        numSubstitutions!=uprv_lengthof(invalidExpectedFFFD)
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(normal, pLength=NULL) failed - %s\n", u_errorName(errorCode));
     }
@@ -1775,10 +1773,10 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, NULL, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(expected) || 0!=memcmp(dest, expected, length) ||
+        length!=uprv_lengthof(expected) || 0!=memcmp(dest, expected, length) ||
         dest[length]!=0
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(normal, pNumSubstitutions=NULL) failed - %s\n", u_errorName(errorCode));
@@ -1786,13 +1784,13 @@ static void Test_strFromJavaModifiedUTF8() {
     memset(dest, 0xff, sizeof(dest));
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
-    p=u_strFromJavaModifiedUTF8WithSub(dest, LENGTHOF(expected), &length,
-                                       (const char *)src, LENGTHOF(src),
+    p=u_strFromJavaModifiedUTF8WithSub(dest, uprv_lengthof(expected), &length,
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( errorCode!=U_STRING_NOT_TERMINATED_WARNING || p!=dest ||
-        length!=LENGTHOF(expected) || 0!=memcmp(dest, expected, length) ||
+        length!=uprv_lengthof(expected) || 0!=memcmp(dest, expected, length) ||
         dest[length]!=0xffff ||
-        numSubstitutions!=LENGTHOF(invalidExpectedFFFD)
+        numSubstitutions!=uprv_lengthof(invalidExpectedFFFD)
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(tight) failed - %s\n", u_errorName(errorCode));
     }
@@ -1837,11 +1835,11 @@ static void Test_strFromJavaModifiedUTF8() {
     memset(dest, 0xff, sizeof(dest));
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
-    p=u_strFromJavaModifiedUTF8WithSub(dest, LENGTHOF(expected)/2, &length,
-                                       (const char *)src, LENGTHOF(src),
+    p=u_strFromJavaModifiedUTF8WithSub(dest, uprv_lengthof(expected)/2, &length,
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( errorCode!=U_BUFFER_OVERFLOW_ERROR ||
-        length!=LENGTHOF(expected) || dest[LENGTHOF(expected)/2]!=0xffff
+        length!=uprv_lengthof(expected) || dest[uprv_lengthof(expected)/2]!=0xffff
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(overflow) failed - %s\n", u_errorName(errorCode));
     }
@@ -1849,10 +1847,10 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(NULL, 0, &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( errorCode!=U_BUFFER_OVERFLOW_ERROR ||
-        length!=LENGTHOF(expected) || dest[0]!=0xffff
+        length!=uprv_lengthof(expected) || dest[0]!=0xffff
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(pure preflighting) failed - %s\n", u_errorName(errorCode));
     }
@@ -1860,10 +1858,10 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)shortSrc, LENGTHOF(shortSrc),
+                                       (const char *)shortSrc, uprv_lengthof(shortSrc),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(shortExpected) || 0!=memcmp(dest, shortExpected, length) ||
+        length!=uprv_lengthof(shortExpected) || 0!=memcmp(dest, shortExpected, length) ||
         dest[length]!=0 ||
         numSubstitutions!=0
     ) {
@@ -1876,7 +1874,7 @@ static void Test_strFromJavaModifiedUTF8() {
                                        (const char *)asciiNul, -1,
                                        0xfffd, &numSubstitutions, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(asciiNulExpected) || 0!=memcmp(dest, asciiNulExpected, length) ||
+        length!=uprv_lengthof(asciiNulExpected) || 0!=memcmp(dest, asciiNulExpected, length) ||
         dest[length]!=0 ||
         numSubstitutions!=0
     ) {
@@ -1897,12 +1895,12 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)invalid, LENGTHOF(invalid),
+                                       (const char *)invalid, uprv_lengthof(invalid),
                                        0xfffd, &numSubstitutions, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(invalidExpectedFFFD) || 0!=memcmp(dest, invalidExpectedFFFD, length) ||
+        length!=uprv_lengthof(invalidExpectedFFFD) || 0!=memcmp(dest, invalidExpectedFFFD, length) ||
         dest[length]!=0 ||
-        numSubstitutions!=LENGTHOF(invalidExpectedFFFD)
+        numSubstitutions!=uprv_lengthof(invalidExpectedFFFD)
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(invalid->fffd) failed - %s\n", u_errorName(errorCode));
     }
@@ -1910,12 +1908,12 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)invalid, LENGTHOF(invalid),
+                                       (const char *)invalid, uprv_lengthof(invalid),
                                        0x50000, &numSubstitutions, &errorCode);
     if( U_FAILURE(errorCode) || p!=dest ||
-        length!=LENGTHOF(invalidExpected50000) || 0!=memcmp(dest, invalidExpected50000, length) ||
+        length!=uprv_lengthof(invalidExpected50000) || 0!=memcmp(dest, invalidExpected50000, length) ||
         dest[length]!=0 ||
-        numSubstitutions!=LENGTHOF(invalidExpectedFFFD)  /* not ...50000 */
+        numSubstitutions!=uprv_lengthof(invalidExpectedFFFD)  /* not ...50000 */
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(invalid->50000) failed - %s\n", u_errorName(errorCode));
     }
@@ -1923,7 +1921,7 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)invalid, LENGTHOF(invalid),
+                                       (const char *)invalid, uprv_lengthof(invalid),
                                        U_SENTINEL, &numSubstitutions, &errorCode);
     if(errorCode!=U_INVALID_CHAR_FOUND || dest[0]!=0xffff || numSubstitutions!=0) {
         log_err("u_strFromJavaModifiedUTF8WithSub(invalid->error) failed - %s\n", u_errorName(errorCode));
@@ -1932,10 +1930,10 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, (int32_t)sizeof(dest), &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        U_SENTINEL, &numSubstitutions, &errorCode);
     if( errorCode!=U_INVALID_CHAR_FOUND ||
-        length>=LENGTHOF(expected) || dest[LENGTHOF(expected)-1]!=0xffff ||
+        length>=uprv_lengthof(expected) || dest[uprv_lengthof(expected)-1]!=0xffff ||
         numSubstitutions!=0
     ) {
         log_err("u_strFromJavaModifiedUTF8WithSub(normal->error) failed - %s\n", u_errorName(errorCode));
@@ -1946,7 +1944,7 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(NULL, sizeof(dest), &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=0xffff) {
         log_err("u_strFromJavaModifiedUTF8WithSub(dest=NULL) failed - %s\n", u_errorName(errorCode));
@@ -1955,7 +1953,7 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, -1, &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=0xffff) {
         log_err("u_strFromJavaModifiedUTF8WithSub(destCapacity<0) failed - %s\n", u_errorName(errorCode));
@@ -1964,7 +1962,7 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, sizeof(dest), &length,
-                                       NULL, LENGTHOF(src),
+                                       NULL, uprv_lengthof(src),
                                        0xfffd, &numSubstitutions, &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=0xffff) {
         log_err("u_strFromJavaModifiedUTF8WithSub(src=NULL) failed - %s\n", u_errorName(errorCode));
@@ -1981,7 +1979,7 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, sizeof(dest), &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0x110000, &numSubstitutions, &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=0xffff) {
         log_err("u_strFromJavaModifiedUTF8WithSub(subchar=U_SENTINEL) failed - %s\n", u_errorName(errorCode));
@@ -1990,7 +1988,7 @@ static void Test_strFromJavaModifiedUTF8() {
     errorCode=U_ZERO_ERROR;
     length=numSubstitutions=-5;
     p=u_strFromJavaModifiedUTF8WithSub(dest, sizeof(dest), &length,
-                                       (const char *)src, LENGTHOF(src),
+                                       (const char *)src, uprv_lengthof(src),
                                        0xdfff, &numSubstitutions, &errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || dest[0]!=0xffff) {
         log_err("u_strFromJavaModifiedUTF8WithSub(subchar is surrogate) failed - %s\n", u_errorName(errorCode));
@@ -2014,7 +2012,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromUTF8(dest16, LENGTHOF(dest16), &length, NULL, 0, &errorCode);
+    u_strFromUTF8(dest16, uprv_lengthof(dest16), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromUTF8(source=NULL, sourceLength=0) failed\n");
     }
@@ -2022,7 +2020,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromUTF8WithSub(dest16, LENGTHOF(dest16), &length, NULL, 0, 0xfffd, NULL, &errorCode);
+    u_strFromUTF8WithSub(dest16, uprv_lengthof(dest16), &length, NULL, 0, 0xfffd, NULL, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromUTF8WithSub(source=NULL, sourceLength=0) failed\n");
     }
@@ -2030,7 +2028,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromUTF8Lenient(dest16, LENGTHOF(dest16), &length, NULL, 0, &errorCode);
+    u_strFromUTF8Lenient(dest16, uprv_lengthof(dest16), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromUTF8Lenient(source=NULL, sourceLength=0) failed\n");
     }
@@ -2038,7 +2036,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromUTF32(dest16, LENGTHOF(dest16), &length, NULL, 0, &errorCode);
+    u_strFromUTF32(dest16, uprv_lengthof(dest16), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromUTF32(source=NULL, sourceLength=0) failed\n");
     }
@@ -2046,7 +2044,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromUTF32WithSub(dest16, LENGTHOF(dest16), &length, NULL, 0, 0xfffd, NULL, &errorCode);
+    u_strFromUTF32WithSub(dest16, uprv_lengthof(dest16), &length, NULL, 0, 0xfffd, NULL, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromUTF32WithSub(source=NULL, sourceLength=0) failed\n");
     }
@@ -2054,7 +2052,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromJavaModifiedUTF8WithSub(dest16, LENGTHOF(dest16), &length, NULL, 0, 0xfffd, NULL, &errorCode);
+    u_strFromJavaModifiedUTF8WithSub(dest16, uprv_lengthof(dest16), &length, NULL, 0, 0xfffd, NULL, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromJavaModifiedUTF8WithSub(source=NULL, sourceLength=0) failed\n");
     }
@@ -2064,7 +2062,7 @@ static void TestNullEmptySource() {
     dest8[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strToUTF8(dest8, LENGTHOF(dest8), &length, NULL, 0, &errorCode);
+    u_strToUTF8(dest8, uprv_lengthof(dest8), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest8[0]!=0 || dest8[1]!=3) {
         log_err("u_strToUTF8(source=NULL, sourceLength=0) failed\n");
     }
@@ -2072,7 +2070,7 @@ static void TestNullEmptySource() {
     dest8[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strToUTF8WithSub(dest8, LENGTHOF(dest8), &length, NULL, 0, 0xfffd, NULL, &errorCode);
+    u_strToUTF8WithSub(dest8, uprv_lengthof(dest8), &length, NULL, 0, 0xfffd, NULL, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest8[0]!=0 || dest8[1]!=3) {
         log_err("u_strToUTF8(source=NULL, sourceLength=0) failed\n");
     }
@@ -2080,7 +2078,7 @@ static void TestNullEmptySource() {
     dest32[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strToUTF32(dest32, LENGTHOF(dest32), &length, NULL, 0, &errorCode);
+    u_strToUTF32(dest32, uprv_lengthof(dest32), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest32[0]!=0 || dest32[1]!=3) {
         log_err("u_strToUTF32(source=NULL, sourceLength=0) failed\n");
     }
@@ -2088,7 +2086,7 @@ static void TestNullEmptySource() {
     dest32[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strToUTF32WithSub(dest32, LENGTHOF(dest32), &length, NULL, 0, 0xfffd, NULL, &errorCode);
+    u_strToUTF32WithSub(dest32, uprv_lengthof(dest32), &length, NULL, 0, 0xfffd, NULL, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest32[0]!=0 || dest32[1]!=3) {
         log_err("u_strToUTF32WithSub(source=NULL, sourceLength=0) failed\n");
     }
@@ -2096,7 +2094,7 @@ static void TestNullEmptySource() {
     dest8[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strToJavaModifiedUTF8(dest8, LENGTHOF(dest8), &length, NULL, 0, &errorCode);
+    u_strToJavaModifiedUTF8(dest8, uprv_lengthof(dest8), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest8[0]!=0 || dest8[1]!=3) {
         log_err("u_strToJavaModifiedUTF8(source=NULL, sourceLength=0) failed\n");
     }
@@ -2106,7 +2104,7 @@ static void TestNullEmptySource() {
     dest16[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strFromWCS(dest16, LENGTHOF(dest16), &length, NULL, 0, &errorCode);
+    u_strFromWCS(dest16, uprv_lengthof(dest16), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || dest16[0]!=0 || dest16[1]!=3) {
         log_err("u_strFromWCS(source=NULL, sourceLength=0) failed\n");
     }
@@ -2114,7 +2112,7 @@ static void TestNullEmptySource() {
     destW[0]=3;
     length=3;
     errorCode=U_ZERO_ERROR;
-    u_strToWCS(destW, LENGTHOF(destW), &length, NULL, 0, &errorCode);
+    u_strToWCS(destW, uprv_lengthof(destW), &length, NULL, 0, &errorCode);
     if(errorCode!=U_ZERO_ERROR || length!=0 || destW[0]!=0 || destW[1]!=3) {
         log_err("u_strToWCS(source=NULL, sourceLength=0) failed\n");
     }
index 6a9fb5b52c39296451cd4f949316a48132c26b80..09265ca921d69ebf0f88d142dbc4faeb1d0b0ff2 100644 (file)
 #include "unicode/ucnv.h"
 #include "unicode/uiter.h"
 #include "cintltst.h"
+#include "cmemory.h"
 #include <string.h>
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 /* get the sign of an integer */
 #define _SIGN(value) ((value)==0 ? 0 : ((int32_t)(value)>>31)|1)
 
@@ -719,12 +718,12 @@ TestSurrogateSearching() {
     if(
         first!=u_strchr(s, nul) ||
         first!=u_strchr32(s, nul) ||
-        first!=u_memchr(s, nul, LENGTHOF(s)) ||
-        first!=u_memchr32(s, nul, LENGTHOF(s)) ||
+        first!=u_memchr(s, nul, uprv_lengthof(s)) ||
+        first!=u_memchr32(s, nul, uprv_lengthof(s)) ||
         first!=u_strrchr(s, nul) ||
         first!=u_strrchr32(s, nul) ||
-        first!=u_memrchr(s, nul, LENGTHOF(s)) ||
-        first!=u_memrchr32(s, nul, LENGTHOF(s))
+        first!=u_memrchr(s, nul, uprv_lengthof(s)) ||
+        first!=u_memrchr32(s, nul, uprv_lengthof(s))
     ) {
         log_err("error: one of the u_str[|mem][r]chr[32](s, nul) does not find the terminator of s\n");
     }
@@ -734,13 +733,13 @@ TestSurrogateSearching() {
         s!=u_strstr(s, &nul) ||
         s!=u_strFindFirst(s, -1, &nul, -1) ||
         s!=u_strFindFirst(s, -1, &nul, 0) ||
-        s!=u_strFindFirst(s, LENGTHOF(s), &nul, -1) ||
-        s!=u_strFindFirst(s, LENGTHOF(s), &nul, 0) ||
+        s!=u_strFindFirst(s, uprv_lengthof(s), &nul, -1) ||
+        s!=u_strFindFirst(s, uprv_lengthof(s), &nul, 0) ||
         s!=u_strrstr(s, &nul) ||
         s!=u_strFindLast(s, -1, &nul, -1) ||
         s!=u_strFindLast(s, -1, &nul, 0) ||
-        s!=u_strFindLast(s, LENGTHOF(s), &nul, -1) ||
-        s!=u_strFindLast(s, LENGTHOF(s), &nul, 0)
+        s!=u_strFindLast(s, uprv_lengthof(s), &nul, -1) ||
+        s!=u_strFindLast(s, uprv_lengthof(s), &nul, 0)
     ) {
         log_err("error: one of the u_str[str etc](s, \"\") does not find s itself\n");
     }
@@ -1144,7 +1143,7 @@ TestCountChar32() {
     int32_t i, length, number;
 
     /* test u_strHasMoreChar32Than() with length>=0 */
-    length=LENGTHOF(string);
+    length=uprv_lengthof(string);
     while(length>=0) {
         for(i=0; i<=length; ++i) {
             for(number=-1; number<=((length-i)+2); ++number) {
@@ -1155,7 +1154,7 @@ TestCountChar32() {
     }
 
     /* test u_strHasMoreChar32Than() with NUL-termination (length=-1) */
-    length=LENGTHOF(string);
+    length=uprv_lengthof(string);
     u_memcpy(buffer, string, length);
     while(length>=0) {
         buffer[length]=0;
@@ -1454,7 +1453,7 @@ TestUCharIterator() {
     }
 
     /* test get/set state */
-    length=LENGTHOF(text)-1;
+    length=uprv_lengthof(text)-1;
     uiter_setString(&iter1, text, -1);
     uiter_setString(&iter2, text, length);
     testIteratorState(&iter1, &iter2, "UTF16IteratorState", length/2);
@@ -1477,7 +1476,7 @@ TestUCharIterator() {
     compareIterators(&iter1, "UTF16Iterator", &iter2, "UTF8Iterator_1");
 
     /* test get/set state */
-    length=LENGTHOF(text)-1;
+    length=uprv_lengthof(text)-1;
     uiter_setUTF8(&iter1, bytes, -1);
     testIteratorState(&iter1, &iter2, "UTF8IteratorState", length/2);
     testIteratorState(&iter1, &iter2, "UTF8IteratorStatePlus1", length/2+1);
index f459bf4ef91a3e16353e9b98eb84a3ce78c68332..eb087193c58f1028fa0199cb6ae99dcacc7b01b2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2013, International Business Machines
+ *   Copyright (C) 2003-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
 #include "unicode/ustring.h"
 #include "unicode/uidna.h"
 #include "cintltst.h"
+#include "cmemory.h"
 
-
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 #define MAX_DEST_SIZE 1000
 
 static void TestToUnicode(void);
@@ -723,8 +721,8 @@ static void TestLength(){
                         0xFE0F, 0xFEFF, 0x0000
                       };
 
-        int32_t len1 = LENGTHOF(ul1)-1/*remove the null termination*/;
-        int32_t destLen = LENGTHOF(dest);
+        int32_t len1 = uprv_lengthof(ul1)-1/*remove the null termination*/;
+        int32_t destLen = uprv_lengthof(dest);
         UErrorCode status = U_ZERO_ERROR;
         UParseError ps;
         int32_t len = (int32_t)strlen(cl);
@@ -735,14 +733,14 @@ static void TestLength(){
         }
 
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len = -1;
         destLen = uidna_toUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_ZERO_ERROR){
             log_err_status(status, "uidna_toUnicode failed with error %s.\n", u_errorName(status));
         }
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len = (int32_t)strlen(cl);
         destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_IDNA_LABEL_TOO_LONG_ERROR){
@@ -750,7 +748,7 @@ static void TestLength(){
         }
         
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len = -1;
         destLen = uidna_toASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_IDNA_LABEL_TOO_LONG_ERROR){
@@ -758,14 +756,14 @@ static void TestLength(){
         }
 
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_ZERO_ERROR){
             log_err_status(status, "uidna_toASCII failed with error %s.\n", u_errorName(status));
         }
         
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len1 = -1;
         destLen = uidna_toASCII(ul1, len1, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_ZERO_ERROR){
@@ -776,7 +774,7 @@ static void TestLength(){
         static const char* cl = "my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.my_very_very_long_and_incredibly_uncreative_domain_label.ibm.com";
         UChar ul[400] = {'\0'};
         UChar dest[400] = {'\0'};
-        int32_t destLen = LENGTHOF(dest);
+        int32_t destLen = uprv_lengthof(dest);
         UErrorCode status = U_ZERO_ERROR;
         UParseError ps;
         int32_t len = (int32_t)strlen(cl);
@@ -788,7 +786,7 @@ static void TestLength(){
         }
         
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len = -1;
         destLen = uidna_IDNToUnicode(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
@@ -796,7 +794,7 @@ static void TestLength(){
         }
         
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len = (int32_t)strlen(cl);
         destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
@@ -804,7 +802,7 @@ static void TestLength(){
         }
         
         status = U_ZERO_ERROR;
-        destLen = LENGTHOF(dest);
+        destLen = uprv_lengthof(dest);
         len = -1;
         destLen = uidna_IDNToASCII(ul, len, dest, destLen, UIDNA_DEFAULT, &ps, &status);
         if(status != U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR){
@@ -881,7 +879,7 @@ static void TestUTS46() {
 
     /* These calls should succeed. */
     length = uidna_labelToASCII(uts46, fA_sharps16, -1,
-                                dest16, LENGTHOF(dest16), &info, &errorCode);
+                                dest16, uprv_lengthof(dest16), &info, &errorCode);
     if( U_FAILURE(errorCode) || length != 4 || 0 != u_memcmp(dest16, fass16, 5) ||
         !info.isTransitionalDifferent || info.errors != 0
     ) {
@@ -889,7 +887,7 @@ static void TestUTS46() {
     }
     errorCode = U_ZERO_ERROR;
     length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16),
-                                  dest16, LENGTHOF(dest16), &info, &errorCode);
+                                  dest16, uprv_lengthof(dest16), &info, &errorCode);
     if( U_FAILURE(errorCode) || length != 3 || 0 != u_memcmp(dest16, fa_sharps16, 4) ||
         !info.isTransitionalDifferent || info.errors != 0
     ) {
@@ -916,7 +914,7 @@ static void TestUTS46() {
 
     errorCode = U_ZERO_ERROR;
     length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1,
-                                     dest8, LENGTHOF(dest8), &info, &errorCode);
+                                     dest8, uprv_lengthof(dest8), &info, &errorCode);
     if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fass8, 5) ||
         !info.isTransitionalDifferent || info.errors != 0
     ) {
@@ -924,7 +922,7 @@ static void TestUTS46() {
     }
     errorCode = U_ZERO_ERROR;
     length = uidna_labelToUnicodeUTF8(uts46, fA_sharps8, strlen(fA_sharps8),
-                                      dest8, LENGTHOF(dest8), &info, &errorCode);
+                                      dest8, uprv_lengthof(dest8), &info, &errorCode);
     if( U_FAILURE(errorCode) || length != 4 || 0 != memcmp(dest8, fa_sharps8, 5) ||
         !info.isTransitionalDifferent || info.errors != 0
     ) {
@@ -971,13 +969,13 @@ static void TestUTS46() {
     /* These calls should fail. */
     errorCode = U_USELESS_COLLATOR_ERROR;
     length = uidna_labelToASCII(uts46, fA_sharps16, -1,
-                                dest16, LENGTHOF(dest16), &info, &errorCode);
+                                dest16, uprv_lengthof(dest16), &info, &errorCode);
     if(errorCode != U_USELESS_COLLATOR_ERROR) {
         log_err("uidna_labelToASCII(failure) failed: %s\n", u_errorName(errorCode));
     }
     errorCode = U_ZERO_ERROR;
     length = uidna_labelToUnicode(uts46, fA_sharps16, u_strlen(fA_sharps16),
-                                  dest16, LENGTHOF(dest16), NULL, &errorCode);
+                                  dest16, uprv_lengthof(dest16), NULL, &errorCode);
     if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
         log_err("uidna_labelToUnicode(UIDNAInfo=NULL) failed: %s\n", u_errorName(errorCode));
     }
@@ -996,7 +994,7 @@ static void TestUTS46() {
 
     errorCode = U_ZERO_ERROR;
     length = uidna_labelToASCII_UTF8(uts46, fA_sharps8, -1,
-                                     NULL, LENGTHOF(dest8), &info, &errorCode);
+                                     NULL, uprv_lengthof(dest8), &info, &errorCode);
     if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
         log_err("uidna_labelToASCII_UTF8(dest=NULL) failed: %s\n", u_errorName(errorCode));
     }
index cfbeed82cd1dcc2b3a2956d9ca185a568ca3546c..cb08a51e028160ef885d7a8c5745af817a84bc26 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*****************************************************************************
@@ -21,6 +21,7 @@
 #include "unicode/ustring.h"
 #include "unicode/uset.h"
 #include "cintltst.h"
+#include "cmemory.h"
 
 #define MAX_LENGTH 999
 
@@ -33,7 +34,6 @@ static int32_t  gOutBufferSize = 0;
 static char     gNuConvTestName[1024];
 
 #define nct_min(x,y)  ((x<y) ? x : y)
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 static void printSeq(const unsigned char* a, int len);
 static void printSeqErr(const unsigned char* a, int len);
@@ -1792,7 +1792,7 @@ doTestTruncated(const char *cnvName, const uint8_t *bytes, int32_t length) {
     source=(const char *)bytes;
     sourceLimit=source+length;
     target=buffer;
-    targetLimit=buffer+LENGTHOF(buffer);
+    targetLimit=buffer+uprv_lengthof(buffer);
 
     /* 1. input bytes with flush=FALSE, then input nothing with flush=TRUE */
     ucnv_toUnicode(cnv, &target, targetLimit, &source, sourceLimit, NULL, FALSE, &errorCode);
@@ -1866,7 +1866,7 @@ TestTruncated() {
     };
     int32_t i;
 
-    for(i=0; i<LENGTHOF(testCases); ++i) {
+    for(i=0; i<uprv_lengthof(testCases); ++i) {
         doTestTruncated(testCases[i].cnvName, testCases[i].bytes, testCases[i].length);
     }
 }
@@ -1961,7 +1961,7 @@ TestUnicodeSet() {
     }
 
     /* test converters that are known to convert all of Unicode (except maybe for surrogates) */
-    for(i=0; i<LENGTHOF(completeSetNames); ++i) {
+    for(i=0; i<uprv_lengthof(completeSetNames); ++i) {
         errorCode=U_ZERO_ERROR;
         name=completeSetNames[i];
         cnv=ucnv_open(name, &errorCode);
@@ -1985,7 +1985,7 @@ TestUnicodeSet() {
 
 #if !UCONFIG_NO_LEGACY_CONVERSION
     /* test LMBCS variants which convert all of Unicode except for U+F6xx */
-    for(i=0; i<LENGTHOF(lmbcsNames); ++i) {
+    for(i=0; i<uprv_lengthof(lmbcsNames); ++i) {
         errorCode=U_ZERO_ERROR;
         name=lmbcsNames[i];
         cnv=ucnv_open(name, &errorCode);
@@ -2009,7 +2009,7 @@ TestUnicodeSet() {
 #endif
 
     /* test specific sets */
-    for(i=0; i<LENGTHOF(nameRanges); ++i) {
+    for(i=0; i<uprv_lengthof(nameRanges); ++i) {
         errorCode=U_ZERO_ERROR;
         name=nameRanges[i].name;
         cnv=ucnv_open(name, &errorCode);
index 61b11214beb9051e28d34de5a1980aec7b5a0e3f..adeb206ce34660074fc4a57365302876b299cb4d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2007, International Business Machines
+ *   Copyright (C) 2003-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -21,8 +21,8 @@
 #include "nfsprep.h"
 #include "ustr_imp.h"
 #include "cintltst.h"
+#include "cmemory.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 #define NFS4_MAX_BUFFER_SIZE 1000
 #define PREFIX_SUFFIX_SEPARATOR 0x0040 /* '@' */
 
@@ -195,7 +195,7 @@ getPrefixSuffix(const char *src, int32_t srcLength,
     *prefixLen = i;
     *suffixLen = srcLength - i;
     /* special prefixes must not be followed by suffixes! */
-    if((findStringIndex(special_prefixes,LENGTHOF(special_prefixes), *prefix, *prefixLen-1) != -1) && (*suffix != NULL)){
+    if((findStringIndex(special_prefixes,uprv_lengthof(special_prefixes), *prefix, *prefixLen-1) != -1) && (*suffix != NULL)){
         *status = U_PARSE_ERROR;
         return;
     }
index 08b98ffe03b3b8954ecec8df32f3d6112558c866..579322890466c86f6bf88479c6fad09bb3988689 100644 (file)
@@ -26,8 +26,6 @@
 #include "cmemory.h"
 #include "nucnvtst.h"
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 static void TestNextUChar(UConverter* cnv, const char* source, const char* limit, const int32_t results[], const char* message);
 static void TestNextUCharError(UConverter* cnv, const char* source, const char* limit, UErrorCode expected, const char* message);
 #if !UCONFIG_NO_COLLATION
@@ -5575,7 +5573,7 @@ TestIsFixedWidth() {
             "UTF16"
     };
 
-    for (i = 0; i < LENGTHOF(fixedWidth); i++) {
+    for (i = 0; i < uprv_lengthof(fixedWidth); i++) {
         cnv = ucnv_open(fixedWidth[i], &status);
         if (cnv == NULL || U_FAILURE(status)) {
             log_data_err("Error open converter: %s - %s \n", fixedWidth[i], u_errorName(status));
@@ -5588,7 +5586,7 @@ TestIsFixedWidth() {
         ucnv_close(cnv);
     }
 
-    for (i = 0; i < LENGTHOF(notFixedWidth); i++) {
+    for (i = 0; i < uprv_lengthof(notFixedWidth); i++) {
         cnv = ucnv_open(notFixedWidth[i], &status);
         if (cnv == NULL || U_FAILURE(status)) {
             log_data_err("Error open converter: %s - %s \n", notFixedWidth[i], u_errorName(status));
index e0f1a4b045429eeb75efa1b0ee214a4cda47aad3..d8f6ab5258716785de8d530b71b1af0ae7d5f014 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2003-2013, International Business Machines
+*   Copyright (C) 2003-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -25,8 +25,6 @@
 #include "cintltst.h"
 #include "uarrsort.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 static void
 SortTest() {
     uint16_t small[]={ 8, 1, 2, 5, 4, 3, 7, 6 };
@@ -39,12 +37,12 @@ SortTest() {
 
     /* sort small array (stable) */
     errorCode=U_ZERO_ERROR;
-    uprv_sortArray(small, LENGTHOF(small), sizeof(small[0]), uprv_uint16Comparator, NULL, TRUE, &errorCode);
+    uprv_sortArray(small, uprv_lengthof(small), sizeof(small[0]), uprv_uint16Comparator, NULL, TRUE, &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("uprv_sortArray(small) failed - %s\n", u_errorName(errorCode));
         return;
     }
-    for(i=1; i<LENGTHOF(small); ++i) {
+    for(i=1; i<uprv_lengthof(small); ++i) {
         if(small[i-1]>small[i]) {
             log_err("uprv_sortArray(small) mis-sorted [%d]=%u > [%d]=%u\n", i-1, small[i-1], i, small[i]);
             return;
@@ -52,17 +50,17 @@ SortTest() {
     }
 
     /* for medium, add bits that will not be compared, to test stability */
-    for(i=0; i<LENGTHOF(medium); ++i) {
+    for(i=0; i<uprv_lengthof(medium); ++i) {
         medium[i]=(medium[i]<<4)|i;
     }
 
     /* sort medium array (stable) */
-    uprv_sortArray(medium, LENGTHOF(medium), sizeof(medium[0]), uprv_int32Comparator, NULL, TRUE, &errorCode);
+    uprv_sortArray(medium, uprv_lengthof(medium), sizeof(medium[0]), uprv_int32Comparator, NULL, TRUE, &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("uprv_sortArray(medium) failed - %s\n", u_errorName(errorCode));
         return;
     }
-    for(i=1; i<LENGTHOF(medium); ++i) {
+    for(i=1; i<uprv_lengthof(medium); ++i) {
         if(medium[i-1]>=medium[i]) {
             log_err("uprv_sortArray(medium) mis-sorted [%d]=%u > [%d]=%u\n", i-1, medium[i-1], i, medium[i]);
             return;
@@ -71,12 +69,12 @@ SortTest() {
 
     /* sort large array (not stable) */
     errorCode=U_ZERO_ERROR;
-    uprv_sortArray(large, LENGTHOF(large), sizeof(large[0]), uprv_uint32Comparator, NULL, FALSE, &errorCode);
+    uprv_sortArray(large, uprv_lengthof(large), sizeof(large[0]), uprv_uint32Comparator, NULL, FALSE, &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("uprv_sortArray(large) failed - %s\n", u_errorName(errorCode));
         return;
     }
-    for(i=1; i<LENGTHOF(large); ++i) {
+    for(i=1; i<uprv_lengthof(large); ++i) {
         if(large[i-1]>large[i]) {
             log_err("uprv_sortArray(large) mis-sorted [%d]=%u > [%d]=%u\n", i-1, large[i-1], i, large[i]);
             return;
index fc3a9c4e7bebd4e829b57f7308abd6454bc5ff3c..9bd6f1dc0c62eb1e5918e1431239b5d7c6ddf5bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2010, International Business Machines
+ *   Copyright (C) 2003-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
@@ -25,9 +25,6 @@
 #include "cintltst.h"
 #include "nfsprep.h"
 
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void addUStringPrepTest(TestNode** root);
 void doStringPrepTest(const char* binFileName, const char* txtFileName, 
                  int32_t options, UErrorCode* errorCode);
@@ -444,7 +441,7 @@ Test_nfs4_mixed_prep(void){
         char src[MAX_BUFFER_SIZE];
         int32_t srcLen;
 
-        for(i=0; i< LENGTHOF(mixed_prep_data); i++){
+        for(i=0; i< uprv_lengthof(mixed_prep_data); i++){
             int32_t destLen=0;
             char* dest = NULL;
             UErrorCode status = U_ZERO_ERROR;
@@ -761,7 +758,7 @@ static void TestStringPrepProfiles(void) {
     int32_t i, testNum = 0;
     UStringPrepProfile *sprep = NULL;
     
-    for (i = 0; i < LENGTHOF(profile_test_case); i++) {
+    for (i = 0; i < uprv_lengthof(profile_test_case); i++) {
         if (uprv_strstr(profile_test_case[i], "RFC")) {
             if (sprep != NULL) {
                 usprep_close(sprep);
index ccd9c48e8eb04959163748781dc326d9b7091848..126892d9d5010fd3d1707b48553ed2ed7616a08b 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 2001-2008, International Business Machines
+*   Copyright (C) 2001-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -23,8 +23,6 @@
 #include "udataswp.h"
 #include "cintltst.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void addTrie2Test(TestNode** root);
 
 /* Values for setting possibly overlapping, out-of-order ranges of values */
@@ -1034,32 +1032,32 @@ checkRangesSingleValue[]={
 static void
 TrieTest(void) {
     testTrieRanges("set1", FALSE,
-        setRanges1, LENGTHOF(setRanges1),
-        checkRanges1, LENGTHOF(checkRanges1));
+        setRanges1, uprv_lengthof(setRanges1),
+        checkRanges1, uprv_lengthof(checkRanges1));
     testTrieRanges("set2-overlap", FALSE,
-        setRanges2, LENGTHOF(setRanges2),
-        checkRanges2, LENGTHOF(checkRanges2));
+        setRanges2, uprv_lengthof(setRanges2),
+        checkRanges2, uprv_lengthof(checkRanges2));
     testTrieRanges("set3-initial-9", FALSE,
-        setRanges3, LENGTHOF(setRanges3),
-        checkRanges3, LENGTHOF(checkRanges3));
+        setRanges3, uprv_lengthof(setRanges3),
+        checkRanges3, uprv_lengthof(checkRanges3));
     testTrieRanges("set-empty", FALSE,
         setRangesEmpty, 0,
-        checkRangesEmpty, LENGTHOF(checkRangesEmpty));
+        checkRangesEmpty, uprv_lengthof(checkRangesEmpty));
     testTrieRanges("set-single-value", FALSE,
-        setRangesSingleValue, LENGTHOF(setRangesSingleValue),
-        checkRangesSingleValue, LENGTHOF(checkRangesSingleValue));
+        setRangesSingleValue, uprv_lengthof(setRangesSingleValue),
+        checkRangesSingleValue, uprv_lengthof(checkRangesSingleValue));
 
     testTrieRanges("set2-overlap.withClone", TRUE,
-        setRanges2, LENGTHOF(setRanges2),
-        checkRanges2, LENGTHOF(checkRanges2));
+        setRanges2, uprv_lengthof(setRanges2),
+        checkRanges2, uprv_lengthof(checkRanges2));
 }
 
 static void
 EnumNewTrieForLeadSurrogateTest(void) {
     static const char *const testName="enum-for-lead";
     UTrie2 *trie=makeTrieWithRanges(testName, FALSE,
-                                    setRanges2, LENGTHOF(setRanges2),
-                                    checkRanges2, LENGTHOF(checkRanges2));
+                                    setRanges2, uprv_lengthof(setRanges2),
+                                    checkRanges2, uprv_lengthof(checkRanges2));
     while(trie!=NULL) {
         const CheckRange *checkRanges;
 
@@ -1130,7 +1128,7 @@ dummyTest(UTrie2ValueBits valueBits) {
         return;
     }
 
-    testFrozenTrie(testName, trie, valueBits, checkRanges, LENGTHOF(checkRanges));
+    testFrozenTrie(testName, trie, valueBits, checkRanges, uprv_lengthof(checkRanges));
     utrie2_close(trie);
 }
 
@@ -1191,7 +1189,7 @@ FreeBlocksTest(void) {
     }
 
     trie=testTrieSerializeAllValueBits(testName, trie, FALSE,
-                                       checkRanges, LENGTHOF(checkRanges));
+                                       checkRanges, uprv_lengthof(checkRanges));
     utrie2_close(trie);
 }
 
@@ -1249,7 +1247,7 @@ GrowDataArrayTest(void) {
     }
 
     trie=testTrieSerializeAllValueBits(testName, trie, FALSE,
-                                          checkRanges, LENGTHOF(checkRanges));
+                                          checkRanges, uprv_lengthof(checkRanges));
     utrie2_close(trie);
 }
 
@@ -1411,8 +1409,8 @@ testTrie2FromTrie1(const char *testName,
 static void
 Trie12ConversionTest(void) {
     testTrie2FromTrie1("trie1->trie2",
-                       setRanges2, LENGTHOF(setRanges2),
-                       checkRanges2, LENGTHOF(checkRanges2));
+                       setRanges2, uprv_lengthof(setRanges2),
+                       checkRanges2, uprv_lengthof(checkRanges2));
 }
 
 void
index 6497871f679a60629fd94a152ac82c08ecdc4564..75025695ee1ffffca8f46c787519a78c1ba555d8 100644 (file)
@@ -1,5 +1,5 @@
 /********************************************************************
- * Copyright (c) 1997-2011, International Business Machines
+ * Copyright (c) 1997-2014, International Business Machines
  * Corporation and others. All Rights Reserved.
  ********************************************************************
  *
@@ -24,8 +24,6 @@
 #include "cstring.h"
 #include "propsvec.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define FILENAME_BUFFER 1024
 
 #define TDSRCPATH  ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING
@@ -393,7 +391,7 @@ static void TestSelector()
     excluded_sets[i] = uset_open(i*30, i*30+500);
   }
 
-  for(testCaseIdx = 0; testCaseIdx < LENGTHOF(getEncodingsFns); testCaseIdx++)
+  for(testCaseIdx = 0; testCaseIdx < uprv_lengthof(getEncodingsFns); testCaseIdx++)
   {
     int32_t excluded_set_id;
     int32_t num_encodings;
@@ -411,7 +409,7 @@ static void TestSelector()
      * The handling of the exclusion set is independent of the
      * set of encodings, so there is no need to test every combination.
      */
-    excluded_set_id = testCaseIdx % LENGTHOF(excluded_sets);
+    excluded_set_id = testCaseIdx % uprv_lengthof(excluded_sets);
     {
       UConverterSelector *sel_rt, *sel_fb;
       char *buffer_fb = NULL;
@@ -469,7 +467,7 @@ static void TestSelector()
         verifyResult(ucnvsel_selectForUTF8(sel_rt, s, -1, &status), manual_rt);
         verifyResult(ucnvsel_selectForUTF8(sel_fb, s, -1, &status), manual_fb);
 
-        u_strFromUTF8(utf16, LENGTHOF(utf16), &length16, s, length8, &status);
+        u_strFromUTF8(utf16, uprv_lengthof(utf16), &length16, s, length8, &status);
         if (U_FAILURE(status)) {
           log_err("error converting the test text (string %ld) to UTF-16 - %s\n",
                   (long)text.number, u_errorName(status));
index bdcf8340fe180e9bb2183fece3a3c6c59715473f..7bc537369776d18119e52b1de7da66e85e4fa742 100644 (file)
@@ -55,8 +55,6 @@ unorm2_swap(const UDataSwapper *ds,
 
 /* other definitions and prototypes */
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
 static void TestUDataOpen(void);
 static void TestUDataOpenChoiceDemo1(void);
@@ -1688,7 +1686,7 @@ TestSwapData() {
     errorCode=U_ZERO_ERROR;
 #endif
 
-    for(i=0; i<LENGTHOF(swapCases); ++i) {
+    for(i=0; i<uprv_lengthof(swapCases); ++i) {
         /* build the name for logging */
         errorCode=U_ZERO_ERROR;
         if(swapCases[i].name[0]=='*') {
index 9565530b6b7f55ef4270097f8c7551917dd80c9f..d2b87f41d62df4c18c2932528a1c5b4d0dcbf4a0 100644 (file)
@@ -1,5 +1,5 @@
 /********************************************************************
- * Copyright (c) 2013, International Business Machines Corporation
+ * Copyright (c) 2014, International Business Machines Corporation
  * and others. All Rights Reserved.
  ********************************************************************/
 /* C API TEST FOR UREGION */
@@ -51,8 +51,6 @@ typedef struct KnownRegion {
   const char *containingContinent;
 } KnownRegion;
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 static KnownRegion knownRegions[] = {
     // Code, Num, Parent, Type,             Containing Continent
     { "TP" , 626, "035", URGN_TERRITORY, "142" },
index 6e321a3629421be687c85b8c822d08f5bc2bbc44..0cd897eb139e1d38fd007bfc567dc8b4fff569d8 100644 (file)
@@ -1,17 +1,16 @@
 /*
 **********************************************************************
-* Copyright (c) 2002-2009, International Business Machines
+* Copyright (c) 2002-2014, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 */
 #include "unicode/uset.h"
 #include "unicode/ustring.h"
 #include "cintltst.h"
+#include "cmemory.h"
 #include <stdlib.h>
 #include <string.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define TEST(x) addTest(root, &x, "uset/" # x)
 
 static void TestAPI(void);
@@ -492,7 +491,7 @@ TestSerialized() {
         return;
     }
 
-    length=uset_serialize(set, buffer, LENGTHOF(buffer), &errorCode);
+    length=uset_serialize(set, buffer, uprv_lengthof(buffer), &errorCode);
     if(U_FAILURE(errorCode)) {
         log_err("unable to uset_serialize([:Cf:]) - %s\n", u_errorName(errorCode));
         uset_close(set);
index 50dbb172af3abfe5a983a2d5625016d2396d1bec..b57d24bc2ca7b35a716d943b31321943e3ecb573 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1998-2012, International Business Machines Corporation and
+ * Copyright (c) 1998-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*
@@ -21,8 +21,6 @@
 #include "cintltst.h"
 #include <stdio.h>
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 static void printUChars(const UChar *uchars);
 
 static void TestCodeUnitValues(void);
@@ -742,7 +740,7 @@ static void TestAppend() {
     UBool isError, expectIsError, wrongIsError;
 
     length=0;
-    for(i=0; i<LENGTHOF(codePoints); ++i) {
+    for(i=0; i<uprv_lengthof(codePoints); ++i) {
         c=codePoints[i];
         if(c<0 || 0x10ffff<c) {
             continue; /* skip non-code points for U16_APPEND_UNSAFE */
@@ -750,24 +748,24 @@ static void TestAppend() {
 
         U16_APPEND_UNSAFE(buffer, length, c);
     }
-    if(length!=LENGTHOF(expectUnsafe) || 0!=memcmp(buffer, expectUnsafe, length*U_SIZEOF_UCHAR)) {
+    if(length!=uprv_lengthof(expectUnsafe) || 0!=memcmp(buffer, expectUnsafe, length*U_SIZEOF_UCHAR)) {
         log_err("U16_APPEND_UNSAFE did not generate the expected output\n");
     }
 
     length=0;
     wrongIsError=FALSE;
-    for(i=0; i<LENGTHOF(codePoints); ++i) {
+    for(i=0; i<uprv_lengthof(codePoints); ++i) {
         c=codePoints[i];
         expectIsError= c<0 || 0x10ffff<c; /* || U_IS_SURROGATE(c); */ /* surrogates in UTF-32 shouldn't be used, but it's okay to pass them around internally. */
         isError=FALSE;
 
-        U16_APPEND(buffer, length, LENGTHOF(buffer), c, isError);
+        U16_APPEND(buffer, length, uprv_lengthof(buffer), c, isError);
         wrongIsError|= isError!=expectIsError;
     }
     if(wrongIsError) {
         log_err("U16_APPEND did not set isError correctly\n");
     }
-    if(length!=LENGTHOF(expectSafe) || 0!=memcmp(buffer, expectSafe, length*U_SIZEOF_UCHAR)) {
+    if(length!=uprv_lengthof(expectSafe) || 0!=memcmp(buffer, expectSafe, length*U_SIZEOF_UCHAR)) {
         log_err("U16_APPEND did not generate the expected output\n");
     }
 }
index 88e1a091312090f2f181314b4724aa23575e20f8..228f4307af260521b511e3a007df50973d620bd2 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1998-2012, International Business Machines Corporation and
+ * Copyright (c) 1998-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*
@@ -18,8 +18,6 @@
 #include "cmemory.h"
 #include "cintltst.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* lenient UTF-8 ------------------------------------------------------------ */
 
 /*
@@ -101,7 +99,7 @@ static void TestCodeUnitValues()
     static const uint8_t codeunit[]={0x00, 0x65, 0x7e, 0x7f, 0xc0, 0xc4, 0xf0, 0xfd, 0x80, 0x81, 0xbc, 0xbe,};
 
     int16_t i;
-    for(i=0; i<LENGTHOF(codeunit); i++){
+    for(i=0; i<uprv_lengthof(codeunit); i++){
         uint8_t c=codeunit[i];
         log_verbose("Testing code unit value of %x\n", c);
         if(i<4){
@@ -144,7 +142,7 @@ static void TestCharLength()
 
     int16_t i;
     UBool multiple;
-    for(i=0; i<LENGTHOF(codepoint); i=(int16_t)(i+2)){
+    for(i=0; i<uprv_lengthof(codepoint); i=(int16_t)(i+2)){
         UChar32 c=codepoint[i+1];
         if(UTF8_CHAR_LENGTH(c) != (uint16_t)codepoint[i] || U8_LENGTH(c) != (uint16_t)codepoint[i]){
               log_err("The no: of code units for %lx:- Expected: %d Got: %d\n", c, codepoint[i], UTF8_CHAR_LENGTH(c));
@@ -542,14 +540,14 @@ static void TestNextPrevCharUnsafe() {
         }
     }
 
-    for(i=LENGTHOF(codePoints)-1, offset=sizeof(input); offset > 0; --i){
+    for(i=uprv_lengthof(codePoints)-1, offset=sizeof(input); offset > 0; --i){
          UTF8_PREV_CHAR_UNSAFE(input, offset, c);
          if(c != codePoints[i]){
              log_err("ERROR: UTF8_PREV_CHAR_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n",
                      offset, codePoints[i], c);
          }
     }
-    for(i=LENGTHOF(codePoints)-1, offset=sizeof(input); offset > 0; --i){
+    for(i=uprv_lengthof(codePoints)-1, offset=sizeof(input); offset > 0; --i){
          U8_PREV_UNSAFE(input, offset, c);
          if(c != codePoints[i]){
              log_err("ERROR: U8_PREV_UNSAFE failed for offset=%ld. Expected:%lx Got:%lx\n",
@@ -608,7 +606,7 @@ static void TestFwdBack() {
     }
 
     offsafe=0;
-    for(i=0; i<LENGTHOF(Nvalue); i++){
+    for(i=0; i<uprv_lengthof(Nvalue); i++){
         UTF8_FWD_N_SAFE(input, offsafe, sizeof(input), Nvalue[i]);
         if(offsafe != fwd_N_safe[i]){
             log_err("ERROR: Forward_N_safe offset=%d expected:%d, Got:%d\n", i, fwd_N_safe[i], offsafe);
@@ -617,7 +615,7 @@ static void TestFwdBack() {
     }
 
     offsafe=0;
-    for(i=0; i<LENGTHOF(Nvalue); i++){
+    for(i=0; i<uprv_lengthof(Nvalue); i++){
         U8_FWD_N(input, offsafe, sizeof(input), Nvalue[i]);
         if(offsafe != fwd_N_safe[i]){
             log_err("ERROR: U8_FWD_N offset=%d expected:%d, Got:%d\n", i, fwd_N_safe[i], offsafe);
@@ -626,7 +624,7 @@ static void TestFwdBack() {
     }
 
     offsafe=sizeof(input);
-    for(i=0; i<LENGTHOF(Nvalue); i++){
+    for(i=0; i<uprv_lengthof(Nvalue); i++){
         UTF8_BACK_N_SAFE(input, 0, offsafe, Nvalue[i]);
         if(offsafe != back_N_safe[i]){
             log_err("ERROR: backward_N_safe offset=%d expected:%d, Got:%ld\n", i, back_N_safe[i], offsafe);
@@ -634,7 +632,7 @@ static void TestFwdBack() {
     }
 
     offsafe=sizeof(input);
-    for(i=0; i<LENGTHOF(Nvalue); i++){
+    for(i=0; i<uprv_lengthof(Nvalue); i++){
         U8_BACK_N(input, 0, offsafe, Nvalue[i]);
         if(offsafe != back_N_safe[i]){
             log_err("ERROR: U8_BACK_N offset=%d expected:%d, Got:%ld\n", i, back_N_safe[i], offsafe);
@@ -660,40 +658,40 @@ static void TestFwdBackUnsafe() {
 
     int32_t offset;
     int32_t i;
-    for(i=1, offset=0; offset<LENGTHOF(input); ++i) {
+    for(i=1, offset=0; offset<uprv_lengthof(input); ++i) {
         UTF8_FWD_1_UNSAFE(input, offset);
         if(offset != boundaries[i]){
             log_err("ERROR: UTF8_FWD_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
         }
     }
-    for(i=1, offset=0; offset<LENGTHOF(input); ++i) {
+    for(i=1, offset=0; offset<uprv_lengthof(input); ++i) {
         U8_FWD_1_UNSAFE(input, offset);
         if(offset != boundaries[i]){
             log_err("ERROR: U8_FWD_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
         }
     }
 
-    for(i=LENGTHOF(boundaries)-2, offset=LENGTHOF(input); offset>0; --i) {
+    for(i=uprv_lengthof(boundaries)-2, offset=uprv_lengthof(input); offset>0; --i) {
         UTF8_BACK_1_UNSAFE(input, offset);
         if(offset != boundaries[i]){
             log_err("ERROR: UTF8_BACK_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
         }
     }
-    for(i=LENGTHOF(boundaries)-2, offset=LENGTHOF(input); offset>0; --i) {
+    for(i=uprv_lengthof(boundaries)-2, offset=uprv_lengthof(input); offset>0; --i) {
         U8_BACK_1_UNSAFE(input, offset);
         if(offset != boundaries[i]){
             log_err("ERROR: U8_BACK_1_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
         }
     }
 
-    for(i=0; i<LENGTHOF(boundaries); ++i) {
+    for(i=0; i<uprv_lengthof(boundaries); ++i) {
         offset=0;
         UTF8_FWD_N_UNSAFE(input, offset, i);
         if(offset != boundaries[i]) {
             log_err("ERROR: UTF8_FWD_N_UNSAFE offset expected:%d, Got:%d\n", boundaries[i], offset);
         }
     }
-    for(i=0; i<LENGTHOF(boundaries); ++i) {
+    for(i=0; i<uprv_lengthof(boundaries); ++i) {
         offset=0;
         U8_FWD_N_UNSAFE(input, offset, i);
         if(offset != boundaries[i]) {
@@ -701,17 +699,17 @@ static void TestFwdBackUnsafe() {
         }
     }
 
-    for(i=0; i<LENGTHOF(boundaries); ++i) {
-        int32_t j=LENGTHOF(boundaries)-1-i;
-        offset=LENGTHOF(input);
+    for(i=0; i<uprv_lengthof(boundaries); ++i) {
+        int32_t j=uprv_lengthof(boundaries)-1-i;
+        offset=uprv_lengthof(input);
         UTF8_BACK_N_UNSAFE(input, offset, i);
         if(offset != boundaries[j]) {
             log_err("ERROR: UTF8_BACK_N_UNSAFE offset expected:%d, Got:%d\n", boundaries[j], offset);
         }
     }
-    for(i=0; i<LENGTHOF(boundaries); ++i) {
-        int32_t j=LENGTHOF(boundaries)-1-i;
-        offset=LENGTHOF(input);
+    for(i=0; i<uprv_lengthof(boundaries); ++i) {
+        int32_t j=uprv_lengthof(boundaries)-1-i;
+        offset=uprv_lengthof(input);
         U8_BACK_N_UNSAFE(input, offset, i);
         if(offset != boundaries[j]) {
             log_err("ERROR: U8_BACK_N_UNSAFE offset expected:%d, Got:%d\n", boundaries[j], offset);
@@ -729,8 +727,8 @@ static void TestSetChar() {
 
     uint32_t i=0;
     int32_t offset=0, setOffset=0;
-    for(offset=0; offset<=LENGTHOF(input); offset++){
-        if (offset<LENGTHOF(input)){
+    for(offset=0; offset<=uprv_lengthof(input); offset++){
+        if (offset<uprv_lengthof(input)){
             setOffset=offset;
             UTF8_SET_CHAR_START_SAFE(input, 0, setOffset);
             if(setOffset != start_safe[i]){
@@ -770,8 +768,8 @@ static void TestSetCharUnsafe() {
 
     uint32_t i=0;
     int32_t offset=0, setOffset=0;
-    for(offset=0; offset<=LENGTHOF(input); offset++){
-        if (offset<LENGTHOF(input)){
+    for(offset=0; offset<=uprv_lengthof(input); offset++){
+        if (offset<uprv_lengthof(input)){
             setOffset=offset;
             UTF8_SET_CHAR_START_UNSAFE(input, setOffset);
             if(setOffset != start_unsafe[i]){
@@ -911,8 +909,8 @@ static void TestAppendChar(){
     uint8_t str[12];
     uint32_t offset;
 /*    UChar32 c=0;*/
-    uint16_t size=LENGTHOF(s);
-    for(i=0; i<LENGTHOF(test); i=(uint16_t)(i+2)){
+    uint16_t size=uprv_lengthof(s);
+    for(i=0; i<uprv_lengthof(test); i=(uint16_t)(i+2)){
         uprv_memcpy(str, s, size);
         offset=test[i];
         if(count<13){
@@ -1003,7 +1001,7 @@ static void TestAppend() {
     UBool isError, expectIsError, wrongIsError;
 
     length=0;
-    for(i=0; i<LENGTHOF(codePoints); ++i) {
+    for(i=0; i<uprv_lengthof(codePoints); ++i) {
         c=codePoints[i];
         if(c<0 || 0x10ffff<c) {
             continue; /* skip non-code points for U8_APPEND_UNSAFE */
@@ -1011,24 +1009,24 @@ static void TestAppend() {
 
         U8_APPEND_UNSAFE(buffer, length, c);
     }
-    if(length!=LENGTHOF(expectUnsafe) || 0!=memcmp(buffer, expectUnsafe, length)) {
+    if(length!=uprv_lengthof(expectUnsafe) || 0!=memcmp(buffer, expectUnsafe, length)) {
         log_err("U8_APPEND_UNSAFE did not generate the expected output\n");
     }
 
     length=0;
     wrongIsError=FALSE;
-    for(i=0; i<LENGTHOF(codePoints); ++i) {
+    for(i=0; i<uprv_lengthof(codePoints); ++i) {
         c=codePoints[i];
         expectIsError= c<0 || 0x10ffff<c || U_IS_SURROGATE(c);
         isError=FALSE;
 
-        U8_APPEND(buffer, length, LENGTHOF(buffer), c, isError);
+        U8_APPEND(buffer, length, uprv_lengthof(buffer), c, isError);
         wrongIsError|= isError!=expectIsError;
     }
     if(wrongIsError) {
         log_err("U8_APPEND did not set isError correctly\n");
     }
-    if(length!=LENGTHOF(expectSafe) || 0!=memcmp(buffer, expectSafe, length)) {
+    if(length!=uprv_lengthof(expectSafe) || 0!=memcmp(buffer, expectSafe, length)) {
         log_err("U8_APPEND did not generate the expected output\n");
     }
 }
@@ -1051,7 +1049,7 @@ TestSurrogates() {
     int32_t i, j, k, iu, is, il, length;
 
     k=0; /* index into cp[] */
-    length=LENGTHOF(b);
+    length=uprv_lengthof(b);
     for(i=0; i<length;) {
         j=i;
         U8_NEXT_UNSAFE(b, j, cu);
index 9213077f8fa30026c811d572e1b25770885eb790..5bee4f2c57e316bcaca9c1a28427d5b2565f632c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  ****************************************************************************
- * Copyright (c) 1997-2013, International Business Machines Corporation and *
+ * Copyright (c) 1997-2014, International Business Machines Corporation and *
  * others. All Rights Reserved.                                             *
  ****************************************************************************
  */
 #include "unicode/ucal.h"
 
 #include "cintltst.h"
+#include "cmemory.h"
 
 #include <stdlib.h>
 #include <time.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define LOOP_COUNT 10000
 
 static void TestAPI(void);
@@ -461,7 +460,7 @@ TestDotNet() {
         ucal_close(cal);
         return;
     }
-    for(i = 0; i < LENGTHOF(dotNetDateTimeTicks); ++i) {
+    for(i = 0; i < uprv_lengthof(dotNetDateTimeTicks); ++i) {
         /* Test conversion from .Net/Universal time to ICU time. */
         dt = dotNetDateTimeTicks + i;
         millis = utmscale_toInt64(dt->ticks, UDTS_ICU4C_TIME, &errorCode);
index 41761de61ce5350329189b469ced9049d36f114b..908e84db9478bbe7b21e7043b25563c88afdbbdd 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "intltest.h"
 #include "alphaindextst.h"
+#include "cmemory.h"
 
 #include "unicode/alphaindex.h"
 #include "unicode/coll.h"
@@ -25,8 +26,6 @@
 // #include <string>
 // #include <iostream>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 namespace {
 
 UnicodeString joinLabelsAndAppend(AlphabeticIndex::ImmutableIndex &index, UnicodeString &dest) {
@@ -317,7 +316,7 @@ void AlphabeticIndexTest::APITest() {
     // if Russian sorts Cyrillic first.
     int32_t reorderCodes[20];
     int32_t expectedLatinIndex = 0;
-    if (index->getCollator().getReorderCodes(reorderCodes, LENGTHOF(reorderCodes), status) > 0) {
+    if (index->getCollator().getReorderCodes(reorderCodes, uprv_lengthof(reorderCodes), status) > 0) {
         expectedLatinIndex = index->getBucketCount(status) - 1;
     }
     n = index->getBucketIndex(adam, status);
@@ -533,7 +532,7 @@ static const char *localeAndIndexCharactersLists[][2] = {
 
 void AlphabeticIndexTest::TestIndexCharactersList() {
     UErrorCode status = U_ZERO_ERROR;
-    for (int32_t i = 0; i < LENGTHOF(localeAndIndexCharactersLists); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(localeAndIndexCharactersLists); ++i) {
         const char *(&localeAndIndexCharacters)[2] = localeAndIndexCharactersLists[i];
         const char *locale = localeAndIndexCharacters[0];
         UnicodeString expectedIndexCharacters
@@ -562,7 +561,7 @@ void AlphabeticIndexTest::TestHaniFirst() {
         return;
     }
     int32_t reorderCodes[] = { USCRIPT_HAN };
-    coll->setReorderCodes(reorderCodes, LENGTHOF(reorderCodes), status);
+    coll->setReorderCodes(reorderCodes, uprv_lengthof(reorderCodes), status);
     TEST_CHECK_STATUS; 
     AlphabeticIndex index(coll.orphan(), status);
     TEST_CHECK_STATUS; 
@@ -591,7 +590,7 @@ void AlphabeticIndexTest::TestPinyinFirst() {
         return;
     }
     int32_t reorderCodes[] = { USCRIPT_HAN };
-    coll->setReorderCodes(reorderCodes, LENGTHOF(reorderCodes), status);
+    coll->setReorderCodes(reorderCodes, uprv_lengthof(reorderCodes), status);
     TEST_CHECK_STATUS;
     AlphabeticIndex index(coll.orphan(), status);
     TEST_CHECK_STATUS;
@@ -640,7 +639,7 @@ void AlphabeticIndexTest::TestSchSt() {
         { "Steiff", 22, "St" },
         { "Thomas", 23, "T" }
     };
-    for (int32_t i = 0; i < LENGTHOF(testCases); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(testCases); ++i) {
         const TestCase &testCase = testCases[i];
         UnicodeString name = UnicodeString(testCase.name).unescape();
         UnicodeString label = UnicodeString(testCase.bucketLabel).unescape();
@@ -673,7 +672,7 @@ void AlphabeticIndexTest::TestNoLabels() {
 void AlphabeticIndexTest::TestChineseZhuyin() {
     UErrorCode status = U_ZERO_ERROR;
     char loc[100];
-    uloc_forLanguageTag("zh-u-co-zhuyin", loc, LENGTHOF(loc), NULL, &status);
+    uloc_forLanguageTag("zh-u-co-zhuyin", loc, uprv_lengthof(loc), NULL, &status);
     AlphabeticIndex index(loc, status);
     LocalPointer<AlphabeticIndex::ImmutableIndex> immIndex(index.buildImmutableIndex(status));
     TEST_CHECK_STATUS; 
@@ -694,7 +693,7 @@ void AlphabeticIndexTest::TestJapaneseKanji() {
     // They should all go into the overflow bucket.
     static const UChar32 kanji[] = { 0x4E9C, 0x95C7, 0x4E00, 0x58F1 };
     int32_t overflowIndex = immIndex->getBucketCount() - 1;
-    for(int32_t i = 0; i < LENGTHOF(kanji); ++i) {
+    for(int32_t i = 0; i < uprv_lengthof(kanji); ++i) {
         char msg[40];
         sprintf(msg, "kanji[%d]=U+%04lX in overflow bucket", (int)i, (long)kanji[i]);
         assertEquals(msg, overflowIndex, immIndex->getBucketIndex(UnicodeString(kanji[i]), status));
index ec3a1c54eda0e4100bd4b5a6a375dba050a65ad7..32a6c74d82691949a330c3eaf37d285f35cf6ac3 100644 (file)
@@ -46,8 +46,6 @@
 #include "cmemory.h"
 #include <stdlib.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void
 CollationAPITest::doAssert(UBool condition, const char *message)
 {
@@ -1244,10 +1242,10 @@ void CollationAPITest::TestSortKeyOverflow() {
     // 2 bytes for the Cyrillic i, 1 byte for the primary-compression terminator,
     // 2 bytes for the Greek phi, and 1 byte for the NUL terminator.
     uint8_t sortKey[12];
-    int32_t length = col->getSortKey(i_and_phi, 2, sortKey, LENGTHOF(sortKey));
+    int32_t length = col->getSortKey(i_and_phi, 2, sortKey, uprv_lengthof(sortKey));
     uint8_t sortKey2[12];
     for (int32_t capacity = 0; capacity < length; ++capacity) {
-        uprv_memset(sortKey2, 2, LENGTHOF(sortKey2));
+        uprv_memset(sortKey2, 2, uprv_lengthof(sortKey2));
         int32_t length2 = col->getSortKey(i_and_phi, 2, sortKey2, capacity);
         if (length2 != length || 0 != uprv_memcmp(sortKey, sortKey2, capacity)) {
             errln("getSortKey(i_and_phi, capacity=%d) failed to write proper prefix", capacity);
@@ -1663,7 +1661,7 @@ void CollationAPITest::TestGetLocale() {
   u_unescape(rules, rlz, 256);
 
   /* test opening collators for different locales */
-  for(i = 0; i<(int32_t)LENGTHOF(testStruct); i++) {
+  for(i = 0; i<(int32_t)uprv_lengthof(testStruct); i++) {
     status = U_ZERO_ERROR;
     coll = Collator::createInstance(testStruct[i].requestedLocale, status);
     if(U_FAILURE(status)) {
@@ -1921,7 +1919,7 @@ void CollationAPITest::TestGetTailoredSet()
   UnicodeString buff; 
   UnicodeSet *set = NULL;
 
-  for(i = 0; i < LENGTHOF(setTest); i++) {
+  for(i = 0; i < uprv_lengthof(setTest); i++) {
     buff = UnicodeString(setTest[i].rules, -1, US_INV).unescape();
     RuleBasedCollator coll(buff, status);
     if(U_SUCCESS(status)) {
@@ -2372,7 +2370,7 @@ void CollationAPITest::TestCloneBinary() {
     UnicodeString ue = UNICODE_STRING_SIMPLE("ue");
     assertEquals("rbc/primary: u-umlaut==ue", UCOL_EQUAL, rbc->compare(uUmlaut, ue, errorCode));
     uint8_t bin[25000];
-    int32_t binLength = rbc->cloneBinary(bin, LENGTHOF(bin), errorCode);
+    int32_t binLength = rbc->cloneBinary(bin, uprv_lengthof(bin), errorCode);
     if(errorCode.logDataIfFailureAndReset("rbc->cloneBinary()")) {
         return;
     }
@@ -2386,7 +2384,7 @@ void CollationAPITest::TestCloneBinary() {
     assertEquals("rbc2: u-umlaut==ue", UCOL_EQUAL, rbc2.compare(uUmlaut, ue, errorCode));
     assertTrue("rbc==rbc2", *rbc == rbc2);
     uint8_t bin2[25000];
-    int32_t bin2Length = rbc2.cloneBinary(bin2, LENGTHOF(bin2), errorCode);
+    int32_t bin2Length = rbc2.cloneBinary(bin2, uprv_lengthof(bin2), errorCode);
     assertEquals("len(rbc binary)==len(rbc2 binary)", binLength, bin2Length);
     assertTrue("rbc binary==rbc2 binary", binLength == bin2Length && memcmp(bin, bin2, binLength) == 0);
 
index bc24714f60c9e2f665403a4e7543dfe26486cefe..82cefddc4527a88886b0115b0ca1cf16c4193a7b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2010-2013, International Business Machines
+*   Copyright (C) 2010-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  bytetrietest.cpp
@@ -20,8 +20,7 @@
 #include "unicode/localpointer.h"
 #include "unicode/stringpiece.h"
 #include "intltest.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 struct StringAndValue {
     const char *s;
@@ -129,14 +128,14 @@ void BytesTrieTest::TestEmpty() {
     static const StringAndValue data[]={
         { "", 0 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::Test_a() {
     static const StringAndValue data[]={
         { "a", 1 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::Test_a_ab() {
@@ -144,7 +143,7 @@ void BytesTrieTest::Test_a_ab() {
         { "a", 1 },
         { "ab", 100 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestShortestBranch() {
@@ -152,7 +151,7 @@ void BytesTrieTest::TestShortestBranch() {
         { "a", 1000 },
         { "b", 2000 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestBranches() {
@@ -172,7 +171,7 @@ void BytesTrieTest::TestBranches() {
         { "vv", 0x7fffffff },
         { "zz", (int32_t)0x80000000 }
     };
-    for(int32_t length=2; length<=LENGTHOF(data); ++length) {
+    for(int32_t length=2; length<=uprv_lengthof(data); ++length) {
         logln("TestBranches length=%d", (int)length);
         checkData(data, length);
     }
@@ -191,7 +190,7 @@ void BytesTrieTest::TestLongSequence() {
           "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
           "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -3 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestLongBranch() {
@@ -219,7 +218,7 @@ void BytesTrieTest::TestLongBranch() {
         { "t234567890", 0x77777777 },
         { "z", (int32_t)0x80000001 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestValuesForState() {
@@ -233,7 +232,7 @@ void BytesTrieTest::TestValuesForState() {
         { "abcde", -5 },
         { "abcdef", -6 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestCompact() {
@@ -260,7 +259,7 @@ void BytesTrieTest::TestCompact() {
         { "xjuly", 7 },
         { "xjune", 6 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 BytesTrie *BytesTrieTest::buildMonthsTrie(UStringTrieBuildOption buildOption) {
@@ -300,7 +299,7 @@ BytesTrie *BytesTrieTest::buildMonthsTrie(UStringTrieBuildOption buildOption) {
         { "jun.", 6 },
         { "june", 6 }
     };
-    return buildTrie(data, LENGTHOF(data), buildOption);
+    return buildTrie(data, uprv_lengthof(data), buildOption);
 }
 
 void BytesTrieTest::TestHasUniqueValue() {
@@ -345,7 +344,7 @@ void BytesTrieTest::TestGetNextBytes() {
         return;  // buildTrie() reported an error
     }
     char buffer[40];
-    CheckedArrayByteSink sink(buffer, LENGTHOF(buffer));
+    CheckedArrayByteSink sink(buffer, uprv_lengthof(buffer));
     int32_t count=trie->getNextBytes(sink);
     if(count!=2 || sink.NumberOfBytesAppended()!=2 || buffer[0]!='a' || buffer[1]!='j') {
         errln("months getNextBytes()!=[aj] at root");
@@ -431,10 +430,10 @@ void BytesTrieTest::TestIteratorFromBranch() {
         { "uar", 1 },
         { "uary", 1 }
     };
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), data, LENGTHOF(data));
+    checkIterator(iter.reset(), data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestIteratorFromLinearMatch() {
@@ -459,10 +458,10 @@ void BytesTrieTest::TestIteratorFromLinearMatch() {
         { "r", 1 },
         { "ry", 1 }
     };
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), data, LENGTHOF(data));
+    checkIterator(iter.reset(), data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestTruncatingIteratorFromRoot() {
@@ -505,10 +504,10 @@ void BytesTrieTest::TestTruncatingIteratorFromRoot() {
         { "jun.", 6 },
         { "june", 6 }
     };
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), data, LENGTHOF(data));
+    checkIterator(iter.reset(), data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::TestTruncatingIteratorFromLinearMatchShort() {
@@ -517,7 +516,7 @@ void BytesTrieTest::TestTruncatingIteratorFromLinearMatchShort() {
         { "abcdepq", 200 },
         { "abcdeyz", 3000 }
     };
-    LocalPointer<BytesTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
+    LocalPointer<BytesTrie> trie(buildTrie(data, uprv_lengthof(data), USTRINGTRIE_BUILD_FAST));
     if(trie.isNull()) {
         return;  // buildTrie() reported an error
     }
@@ -533,10 +532,10 @@ void BytesTrieTest::TestTruncatingIteratorFromLinearMatchShort() {
     static const StringAndValue expected[]={
         { "cd", -1 }
     };
-    checkIterator(iter, expected, LENGTHOF(expected));
+    checkIterator(iter, expected, uprv_lengthof(expected));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), expected, LENGTHOF(expected));
+    checkIterator(iter.reset(), expected, uprv_lengthof(expected));
 }
 
 void BytesTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
@@ -545,7 +544,7 @@ void BytesTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
         { "abcdepq", 200 },
         { "abcdeyz", 3000 }
     };
-    LocalPointer<BytesTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
+    LocalPointer<BytesTrie> trie(buildTrie(data, uprv_lengthof(data), USTRINGTRIE_BUILD_FAST));
     if(trie.isNull()) {
         return;  // buildTrie() reported an error
     }
@@ -564,10 +563,10 @@ void BytesTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
         { "dep", -1 },
         { "dey", -1 }
     };
-    checkIterator(iter, expected, LENGTHOF(expected));
+    checkIterator(iter, expected, uprv_lengthof(expected));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), expected, LENGTHOF(expected));
+    checkIterator(iter.reset(), expected, uprv_lengthof(expected));
 }
 
 void BytesTrieTest::TestIteratorFromBytes() {
@@ -578,12 +577,12 @@ void BytesTrieTest::TestIteratorFromBytes() {
     };
     builder_->clear();
     IcuTestErrorCode errorCode(*this, "TestIteratorFromBytes()");
-    for(int32_t i=0; i<LENGTHOF(data); ++i) {
+    for(int32_t i=0; i<uprv_lengthof(data); ++i) {
         builder_->add(data[i].s, data[i].value, errorCode);
     }
     StringPiece trieBytes=builder_->buildStringPiece(USTRINGTRIE_BUILD_FAST, errorCode);
     BytesTrie::Iterator iter(trieBytes.data(), 0, errorCode);
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
 }
 
 void BytesTrieTest::checkData(const StringAndValue data[], int32_t dataLength) {
index bc9d7439238dc3e4c818d339e186a5ecf5956d2a..08b76e3f156e8a329eb238cf5f75c9bcbebc4281 100644 (file)
@@ -1,6 +1,6 @@
 /****************************************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  * Modification History:
  *
@@ -20,6 +20,7 @@
 #include "unicode/putil.h"
 #include "unicode/utf16.h"
 #include "citrtest.h"
+#include "cmemory.h"
 
 
 class  SCharacterIterator : public CharacterIterator {
@@ -139,8 +140,6 @@ private:
 };
 const char SCharacterIterator::fgClassID=0;
 
-#define LENGTHOF(array) ((int32_t)(sizeof(array)/sizeof((array)[0])))
-
 CharIterTest::CharIterTest()
 {
 }
@@ -967,7 +966,7 @@ class SubCharIter : public CharacterIterator {
 public:
     // public default constructor, to get coverage of CharacterIterator()
     SubCharIter() : CharacterIterator() {
-        textLength=end=LENGTHOF(s);
+        textLength=end=uprv_lengthof(s);
         s[0]=0x61;      // 'a'
         s[1]=0xd900;    // U+50400
         s[2]=0xdd00;
@@ -976,7 +975,7 @@ public:
 
     // useful stuff, mostly dummy but testing coverage and subclassability
     virtual UChar nextPostInc() {
-        if(pos<LENGTHOF(s)) {
+        if(pos<uprv_lengthof(s)) {
             return s[pos++];
         } else {
             return DONE;
@@ -984,9 +983,9 @@ public:
     }
 
     virtual UChar32 next32PostInc() {
-        if(pos<LENGTHOF(s)) {
+        if(pos<uprv_lengthof(s)) {
             UChar32 c;
-            U16_NEXT(s, pos, LENGTHOF(s), c);
+            U16_NEXT(s, pos, uprv_lengthof(s), c);
             return c;
         } else {
             return DONE;
@@ -994,7 +993,7 @@ public:
     }
 
     virtual UBool hasNext() {
-        return pos<LENGTHOF(s);
+        return pos<uprv_lengthof(s);
     }
 
     virtual UChar first() {
@@ -1005,15 +1004,15 @@ public:
     virtual UChar32 first32() {
         UChar32 c;
         pos=0;
-        U16_NEXT(s, pos, LENGTHOF(s), c);
+        U16_NEXT(s, pos, uprv_lengthof(s), c);
         pos=0;
         return c;
     }
 
     virtual UChar setIndex(int32_t position) {
-        if(0<=position && position<=LENGTHOF(s)) {
+        if(0<=position && position<=uprv_lengthof(s)) {
             pos=position;
-            if(pos<LENGTHOF(s)) {
+            if(pos<uprv_lengthof(s)) {
                 return s[pos];
             }
         }
@@ -1021,11 +1020,11 @@ public:
     }
 
     virtual UChar32 setIndex32(int32_t position) {
-        if(0<=position && position<=LENGTHOF(s)) {
+        if(0<=position && position<=uprv_lengthof(s)) {
             pos=position;
-            if(pos<LENGTHOF(s)) {
+            if(pos<uprv_lengthof(s)) {
                 UChar32 c;
-                U16_GET(s, 0, pos, LENGTHOF(s), c);
+                U16_GET(s, 0, pos, uprv_lengthof(s), c);
                 return c;
             }
         }
@@ -1033,7 +1032,7 @@ public:
     }
 
     virtual UChar current() const {
-        if(pos<LENGTHOF(s)) {
+        if(pos<uprv_lengthof(s)) {
             return s[pos];
         } else {
             return DONE;
@@ -1041,9 +1040,9 @@ public:
     }
 
     virtual UChar32 current32() const {
-        if(pos<LENGTHOF(s)) {
+        if(pos<uprv_lengthof(s)) {
             UChar32 c;
-            U16_GET(s, 0, pos, LENGTHOF(s), c);
+            U16_GET(s, 0, pos, uprv_lengthof(s), c);
             return c;
         } else {
             return DONE;
@@ -1051,7 +1050,7 @@ public:
     }
 
     virtual UChar next() {
-        if(pos<LENGTHOF(s) && ++pos<LENGTHOF(s)) {
+        if(pos<uprv_lengthof(s) && ++pos<uprv_lengthof(s)) {
             return s[pos];
         } else {
             return DONE;
@@ -1059,13 +1058,13 @@ public:
     }
 
     virtual UChar32 next32() {
-        if(pos<LENGTHOF(s)) {
-            U16_FWD_1(s, pos, LENGTHOF(s));
+        if(pos<uprv_lengthof(s)) {
+            U16_FWD_1(s, pos, uprv_lengthof(s));
         }
-        if(pos<LENGTHOF(s)) {
+        if(pos<uprv_lengthof(s)) {
             UChar32 c;
             int32_t i=pos;
-            U16_NEXT(s, i, LENGTHOF(s), c);
+            U16_NEXT(s, i, uprv_lengthof(s), c);
             return c;
         } else {
             return DONE;
@@ -1077,7 +1076,7 @@ public:
     }
 
     virtual void getText(UnicodeString &result) {
-        result.setTo(s, LENGTHOF(s));
+        result.setTo(s, uprv_lengthof(s));
     }
 
     // dummy implementations of other pure virtual base class functions
index 146a09fa65107d322a72efcc33610b84e57c0156..a1e27670abd51d09d12cc66dbe182eba6ff4ad65 100644 (file)
@@ -48,8 +48,6 @@
 #include "uvectr64.h"
 #include "writesrc.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // TODO: Move to ucbuf.h
 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCHARBUFPointer, UCHARBUF, ucbuf_close);
 
@@ -230,7 +228,7 @@ void CollationTest::TestImplicits() {
     UChar32 prev = 0;
     uint32_t prevPrimary = 0;
     UTF16CollationIterator ci(cd, FALSE, NULL, NULL, NULL);
-    for(int32_t i = 0; i < LENGTHOF(sets); ++i) {
+    for(int32_t i = 0; i < uprv_lengthof(sets); ++i) {
         LocalPointer<UnicodeSetIterator> iter(new UnicodeSetIterator(*sets[i]));
         while(iter->next()) {
             UChar32 c = iter->getCodepoint();
@@ -310,7 +308,7 @@ void CollationTest::TestIllegalUTF8() {
     };
 
     StringPiece fffd(strings[0]);
-    for(int32_t i = 1; i < LENGTHOF(strings); ++i) {
+    for(int32_t i = 1; i < uprv_lengthof(strings); ++i) {
         StringPiece illegal(strings[i]);
         UCollationResult order = coll->compareUTF8(fffd, illegal, errorCode);
         if(order != UCOL_EQUAL) {
@@ -481,7 +479,7 @@ void CollationTest::TestFCD() {
     if(errorCode.logIfFailureAndReset("FCDUTF16CollationIterator constructor")) {
         return;
     }
-    CodePointIterator cpi(cp, LENGTHOF(cp));
+    CodePointIterator cpi(cp, uprv_lengthof(cp));
     checkFCD("FCDUTF16CollationIterator", u16ci, cpi);
 
 #if U_HAVE_STD_STRING
@@ -498,7 +496,7 @@ void CollationTest::TestFCD() {
 
     cpi.resetToStart();
     UCharIterator iter;
-    uiter_setString(&iter, s, LENGTHOF(s) - 1);  // -1: without the terminating NUL
+    uiter_setString(&iter, s, uprv_lengthof(s) - 1);  // -1: without the terminating NUL
     FCDUIterCollationIterator uici(data, FALSE, iter, 0);
     if(errorCode.logIfFailureAndReset("FCDUIterCollationIterator constructor")) {
         return;
@@ -1140,7 +1138,7 @@ void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
 
     UColAttribute attr;
     for(int32_t i = 0;; ++i) {
-        if(i == LENGTHOF(attributes)) {
+        if(i == uprv_lengthof(attributes)) {
             errln("invalid attribute name on line %d", (int)fileLineNumber);
             infoln(fileLine);
             errorCode.set(U_PARSE_ERROR);
@@ -1154,7 +1152,7 @@ void CollationTest::parseAndSetAttribute(IcuTestErrorCode &errorCode) {
 
     UColAttributeValue value;
     for(int32_t i = 0;; ++i) {
-        if(i == LENGTHOF(attributeValues)) {
+        if(i == uprv_lengthof(attributeValues)) {
             errln("invalid attribute value name on line %d", (int)fileLineNumber);
             infoln(fileLine);
             errorCode.set(U_PARSE_ERROR);
@@ -1302,7 +1300,7 @@ UBool CollationTest::getSortKeyParts(const UChar *s, int32_t length,
                                      IcuTestErrorCode &errorCode) {
     if(errorCode.isFailure()) { return FALSE; }
     uint8_t part[32];
-    U_ASSERT(partSize <= LENGTHOF(part));
+    U_ASSERT(partSize <= uprv_lengthof(part));
     UCharIterator iter;
     uiter_setString(&iter, s, length);
     uint32_t state[2] = { 0, 0 };
@@ -1440,7 +1438,7 @@ UBool CollationTest::getCollationKey(const char *norm, const UnicodeString &line
 
     // Check that internalNextSortKeyPart() makes the same key, with several part sizes.
     static const int32_t partSizes[] = { 32, 3, 1 };
-    for(int32_t psi = 0; psi < LENGTHOF(partSizes); ++psi) {
+    for(int32_t psi = 0; psi < uprv_lengthof(partSizes); ++psi) {
         int32_t partSize = partSizes[psi];
         CharString parts;
         if(!getSortKeyParts(s, length, parts, 32, errorCode)) {
index f9b9002dc08fb60700dfc0fb7700c60f18bf424b..4988d3cbacdafd5cc338440ce557866f79d72065 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 1997-2013, International Business Machines Corporation and    *
+* Copyright (C) 1997-2014, International Business Machines Corporation and    *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 *
@@ -17,8 +17,7 @@
 
 #include "unicode/compactdecimalformat.h"
 #include "unicode/unum.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
+#include "cmemory.h"
 
 typedef struct ExpectedResult {
   double value;
@@ -218,27 +217,27 @@ void CompactDecimalFormatTest::runIndexedTest(
 }
 
 void CompactDecimalFormatTest::TestEnglishShort() {
-  CheckLocale("en", UNUM_SHORT, kEnglishShort, LENGTHOF(kEnglishShort));
+  CheckLocale("en", UNUM_SHORT, kEnglishShort, uprv_lengthof(kEnglishShort));
 }
 
 void CompactDecimalFormatTest::TestSerbianShort() {
-  CheckLocale("sr", UNUM_SHORT, kSerbianShort, LENGTHOF(kSerbianShort));
+  CheckLocale("sr", UNUM_SHORT, kSerbianShort, uprv_lengthof(kSerbianShort));
 }
 
 void CompactDecimalFormatTest::TestSerbianLong() {
-  CheckLocale("sr", UNUM_LONG, kSerbianLong, LENGTHOF(kSerbianLong));
+  CheckLocale("sr", UNUM_LONG, kSerbianLong, uprv_lengthof(kSerbianLong));
 }
 
 void CompactDecimalFormatTest::TestSerbianLongNegative() {
-  CheckLocale("sr", UNUM_LONG, kSerbianLongNegative, LENGTHOF(kSerbianLongNegative));
+  CheckLocale("sr", UNUM_LONG, kSerbianLongNegative, uprv_lengthof(kSerbianLongNegative));
 }
 
 void CompactDecimalFormatTest::TestJapaneseShort() {
-  CheckLocale(Locale::getJapan(), UNUM_SHORT, kJapaneseShort, LENGTHOF(kJapaneseShort));
+  CheckLocale(Locale::getJapan(), UNUM_SHORT, kJapaneseShort, uprv_lengthof(kJapaneseShort));
 }
 
 void CompactDecimalFormatTest::TestSwahiliShort() {
-  CheckLocale("sw", UNUM_SHORT, kSwahiliShort, LENGTHOF(kSwahiliShort));
+  CheckLocale("sw", UNUM_SHORT, kSwahiliShort, uprv_lengthof(kSwahiliShort));
 }
 
 void CompactDecimalFormatTest::TestFieldPosition() {
@@ -259,7 +258,7 @@ void CompactDecimalFormatTest::TestFieldPosition() {
 }
 
 void CompactDecimalFormatTest::TestCsShort() {
-  CheckLocale("cs", UNUM_SHORT, kCsShort, LENGTHOF(kCsShort));
+  CheckLocale("cs", UNUM_SHORT, kCsShort, uprv_lengthof(kCsShort));
 }
 
 void CompactDecimalFormatTest::TestSkLong() {
@@ -268,15 +267,15 @@ void CompactDecimalFormatTest::TestSkLong() {
   //   few{"0"}
   //   one{"0"}
   //   other{"0"}
-  CheckLocale("sk", UNUM_LONG, kSkLong, LENGTHOF(kSkLong));
+  CheckLocale("sk", UNUM_LONG, kSkLong, uprv_lengthof(kSkLong));
 }
 
 void CompactDecimalFormatTest::TestSwahiliShortNegative() {
-  CheckLocale("sw", UNUM_SHORT, kSwahiliShortNegative, LENGTHOF(kSwahiliShortNegative));
+  CheckLocale("sw", UNUM_SHORT, kSwahiliShortNegative, uprv_lengthof(kSwahiliShortNegative));
 }
 
 void CompactDecimalFormatTest::TestArabicLong() {
-  CheckLocale("ar", UNUM_LONG, kArabicLong, LENGTHOF(kArabicLong));
+  CheckLocale("ar", UNUM_LONG, kArabicLong, uprv_lengthof(kArabicLong));
 }
 
 void CompactDecimalFormatTest::TestSignificantDigits() {
index 481c38a53433b5bfdb09967562f72e4f9ded736d..1654c9285b90cc2f33a343c2e6c877037a9ac639 100644 (file)
 #include "unicode/ustring.h"
 #include "unicode/ures.h"
 #include "convtest.h"
+#include "cmemory.h"
 #include "unicode/tstdtmod.h"
 #include <string.h>
 #include <stdlib.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 enum {
     // characters used in test data for callbacks
     SUB_CB='?',
@@ -291,7 +290,7 @@ ConversionTest::TestFromUnicode() {
                     // read a substitution string, separated by an equal sign
                     p=s.getBuffer()+index+1;
                     length=s.length()-(index+1);
-                    if(length<0 || length>=LENGTHOF(cc.subString)) {
+                    if(length<0 || length>=uprv_lengthof(cc.subString)) {
                         errorCode=U_ILLEGAL_ARGUMENT_ERROR;
                     } else {
                         u_memcpy(cc.subString, p, length);
@@ -445,7 +444,7 @@ ConversionTest::TestGetUnicodeSet() {
                 if(!diffSet.isEmpty()) {
                     diffSet.toPattern(s, TRUE);
                     if(s.length()>100) {
-                        s.replace(100, 0x7fffffff, ellipsis, LENGTHOF(ellipsis));
+                        s.replace(100, 0x7fffffff, ellipsis, uprv_lengthof(ellipsis));
                     }
                     errln("error: ucnv_getUnicodeSet(\"%s\") is missing items - conversion/getUnicodeSet test case %d",
                             charset, i);
@@ -457,7 +456,7 @@ ConversionTest::TestGetUnicodeSet() {
                 if(!diffSet.isEmpty()) {
                     diffSet.toPattern(s, TRUE);
                     if(s.length()>100) {
-                        s.replace(100, 0x7fffffff, ellipsis, LENGTHOF(ellipsis));
+                        s.replace(100, 0x7fffffff, ellipsis, uprv_lengthof(ellipsis));
                     }
                     errln("error: ucnv_getUnicodeSet(\"%s\") contains unexpected items - conversion/getUnicodeSet test case %d",
                             charset, i);
@@ -555,7 +554,7 @@ ConversionTest::TestGetUnicodeSet2() {
     LocalUConverterPointer cnv;
     char buffer[1024];
     int32_t i;
-    for(i=0; i<LENGTHOF(cnvNames); ++i) {
+    for(i=0; i<uprv_lengthof(cnvNames); ++i) {
         UErrorCode errorCode=U_ZERO_ERROR;
         cnv.adoptInstead(cnv_open(cnvNames[i], errorCode));
         if(U_FAILURE(errorCode)) {
@@ -625,7 +624,7 @@ ConversionTest::TestGetUnicodeSet2() {
                 if(!diffSet.isEmpty()) {
                     diffSet.toPattern(out, TRUE);
                     if(out.length()>100) {
-                        out.replace(100, 0x7fffffff, ellipsis, LENGTHOF(ellipsis));
+                        out.replace(100, 0x7fffffff, ellipsis, uprv_lengthof(ellipsis));
                     }
                     errln("error: ucnv_getUnicodeSet(\"%s\") is missing items - which set: %d",
                             cnvNames[i], which);
@@ -637,7 +636,7 @@ ConversionTest::TestGetUnicodeSet2() {
                 if(!diffSet.isEmpty()) {
                     diffSet.toPattern(out, TRUE);
                     if(out.length()>100) {
-                        out.replace(100, 0x7fffffff, ellipsis, LENGTHOF(ellipsis));
+                        out.replace(100, 0x7fffffff, ellipsis, uprv_lengthof(ellipsis));
                     }
                     errln("error: ucnv_getUnicodeSet(\"%s\") contains unexpected items - which set: %d",
                             cnvNames[i], which);
@@ -1030,7 +1029,7 @@ ConversionTest::ToUnicodeCase(ConversionCase &cc, UConverterToUCallback callback
     int32_t i, step;
 
     ok=TRUE;
-    for(i=0; i<LENGTHOF(steps) && ok; ++i) {
+    for(i=0; i<uprv_lengthof(steps) && ok; ++i) {
         step=steps[i].step;
         if(step<0 && !cc.finalFlush) {
             // skip ucnv_getNextUChar() if !finalFlush because
@@ -1042,12 +1041,12 @@ ConversionTest::ToUnicodeCase(ConversionCase &cc, UConverterToUCallback callback
             cc.offsets=NULL;
         }
         else {
-            memset(resultOffsets, -1, LENGTHOF(resultOffsets));
+            memset(resultOffsets, -1, uprv_lengthof(resultOffsets));
         }
-        memset(result, -1, LENGTHOF(result));
+        memset(result, -1, uprv_lengthof(result));
         errorCode.reset();
         resultLength=stepToUnicode(cc, cnv.getAlias(),
-                                result, LENGTHOF(result),
+                                result, uprv_lengthof(result),
                                 step==0 ? resultOffsets : NULL,
                                 step, errorCode);
         ok=checkToUnicode(
@@ -1077,7 +1076,7 @@ ConversionTest::ToUnicodeCase(ConversionCase &cc, UConverterToUCallback callback
 
         errorCode.reset();
         resultLength=ucnv_toUChars(cnv.getAlias(),
-                        result, LENGTHOF(result),
+                        result, uprv_lengthof(result),
                         (const char *)cc.bytes, cc.bytesLength,
                         errorCode);
         ok=checkToUnicode(
@@ -1224,7 +1223,7 @@ stepFromUTF8(ConversionCase &cc,
         targetLimit=resultLimit;
         flush=cc.finalFlush;
 
-        pivotLimit=pivotBuffer+LENGTHOF(pivotBuffer);
+        pivotLimit=pivotBuffer+uprv_lengthof(pivotBuffer);
     } else {
         // start with empty partial buffers
         sourceLimit=source;
@@ -1443,7 +1442,7 @@ ConversionTest::FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback call
     // convert unicode to utf8
     char utf8[256];
     cc.utf8=utf8;
-    u_strToUTF8(utf8, LENGTHOF(utf8), &cc.utf8Length,
+    u_strToUTF8(utf8, uprv_lengthof(utf8), &cc.utf8Length,
                 cc.unicode, cc.unicodeLength,
                 &errorCode);
     if(U_FAILURE(errorCode)) {
@@ -1470,13 +1469,13 @@ ConversionTest::FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback call
     int32_t i, step;
 
     ok=TRUE;
-    for(i=0; i<LENGTHOF(steps) && ok; ++i) {
+    for(i=0; i<uprv_lengthof(steps) && ok; ++i) {
         step=steps[i].step;
-        memset(resultOffsets, -1, LENGTHOF(resultOffsets));
-        memset(result, -1, LENGTHOF(result));
+        memset(resultOffsets, -1, uprv_lengthof(resultOffsets));
+        memset(result, -1, uprv_lengthof(result));
         errorCode=U_ZERO_ERROR;
         resultLength=stepFromUnicode(cc, cnv,
-                                result, LENGTHOF(result),
+                                result, uprv_lengthof(result),
                                 step==0 ? resultOffsets : NULL,
                                 step, &errorCode);
         ok=checkFromUnicode(
@@ -1505,7 +1504,7 @@ ConversionTest::FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback call
         if(cc.utf8Length>=0) {
             errorCode=U_ZERO_ERROR;
             resultLength=stepFromUTF8(cc, utf8Cnv, cnv,
-                                    result, LENGTHOF(result),
+                                    result, uprv_lengthof(result),
                                     step, &errorCode);
             ok=checkFromUnicode(
                     cc, cnv, steps[i].utf8Name,
@@ -1528,7 +1527,7 @@ ConversionTest::FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback call
 
         errorCode=U_ZERO_ERROR;
         resultLength=ucnv_fromUChars(cnv,
-                        result, LENGTHOF(result),
+                        result, uprv_lengthof(result),
                         cc.unicode, cc.unicodeLength,
                         &errorCode);
         ok=checkFromUnicode(
@@ -1577,7 +1576,7 @@ ConversionTest::checkFromUnicode(ConversionCase &cc, UConverter *cnv, const char
     msg=NULL;
 
     errorCode=U_ZERO_ERROR;
-    resultInvalidLength=LENGTHOF(resultInvalidUChars);
+    resultInvalidLength=uprv_lengthof(resultInvalidUChars);
     ucnv_getInvalidUChars(cnv, resultInvalidUChars, &resultInvalidLength, &errorCode);
     if(U_FAILURE(errorCode)) {
         errln("fromUnicode[%d](%s cb=\"%s\" fb=%d flush=%d %s) ucnv_getInvalidUChars() failed - %s",
index 5eea88334559cd8340988f084f3f92d094dfa5b5..5bafdf0f3e75f864a79659408a47d15926a3e7bc 100644 (file)
@@ -22,8 +22,6 @@
 #include "plurrule_impl.h"
 #include <stdio.h>
 
-#define LENGTHOF(array) ((int32_t)(sizeof(array)/sizeof((array)[0])))
-
 // This is an API test, not a unit test.  It doesn't test very many cases, and doesn't
 // try to test the full functionality.  It just calls each function in the class and
 // verifies that it works on a basic level.
@@ -574,7 +572,7 @@ void IntlTestDecimalFormatAPI::TestScale()
     UnicodeString percentPattern("#,##0%");
     pat.setMaximumFractionDigits(4);
 
-    for(int32_t i=0; i < LENGTHOF(testData); i++) {
+    for(int32_t i=0; i < uprv_lengthof(testData); i++) {
         if ( i > 2 ) {
             pat.applyPattern(percentPattern,status);
         }
index 12729c1772873244a425c61acc2544caddd34da6..e03576da514fdfcde44cb5c0525dd2fa84bf8308 100644 (file)
@@ -27,8 +27,6 @@
 #include "windttst.h"
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
 
 #define ASSERT_OK(status)  if(U_FAILURE(status)) {errcheckln(status, #status " = %s @ %s:%d", u_errorName(status), __FILE__, __LINE__); return; }
@@ -169,7 +167,7 @@ void DateFormatTest::TestPatterns() {
     };
 
     IcuTestErrorCode errorCode(*this, "TestPatterns()");
-    for (int32_t i = 0; i < LENGTHOF(EXPECTED); i++) {
+    for (int32_t i = 0; i < uprv_lengthof(EXPECTED); i++) {
         // Verify that patterns have the correct values
         UnicodeString actualPattern(EXPECTED[i].actualPattern, -1, US_INV);
         UnicodeString expectedPattern(EXPECTED[i].expectedPattern, -1, US_INV);
@@ -4180,7 +4178,7 @@ void DateFormatTest::TestDotAndAtLeniency() {
     // Test for date/time parsing regression with CLDR 22.1/ICU 50 pattern strings.
     // For details see http://bugs.icu-project.org/trac/ticket/9789
     static const char *locales[] = { "en", "fr" };
-    for (int32_t i = 0; i < LENGTHOF(locales); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(locales); ++i) {
         Locale locale(locales[i]);
 
         for (DateFormat::EStyle dateStyle = DateFormat::FULL; dateStyle <= DateFormat::SHORT;
index da5ed66cc98f2322a922e5590e287da41e6e6f8d..53fc4f91b86948a68c5514ecb61b13740ec059f0 100644 (file)
@@ -14,8 +14,7 @@
 #include "unicode/sortkey.h"
 #include "g7coll.h"
 #include "sfwdchit.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 static const UChar testCases[][G7CollationTest::MAX_TOKEN_LEN] = {
     {  0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/, 
@@ -92,7 +91,7 @@ void G7CollationTest::TestG7Locales(/* char* par */)
         Locale("ja", "JP", "")
     };
 
-    for (i = 0; i < LENGTHOF(locales); i++)
+    for (i = 0; i < uprv_lengthof(locales); i++)
     {
         UnicodeString dispName;
         UErrorCode status = U_ZERO_ERROR;
index 97a3e67d2492b1e32a480a476869bbcf6a1207c7..53fd987e3ef2bd582c91300f9690121151570159 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /* Modification History:
@@ -14,8 +14,7 @@
 #include "unicode/gender.h"
 #include "unicode/unum.h"
 #include "intltest.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
+#include "cmemory.h"
 
 static const UGender kSingleFemale[] = {UGENDER_FEMALE};
 static const UGender kSingleMale[] = {UGENDER_MALE};
@@ -55,17 +54,17 @@ void GenderInfoTest::runIndexedTest(int32_t index, UBool exec, const char *&name
 
 void GenderInfoTest::TestGetListGender() {
     check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, NULL, 0);
-    check(UGENDER_FEMALE, UGENDER_FEMALE, UGENDER_FEMALE, kSingleFemale, LENGTHOF(kSingleFemale));
-    check(UGENDER_MALE, UGENDER_MALE, UGENDER_MALE, kSingleMale, LENGTHOF(kSingleMale));
-    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, kSingleOther, LENGTHOF(kSingleOther));
+    check(UGENDER_FEMALE, UGENDER_FEMALE, UGENDER_FEMALE, kSingleFemale, uprv_lengthof(kSingleFemale));
+    check(UGENDER_MALE, UGENDER_MALE, UGENDER_MALE, kSingleMale, uprv_lengthof(kSingleMale));
+    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_OTHER, kSingleOther, uprv_lengthof(kSingleOther));
 
-    check(UGENDER_OTHER, UGENDER_FEMALE, UGENDER_FEMALE, kAllFemale, LENGTHOF(kAllFemale));
-    check(UGENDER_OTHER, UGENDER_MALE, UGENDER_MALE, kAllMale, LENGTHOF(kAllMale));
-    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kAllOther, LENGTHOF(kAllOther));
+    check(UGENDER_OTHER, UGENDER_FEMALE, UGENDER_FEMALE, kAllFemale, uprv_lengthof(kAllFemale));
+    check(UGENDER_OTHER, UGENDER_MALE, UGENDER_MALE, kAllMale, uprv_lengthof(kAllMale));
+    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kAllOther, uprv_lengthof(kAllOther));
 
-    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleMale, LENGTHOF(kFemaleMale));
-    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleOther, LENGTHOF(kFemaleOther));
-    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kMaleOther, LENGTHOF(kMaleOther));
+    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleMale, uprv_lengthof(kFemaleMale));
+    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kFemaleOther, uprv_lengthof(kFemaleOther));
+    check(UGENDER_OTHER, UGENDER_OTHER, UGENDER_MALE, kMaleOther, uprv_lengthof(kMaleOther));
 }
 
 void GenderInfoTest::TestFallback() {
index 088b87ec8c5efb28ceb388c1eca05ca9990f7a92..fb4532d3d58e81227be22745a47411ee6e595307 100644 (file)
@@ -45,8 +45,6 @@
     errln("Test Failure at file %s, line %d: \"%s\" (%d) == \"%s\" (%d)", \
              __FILE__, __LINE__, #a, (a), #b, (b)); }}
 
-#define LENGTHOF(array) ((int32_t)(sizeof(array)/sizeof((array)[0])))
-
 /*
  *   TEST_SETUP and TEST_TEARDOWN
  *         macros to handle the boilerplate around setting up test case.
@@ -511,7 +509,7 @@ void IntlTestSpoof::testIdentifierInfo() {
     };
 
     int testNum;
-    for (testNum = 0; testNum < LENGTHOF(tests); testNum++) {
+    for (testNum = 0; testNum < uprv_lengthof(tests); testNum++) {
         char testNumStr[40];
         sprintf(testNumStr, "testNum = %d", testNum);
         Test &test = tests[testNum];
@@ -575,7 +573,7 @@ void IntlTestSpoof::testIdentifierInfo() {
 
     status = U_ZERO_ERROR;
     IdentifierInfo identifierInfo(status);
-    for (testNum=0; testNum<LENGTHOF(scriptTests); testNum++) {
+    for (testNum=0; testNum<uprv_lengthof(scriptTests); testNum++) {
         ScriptTest &test = scriptTests[testNum];
         char msgBuf[100];
         sprintf(msgBuf, "testNum = %d ", testNum);
@@ -691,7 +689,7 @@ void IntlTestSpoof::testRestrictionLevel() {
     TEST_ASSERT_SUCCESS(status);
     idInfo.setIdentifierProfile(*uspoof_getRecommendedUnicodeSet(&status));
     TEST_ASSERT_SUCCESS(status);
-    for (int32_t testNum=0; testNum < LENGTHOF(tests); testNum++) {
+    for (int32_t testNum=0; testNum < uprv_lengthof(tests); testNum++) {
         status = U_ZERO_ERROR;
         const Test &test = tests[testNum];
         UnicodeString testString = UnicodeString(test.fId).unescape();
@@ -700,7 +698,7 @@ void IntlTestSpoof::testRestrictionLevel() {
         sprintf(msgBuffer, "testNum = %d ", testNum);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_MSG(expectedLevel == idInfo.getRestrictionLevel(status), msgBuffer);
-        for (int levelIndex=0; levelIndex<LENGTHOF(restrictionLevels); levelIndex++) {
+        for (int levelIndex=0; levelIndex<uprv_lengthof(restrictionLevels); levelIndex++) {
             status = U_ZERO_ERROR;
             URestrictionLevel levelSetInSpoofChecker = restrictionLevels[levelIndex];
             USpoofChecker *sc = uspoof_open(&status);
@@ -751,7 +749,7 @@ void IntlTestSpoof::testMixedNumbers() {
     };
     UErrorCode status = U_ZERO_ERROR;
     IdentifierInfo idInfo(status);
-    for (int32_t testNum=0; testNum < LENGTHOF(tests); testNum++) {
+    for (int32_t testNum=0; testNum < uprv_lengthof(tests); testNum++) {
         char msgBuf[100];
         sprintf(msgBuf, "testNum = %d ", testNum);
         Test &test = tests[testNum];
index 14f2715e4d69323a1e4d6af79d6b811b3c5ee383..738de244da627baffca88c241bb39858bd522b9c 100644 (file)
@@ -24,8 +24,6 @@
 #include "charstr.h"
 #include "unicode/reldatefmt.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 struct ExpectedResult {
     const Measure *measures;
     int32_t count;
@@ -311,32 +309,32 @@ void MeasureFormatTest::TestExamplesInDocs() {
             "Feet and inches",
             fmtFrFull,
             feetAndInches,
-            LENGTHOF(feetAndInches),
+            uprv_lengthof(feetAndInches),
             "70 pieds et 5,3 pouces");
     verifyFormatWithPrefix(
             "Feet and inches",
             fmtFrFull,
             "Prefix: ",
             feetAndInches,
-            LENGTHOF(feetAndInches),
+            uprv_lengthof(feetAndInches),
             "Prefix: 70 pieds et 5,3 pouces");
     verifyFormat(
             "Foot and inch",
             fmtFrFull,
             footAndInch,
-            LENGTHOF(footAndInch),
+            uprv_lengthof(footAndInch),
             "1 pied et 1 pouce");
     verifyFormat(
             "Foot and inch narrow",
             fmtFrNarrow,
             footAndInch,
-            LENGTHOF(footAndInch),
+            uprv_lengthof(footAndInch),
             "1\\u2032 1\\u2033");
     verifyFormat(
             "Inch and feet",
             fmtEn,
             inchAndFeet,
-            LENGTHOF(inchAndFeet),
+            uprv_lengthof(inchAndFeet),
             "1 inch, 2 feet");
 }
 
@@ -424,65 +422,65 @@ void MeasureFormatTest::TestFormatPeriodEn() {
     }
     
     ExpectedResult fullData[] = {
-            {t_1m_59_9996s, LENGTHOF(t_1m_59_9996s), "1 minute, 59.9996 seconds"},
-            {t_19m, LENGTHOF(t_19m), "19 minutes"},
-            {t_1h_23_5s, LENGTHOF(t_1h_23_5s), "1 hour, 23.5 seconds"},
-            {t_1h_23_5m, LENGTHOF(t_1h_23_5m), "1 hour, 23.5 minutes"},
-            {t_1h_0m_23s, LENGTHOF(t_1h_0m_23s), "1 hour, 0 minutes, 23 seconds"},
-            {t_2y_5M_3w_4d, LENGTHOF(t_2y_5M_3w_4d), "2 years, 5 months, 3 weeks, 4 days"}};
+            {t_1m_59_9996s, uprv_lengthof(t_1m_59_9996s), "1 minute, 59.9996 seconds"},
+            {t_19m, uprv_lengthof(t_19m), "19 minutes"},
+            {t_1h_23_5s, uprv_lengthof(t_1h_23_5s), "1 hour, 23.5 seconds"},
+            {t_1h_23_5m, uprv_lengthof(t_1h_23_5m), "1 hour, 23.5 minutes"},
+            {t_1h_0m_23s, uprv_lengthof(t_1h_0m_23s), "1 hour, 0 minutes, 23 seconds"},
+            {t_2y_5M_3w_4d, uprv_lengthof(t_2y_5M_3w_4d), "2 years, 5 months, 3 weeks, 4 days"}};
 
     ExpectedResult abbrevData[] = {
-            {t_1m_59_9996s, LENGTHOF(t_1m_59_9996s), "1 min, 59.9996 secs"},
-            {t_19m, LENGTHOF(t_19m), "19 mins"},
-            {t_1h_23_5s, LENGTHOF(t_1h_23_5s), "1 hr, 23.5 secs"},
-            {t_1h_23_5m, LENGTHOF(t_1h_23_5m), "1 hr, 23.5 mins"},
-            {t_1h_0m_23s, LENGTHOF(t_1h_0m_23s), "1 hr, 0 mins, 23 secs"},
-            {t_2y_5M_3w_4d, LENGTHOF(t_2y_5M_3w_4d), "2 yrs, 5 mths, 3 wks, 4 days"}};
+            {t_1m_59_9996s, uprv_lengthof(t_1m_59_9996s), "1 min, 59.9996 secs"},
+            {t_19m, uprv_lengthof(t_19m), "19 mins"},
+            {t_1h_23_5s, uprv_lengthof(t_1h_23_5s), "1 hr, 23.5 secs"},
+            {t_1h_23_5m, uprv_lengthof(t_1h_23_5m), "1 hr, 23.5 mins"},
+            {t_1h_0m_23s, uprv_lengthof(t_1h_0m_23s), "1 hr, 0 mins, 23 secs"},
+            {t_2y_5M_3w_4d, uprv_lengthof(t_2y_5M_3w_4d), "2 yrs, 5 mths, 3 wks, 4 days"}};
 
     ExpectedResult narrowData[] = {
-            {t_1m_59_9996s, LENGTHOF(t_1m_59_9996s), "1m 59.9996s"},
-            {t_19m, LENGTHOF(t_19m), "19m"},
-            {t_1h_23_5s, LENGTHOF(t_1h_23_5s), "1h 23.5s"},
-            {t_1h_23_5m, LENGTHOF(t_1h_23_5m), "1h 23.5m"},
-            {t_1h_0m_23s, LENGTHOF(t_1h_0m_23s), "1h 0m 23s"},
-            {t_2y_5M_3w_4d, LENGTHOF(t_2y_5M_3w_4d), "2y 5m 3w 4d"}};
+            {t_1m_59_9996s, uprv_lengthof(t_1m_59_9996s), "1m 59.9996s"},
+            {t_19m, uprv_lengthof(t_19m), "19m"},
+            {t_1h_23_5s, uprv_lengthof(t_1h_23_5s), "1h 23.5s"},
+            {t_1h_23_5m, uprv_lengthof(t_1h_23_5m), "1h 23.5m"},
+            {t_1h_0m_23s, uprv_lengthof(t_1h_0m_23s), "1h 0m 23s"},
+            {t_2y_5M_3w_4d, uprv_lengthof(t_2y_5M_3w_4d), "2y 5m 3w 4d"}};
 
     ExpectedResult numericData[] = {
-            {t_1m_59_9996s, LENGTHOF(t_1m_59_9996s), "1:59.9996"},
-            {t_19m, LENGTHOF(t_19m), "19m"},
-            {t_1h_23_5s, LENGTHOF(t_1h_23_5s), "1:00:23.5"},
-            {t_1h_23_5m, LENGTHOF(t_1h_23_5m), "1:23.5"},
-            {t_1h_0m_23s, LENGTHOF(t_1h_0m_23s), "1:00:23"},
-            {t_5h_17m, LENGTHOF(t_5h_17m), "5:17"},
-            {t_neg5h_17m, LENGTHOF(t_neg5h_17m), "-5h 17m"},
-            {t_19m_28s, LENGTHOF(t_19m_28s), "19:28"},
-            {t_2y_5M_3w_4d, LENGTHOF(t_2y_5M_3w_4d), "2y 5m 3w 4d"},
-            {t_0h_0m_9s, LENGTHOF(t_0h_0m_9s), "0:00:09"},
-            {t_6h_56_92m, LENGTHOF(t_6h_56_92m), "6:56.92"},
-            {t_6_7h_56_92m, LENGTHOF(t_6_7h_56_92m), "6:56.92"},
-            {t_3h_4s_5m, LENGTHOF(t_3h_4s_5m), "3h 4s 5m"},
-            {t_3h_5h, LENGTHOF(t_3h_5h), "3h 5h"}};
+            {t_1m_59_9996s, uprv_lengthof(t_1m_59_9996s), "1:59.9996"},
+            {t_19m, uprv_lengthof(t_19m), "19m"},
+            {t_1h_23_5s, uprv_lengthof(t_1h_23_5s), "1:00:23.5"},
+            {t_1h_23_5m, uprv_lengthof(t_1h_23_5m), "1:23.5"},
+            {t_1h_0m_23s, uprv_lengthof(t_1h_0m_23s), "1:00:23"},
+            {t_5h_17m, uprv_lengthof(t_5h_17m), "5:17"},
+            {t_neg5h_17m, uprv_lengthof(t_neg5h_17m), "-5h 17m"},
+            {t_19m_28s, uprv_lengthof(t_19m_28s), "19:28"},
+            {t_2y_5M_3w_4d, uprv_lengthof(t_2y_5M_3w_4d), "2y 5m 3w 4d"},
+            {t_0h_0m_9s, uprv_lengthof(t_0h_0m_9s), "0:00:09"},
+            {t_6h_56_92m, uprv_lengthof(t_6h_56_92m), "6:56.92"},
+            {t_6_7h_56_92m, uprv_lengthof(t_6_7h_56_92m), "6:56.92"},
+            {t_3h_4s_5m, uprv_lengthof(t_3h_4s_5m), "3h 4s 5m"},
+            {t_3h_5h, uprv_lengthof(t_3h_5h), "3h 5h"}};
 
     ExpectedResult fullDataDe[] = {
-            {t_1m_59_9996s, LENGTHOF(t_1m_59_9996s), "1 Minute und 59,9996 Sekunden"},
-            {t_19m, LENGTHOF(t_19m), "19 Minuten"},
-            {t_1h_23_5s, LENGTHOF(t_1h_23_5s), "1 Stunde und 23,5 Sekunden"},
-            {t_1h_23_5m, LENGTHOF(t_1h_23_5m), "1 Stunde und 23,5 Minuten"},
-            {t_1h_0m_23s, LENGTHOF(t_1h_0m_23s), "1 Stunde, 0 Minuten und 23 Sekunden"},
-            {t_2y_5M_3w_4d, LENGTHOF(t_2y_5M_3w_4d), "2 Jahre, 5 Monate, 3 Wochen und 4 Tage"}};
+            {t_1m_59_9996s, uprv_lengthof(t_1m_59_9996s), "1 Minute und 59,9996 Sekunden"},
+            {t_19m, uprv_lengthof(t_19m), "19 Minuten"},
+            {t_1h_23_5s, uprv_lengthof(t_1h_23_5s), "1 Stunde und 23,5 Sekunden"},
+            {t_1h_23_5m, uprv_lengthof(t_1h_23_5m), "1 Stunde und 23,5 Minuten"},
+            {t_1h_0m_23s, uprv_lengthof(t_1h_0m_23s), "1 Stunde, 0 Minuten und 23 Sekunden"},
+            {t_2y_5M_3w_4d, uprv_lengthof(t_2y_5M_3w_4d), "2 Jahre, 5 Monate, 3 Wochen und 4 Tage"}};
 
     ExpectedResult numericDataDe[] = {
-            {t_1m_59_9996s, LENGTHOF(t_1m_59_9996s), "1:59,9996"},
-            {t_19m, LENGTHOF(t_19m), "19 Min."},
-            {t_1h_23_5s, LENGTHOF(t_1h_23_5s), "1:00:23,5"},
-            {t_1h_23_5m, LENGTHOF(t_1h_23_5m), "1:23,5"},
-            {t_1h_0m_23s, LENGTHOF(t_1h_0m_23s), "1:00:23"},
-            {t_5h_17m, LENGTHOF(t_5h_17m), "5:17"},
-            {t_19m_28s, LENGTHOF(t_19m_28s), "19:28"},
-            {t_2y_5M_3w_4d, LENGTHOF(t_2y_5M_3w_4d), "2 J, 5 M, 3 W und 4 T"},
-            {t_0h_0m_17s, LENGTHOF(t_0h_0m_17s), "0:00:17"},
-            {t_6h_56_92m, LENGTHOF(t_6h_56_92m), "6:56,92"},
-            {t_3h_5h, LENGTHOF(t_3h_5h), "3 Std., 5 Std."}};
+            {t_1m_59_9996s, uprv_lengthof(t_1m_59_9996s), "1:59,9996"},
+            {t_19m, uprv_lengthof(t_19m), "19 Min."},
+            {t_1h_23_5s, uprv_lengthof(t_1h_23_5s), "1:00:23,5"},
+            {t_1h_23_5m, uprv_lengthof(t_1h_23_5m), "1:23,5"},
+            {t_1h_0m_23s, uprv_lengthof(t_1h_0m_23s), "1:00:23"},
+            {t_5h_17m, uprv_lengthof(t_5h_17m), "5:17"},
+            {t_19m_28s, uprv_lengthof(t_19m_28s), "19:28"},
+            {t_2y_5M_3w_4d, uprv_lengthof(t_2y_5M_3w_4d), "2 J, 5 M, 3 W und 4 T"},
+            {t_0h_0m_17s, uprv_lengthof(t_0h_0m_17s), "0:00:17"},
+            {t_6h_56_92m, uprv_lengthof(t_6h_56_92m), "6:56,92"},
+            {t_3h_5h, uprv_lengthof(t_3h_5h), "3 Std., 5 Std."}};
 
     Locale en(Locale::getEnglish());
     LocalPointer<NumberFormat> nf(NumberFormat::createInstance(en, status));
@@ -495,34 +493,34 @@ void MeasureFormatTest::TestFormatPeriodEn() {
     if (!assertSuccess("Error creating measure format en WIDE", status)) {
         return;
     }
-    verifyFormat("en WIDE", mf, fullData, LENGTHOF(fullData));
+    verifyFormat("en WIDE", mf, fullData, uprv_lengthof(fullData));
 
     // exercise copy constructor
     {
         MeasureFormat mf2(mf);
-        verifyFormat("en WIDE copy", mf2, fullData, LENGTHOF(fullData));
+        verifyFormat("en WIDE copy", mf2, fullData, uprv_lengthof(fullData));
     }
     // exercise clone
     {
         MeasureFormat *mf3 = (MeasureFormat *) mf.clone();
-        verifyFormat("en WIDE copy", *mf3, fullData, LENGTHOF(fullData));
+        verifyFormat("en WIDE copy", *mf3, fullData, uprv_lengthof(fullData));
         delete mf3;
     }
     mf = MeasureFormat(en, UMEASFMT_WIDTH_SHORT, (NumberFormat *) nf->clone(), status);
     if (!assertSuccess("Error creating measure format en SHORT", status)) {
         return;
     }
-    verifyFormat("en SHORT", mf, abbrevData, LENGTHOF(abbrevData));
+    verifyFormat("en SHORT", mf, abbrevData, uprv_lengthof(abbrevData));
     mf = MeasureFormat(en, UMEASFMT_WIDTH_NARROW, (NumberFormat *) nf->clone(), status);
     if (!assertSuccess("Error creating measure format en NARROW", status)) {
         return;
     }
-    verifyFormat("en NARROW", mf, narrowData, LENGTHOF(narrowData));
+    verifyFormat("en NARROW", mf, narrowData, uprv_lengthof(narrowData));
     mf = MeasureFormat(en, UMEASFMT_WIDTH_NUMERIC, (NumberFormat *) nf->clone(), status);
     if (!assertSuccess("Error creating measure format en NUMERIC", status)) {
         return;
     }
-    verifyFormat("en NUMERIC", mf, numericData, LENGTHOF(numericData));
+    verifyFormat("en NUMERIC", mf, numericData, uprv_lengthof(numericData));
     
     Locale de(Locale::getGerman());
     nf.adoptInstead(NumberFormat::createInstance(de, status));
@@ -534,12 +532,12 @@ void MeasureFormatTest::TestFormatPeriodEn() {
     if (!assertSuccess("Error creating measure format de WIDE", status)) {
         return;
     }
-    verifyFormat("de WIDE", mf, fullDataDe, LENGTHOF(fullDataDe));
+    verifyFormat("de WIDE", mf, fullDataDe, uprv_lengthof(fullDataDe));
     mf = MeasureFormat(de, UMEASFMT_WIDTH_NUMERIC, (NumberFormat *) nf->clone(), status);
     if (!assertSuccess("Error creating measure format de NUMERIC", status)) {
         return;
     }
-    verifyFormat("de NUMERIC", mf, numericDataDe, LENGTHOF(numericDataDe));
+    verifyFormat("de NUMERIC", mf, numericDataDe, uprv_lengthof(numericDataDe));
 }
 
 void MeasureFormatTest::Test10219FractionalPlurals() {
@@ -550,8 +548,8 @@ void MeasureFormatTest::Test10219FractionalPlurals() {
             {"1 minute", "1.0 minutes", "1.01 minutes"}
     };
     UErrorCode status = U_ZERO_ERROR;
-    for (int j = 0; j < LENGTHOF(values); j++) {
-        for (int i = 0; i < LENGTHOF(expected[j]); i++) {
+    for (int j = 0; j < uprv_lengthof(values); j++) {
+        for (int i = 0; i < uprv_lengthof(expected[j]); i++) {
             DecimalFormat *df =
                 (DecimalFormat *) NumberFormat::createInstance(en, status);
             if (U_FAILURE(status)) {
@@ -657,10 +655,10 @@ void MeasureFormatTest::TestGreek() {
         "7 \\u03AD\\u03C4\\u03B7"};
 
     int32_t counter = 0;
-    for (int32_t locIndex = 0; locIndex < LENGTHOF(locales); ++locIndex ) {
-        for( int32_t numIndex = 0; numIndex < LENGTHOF(numbers); ++numIndex ) {
-            for ( int32_t styleIndex = 0; styleIndex < LENGTHOF(styles); ++styleIndex ) {
-                for ( int32_t unitIndex = 0; unitIndex < LENGTHOF(units); ++unitIndex ) {
+    for (int32_t locIndex = 0; locIndex < uprv_lengthof(locales); ++locIndex ) {
+        for( int32_t numIndex = 0; numIndex < uprv_lengthof(numbers); ++numIndex ) {
+            for ( int32_t styleIndex = 0; styleIndex < uprv_lengthof(styles); ++styleIndex ) {
+                for ( int32_t unitIndex = 0; unitIndex < uprv_lengthof(units); ++unitIndex ) {
                     Measure measure(numbers[numIndex], new MeasureUnit(units[unitIndex]), status);
                     if (!assertSuccess("Error creating Measure", status)) {
                         return;
@@ -734,7 +732,7 @@ void MeasureFormatTest::helperTestMultiples(
         return;
     }
     UnicodeString buffer;
-    fmt.formatMeasures(measures, LENGTHOF(measures), buffer, pos, status);
+    fmt.formatMeasures(measures, uprv_lengthof(measures), buffer, pos, status);
     if (!assertSuccess("Error formatting measures", status)) {
         return;
     }
@@ -857,7 +855,7 @@ void MeasureFormatTest::TestFieldPositionMultiple() {
             fmt,
             prefix,
             first,
-            LENGTHOF(first),
+            uprv_lengthof(first),
             NumberFormat::kIntegerField,
             8,
             11);
@@ -866,7 +864,7 @@ void MeasureFormatTest::TestFieldPositionMultiple() {
             fmt,
             prefix,
             second,
-            LENGTHOF(second),
+            uprv_lengthof(second),
             NumberFormat::kDecimalSeparatorField,
             23,
             24);
@@ -875,7 +873,7 @@ void MeasureFormatTest::TestFieldPositionMultiple() {
             fmt,
             prefix,
             third,
-            LENGTHOF(third),
+            uprv_lengthof(third),
             NumberFormat::kDecimalSeparatorField,
             0,
             0);
@@ -966,7 +964,7 @@ void MeasureFormatTest::TestDoubleZero() {
     }
     nf->setMinimumFractionDigits(2);
     nf->setMaximumFractionDigits(2);
-    fmt.formatMeasures(measures, LENGTHOF(measures), appendTo, pos, status);
+    fmt.formatMeasures(measures, uprv_lengthof(measures), appendTo, pos, status);
     if (!assertSuccess("Error formatting", status)) {
         return;
     }
@@ -976,7 +974,7 @@ void MeasureFormatTest::TestDoubleZero() {
             appendTo);
     measures[0] = Measure(-4.7, MeasureUnit::createHour(status), status);
     appendTo.remove();
-    fmt.formatMeasures(measures, LENGTHOF(measures), appendTo, pos, status);
+    fmt.formatMeasures(measures, uprv_lengthof(measures), appendTo, pos, status);
     if (!assertSuccess("Error formatting", status)) {
         return;
     }
index c3fcf28b3094151481c3fb5fc1dd85c681d1ec71..ba216fdacfba9173d3383e4f92d348d187a054d8 100644 (file)
@@ -39,8 +39,6 @@
 
 //#define NUMFMTST_DEBUG 1
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
-
 static const UChar EUR[] = {69,85,82,0}; // "EUR"
 static const UChar ISO_CURRENCY_USD[] = {0x55, 0x53, 0x44, 0}; // "USD"
 
@@ -3403,8 +3401,8 @@ NumberFormatTest::TestCurrencyIsoPluralFormat() {
         UNUM_CURRENCY_PLURAL
     };
 
-    for (int32_t i=0; i<LENGTHOF(DATA); ++i) {
-      for (int32_t kIndex = 0; kIndex < LENGTHOF(currencyStyles); ++kIndex) {
+    for (int32_t i=0; i<uprv_lengthof(DATA); ++i) {
+      for (int32_t kIndex = 0; kIndex < uprv_lengthof(currencyStyles); ++kIndex) {
         UNumberFormatStyle k = currencyStyles[kIndex];
         const char* localeString = DATA[i][0];
         double numberToBeFormat = atof(DATA[i][1]);
@@ -3512,7 +3510,7 @@ for (;;) {
     printf("loop: %d\n", deadloop++);
 #endif
     for (uint32_t i=0; i< sizeof(DATA)/sizeof(DATA[0]); ++i) {  /* i = test case #  - should be i=0*/
-      for (int32_t kIndex = 2; kIndex < LENGTHOF(currencyStyles); ++kIndex) {
+      for (int32_t kIndex = 2; kIndex < uprv_lengthof(currencyStyles); ++kIndex) {
         UNumberFormatStyle k = currencyStyles[kIndex]; /* k = style */
         const char* localeString = DATA[i][0];
         double numberToBeFormat = atof(DATA[i][1]);
index 8fce96f76db5e53c1cfc2b2d81615c766b6d4cb2..6715d35748d7910c63de8df7aded9c6ba2876214 100644 (file)
@@ -27,8 +27,6 @@
 #include "plurults.h"
 #include "uhash.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
-
 void setupResult(const int32_t testSource[], char result[], int32_t* max);
 UBool checkEqual(const PluralRules &test, char *result, int32_t max);
 UBool testEquality(const PluralRules &test);
@@ -221,7 +219,7 @@ void PluralRulesTest::testAPI(/*char *par*/)
     }
     double fData[] =     {-101, -100, -1,     -0.0,  0,     0.1,  1,     1.999,  2.0,   100,   100.001 };
     UBool isKeywordA[] = {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE,   FALSE, FALSE, TRUE };
-    for (int32_t i=0; i<LENGTHOF(fData); i++) {
+    for (int32_t i=0; i<uprv_lengthof(fData); i++) {
         if ((newRules->select(fData[i])== KEYWORD_A) != isKeywordA[i]) {
              errln("File %s, Line %d, ERROR: plural rules for decimal fractions test failed!\n"
                    "  number = %g, expected %s", __FILE__, __LINE__, fData[i], isKeywordA[i]?"TRUE":"FALSE");
@@ -398,7 +396,7 @@ void PluralRulesTest::testGetSamples() {
     }
     const UnicodeString* keyword;
     while (NULL != (keyword = keywords->snext(status))) {
-      int32_t count = rules->getSamples(*keyword, values, LENGTHOF(values), status);
+      int32_t count = rules->getSamples(*keyword, values, uprv_lengthof(values), status);
       if (U_FAILURE(status)) {
         errln(UNICODE_STRING_SIMPLE("getSamples() failed for locale ") +
               locales[i].getName() +
@@ -409,12 +407,12 @@ void PluralRulesTest::testGetSamples() {
         // TODO: Lots of these. 
         //   errln(UNICODE_STRING_SIMPLE("no samples for keyword ") + *keyword + UNICODE_STRING_SIMPLE(" in locale ") + locales[i].getName() );
       }
-      if (count > LENGTHOF(values)) {
+      if (count > uprv_lengthof(values)) {
         errln(UNICODE_STRING_SIMPLE("getSamples()=") + count +
               UNICODE_STRING_SIMPLE(", too many values, for locale ") +
               locales[i].getName() +
               UNICODE_STRING_SIMPLE(", keyword ") + *keyword);
-        count = LENGTHOF(values);
+        count = uprv_lengthof(values);
       }
       for (int32_t j = 0; j < count; ++j) {
         if (values[j] == UPLRULES_NO_UNIQUE_VALUE) {
@@ -939,7 +937,7 @@ void PluralRulesTest::testParseErrors() {
             "a: n % 37 ! in 3..4"
 
             };
-    for (int i=0; i<LENGTHOF(testCases); i++) {
+    for (int i=0; i<uprv_lengthof(testCases); i++) {
         const char *rules = testCases[i];
         UErrorCode status = U_ZERO_ERROR;
         PluralRules *pr = PluralRules::createRules(UnicodeString(rules), status);
@@ -981,7 +979,7 @@ void PluralRulesTest::testFixedDecimal() {
         {100.0001234, 7, 1234}
     };
 
-    for (int i=0; i<LENGTHOF(testCases); ++i) {
+    for (int i=0; i<uprv_lengthof(testCases); ++i) {
         DoubleTestCase &tc = testCases[i];
         int32_t numFractionDigits = FixedDecimal::decimals(tc.n);
         if (numFractionDigits != tc.fractionDigitCount) {
index 00c4763e874aee33afa2abd52482a32ac977983b..c246495eaff5c2cdbd2db8d6b66cdd0ab59bef31 100644 (file)
@@ -219,8 +219,6 @@ const char* RegexTest::extractToAssertBuf(const UnicodeString& message) {
   return ASSERT_BUF;
 }
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define REGEX_VERBOSE_TEXT(text) {char buf[200];utextToPrintable(buf,sizeof(buf)/sizeof(buf[0]),text);logln("%s:%d: UText %s=\"%s\"", __FILE__, __LINE__, #text, buf);}
 
 #define REGEX_CHECK_STATUS {if (U_FAILURE(status)) {dataerrln("%s:%d: RegexTest failure.  status=%s", \
@@ -5269,7 +5267,7 @@ void RegexTest::Bug10459() {
     //   It should set an U_REGEX_INVALID_STATE.
 
     UChar buf[100];
-    int32_t len = uregex_group(icu_re, 0, buf, LENGTHOF(buf), &status);
+    int32_t len = uregex_group(icu_re, 0, buf, uprv_lengthof(buf), &status);
     REGEX_ASSERT(status == U_REGEX_INVALID_STATE);
     REGEX_ASSERT(len == 0);
 
index ea12f7d7347c6f478912b2491e25937fd785ffab..ecad29ed6e1088662f90cfda44c781978c468911 100644 (file)
@@ -25,8 +25,6 @@ typedef struct KnownRegion {
   const char *containingContinent;
 } KnownRegion;
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 static KnownRegion knownRegions[] = {
     // Code, Num, Parent, Type,             Containing Continent
     { "TP" , 626, "035", URGN_TERRITORY, "142" },
@@ -364,7 +362,7 @@ RegionTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char*
 
 void RegionTest::TestKnownRegions() {
 
-    for (int32_t i = 0 ; i < LENGTHOF(knownRegions) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(knownRegions) ; i++ ) {
         KnownRegion rd = knownRegions[i];
         UErrorCode status = U_ZERO_ERROR;
         const Region *r = Region::getInstance(rd.code,status);
@@ -425,7 +423,7 @@ void RegionTest::TestGetInstanceString() {
     }
 
 
-    for (int32_t i = 0 ; i < LENGTHOF(testData) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(testData) ; i++ ) {
         TestData data = testData[i];
         status = U_ZERO_ERROR;
         r = Region::getInstance(data.inputID,status);
@@ -469,7 +467,7 @@ void RegionTest::TestGetInstanceInt() {
         errcheckln(status, "Calling Region::getInstance(-123) should have triggered an U_ILLEGAL_ARGUMENT_ERROR, but didn't. - %s", u_errorName(status));
     }
 
-    for (int32_t i = 0 ; i < LENGTHOF(testData) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(testData) ; i++ ) {
         TestData data = testData[i];
         status = U_ZERO_ERROR;
         const Region *r = Region::getInstance(data.inputID,status);
@@ -492,7 +490,7 @@ void RegionTest::TestGetInstanceInt() {
 }
 
 void RegionTest::TestGetContainedRegions() {
-    for (int32_t i = 0 ; i < LENGTHOF(knownRegions) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(knownRegions) ; i++ ) {
         KnownRegion rd = knownRegions[i];
         UErrorCode status = U_ZERO_ERROR;
 
@@ -519,7 +517,7 @@ void RegionTest::TestGetContainedRegions() {
 }
 
 void RegionTest::TestGetContainedRegionsWithType() {
-    for (int32_t i = 0 ; i < LENGTHOF(knownRegions) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(knownRegions) ; i++ ) {
         KnownRegion rd = knownRegions[i];
         UErrorCode status = U_ZERO_ERROR;
 
@@ -546,7 +544,7 @@ void RegionTest::TestGetContainedRegionsWithType() {
 }
 
 void RegionTest::TestGetContainingRegion() {        
-    for (int32_t i = 0 ; i < LENGTHOF(knownRegions) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(knownRegions) ; i++ ) {
         KnownRegion rd = knownRegions[i];
         UErrorCode status = U_ZERO_ERROR;
         const Region *r = Region::getInstance(rd.code,status);
@@ -570,7 +568,7 @@ void RegionTest::TestGetContainingRegion() {
 }
 
 void RegionTest::TestGetContainingRegionWithType() {        
-    for (int32_t i = 0 ; i < LENGTHOF(knownRegions) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(knownRegions) ; i++ ) {
         KnownRegion rd = knownRegions[i];
         UErrorCode status = U_ZERO_ERROR;
 
@@ -632,7 +630,7 @@ void RegionTest::TestGetPreferredValues() {
 }
 
 void RegionTest::TestContains() {        
-    for (int32_t i = 0 ; i < LENGTHOF(knownRegions) ; i++ ) {
+    for (int32_t i = 0 ; i < uprv_lengthof(knownRegions) ; i++ ) {
         KnownRegion rd = knownRegions[i];
         UErrorCode status = U_ZERO_ERROR;
 
index 59f8e9cc64fa608080612b100bb082b1dd21ba3a..0a06afa6b36c352529f5335018d8873cc3daf188 100644 (file)
@@ -18,8 +18,7 @@
 #include "unicode/localpointer.h"
 #include "unicode/numfmt.h"
 #include "unicode/reldatefmt.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
+#include "cmemory.h"
 
 static const char *DirectionStr(UDateDirection direction);
 static const char *RelativeUnitStr(UDateRelativeUnit unit);
@@ -617,7 +616,7 @@ void RelativeDateTimeFormatterTest::runIndexedTest(
 }
 
 void RelativeDateTimeFormatterTest::TestEnglish() {
-    RunTest("en", kEnglish, LENGTHOF(kEnglish));
+    RunTest("en", kEnglish, uprv_lengthof(kEnglish));
 }
 
 void RelativeDateTimeFormatterTest::TestEnglishCaps() {
@@ -638,27 +637,27 @@ void RelativeDateTimeFormatterTest::TestEnglishCaps() {
     RelativeDateTimeFormatter fmt2(fmt);
     fmt3 = fmt2;
     assertSuccess("", status);
-    RunTest(fmt3, kEnglishCaps, LENGTHOF(kEnglishCaps), "en caps");
+    RunTest(fmt3, kEnglishCaps, uprv_lengthof(kEnglishCaps), "en caps");
 }
 
 void RelativeDateTimeFormatterTest::TestEnglishShort() {
-    RunTest("en", UDAT_STYLE_SHORT, kEnglishShort, LENGTHOF(kEnglishShort));
+    RunTest("en", UDAT_STYLE_SHORT, kEnglishShort, uprv_lengthof(kEnglishShort));
 }
 
 void RelativeDateTimeFormatterTest::TestEnglishNarrow() {
-    RunTest("en", UDAT_STYLE_NARROW, kEnglishNarrow, LENGTHOF(kEnglishNarrow));
+    RunTest("en", UDAT_STYLE_NARROW, kEnglishNarrow, uprv_lengthof(kEnglishNarrow));
 }
 
 void RelativeDateTimeFormatterTest::TestSerbian() {
-    RunTest("sr", kSerbian, LENGTHOF(kSerbian));
+    RunTest("sr", kSerbian, uprv_lengthof(kSerbian));
 }
 
 void RelativeDateTimeFormatterTest::TestSerbianFallback() {
-    RunTest("sr", UDAT_STYLE_NARROW, kSerbian, LENGTHOF(kSerbian));
+    RunTest("sr", UDAT_STYLE_NARROW, kSerbian, uprv_lengthof(kSerbian));
 }
 
 void RelativeDateTimeFormatterTest::TestEnglishNoQuantity() {
-    RunTest("en", kEnglishNoQuantity, LENGTHOF(kEnglishNoQuantity));
+    RunTest("en", kEnglishNoQuantity, uprv_lengthof(kEnglishNoQuantity));
 }
 
 void RelativeDateTimeFormatterTest::TestEnglishNoQuantityCaps() {
@@ -675,7 +674,7 @@ void RelativeDateTimeFormatterTest::TestEnglishNoQuantityCaps() {
     RunTest(
             fmt,
             kEnglishNoQuantityCaps,
-            LENGTHOF(kEnglishNoQuantityCaps),
+            uprv_lengthof(kEnglishNoQuantityCaps),
             "en caps no quantity");
 }
 
@@ -684,7 +683,7 @@ void RelativeDateTimeFormatterTest::TestEnglishNoQuantityShort() {
             "en",
             UDAT_STYLE_SHORT,
             kEnglishNoQuantityShort,
-            LENGTHOF(kEnglishNoQuantityShort));
+            uprv_lengthof(kEnglishNoQuantityShort));
 }
 
 void RelativeDateTimeFormatterTest::TestEnglishNoQuantityNarrow() {
@@ -692,11 +691,11 @@ void RelativeDateTimeFormatterTest::TestEnglishNoQuantityNarrow() {
             "en",
             UDAT_STYLE_NARROW,
             kEnglishNoQuantityNarrow,
-            LENGTHOF(kEnglishNoQuantityNarrow));
+            uprv_lengthof(kEnglishNoQuantityNarrow));
 }
 
 void RelativeDateTimeFormatterTest::TestSpanishNoQuantity() {
-    RunTest("es", kSpanishNoQuantity, LENGTHOF(kSpanishNoQuantity));
+    RunTest("es", kSpanishNoQuantity, uprv_lengthof(kSpanishNoQuantity));
 }
 
 void RelativeDateTimeFormatterTest::TestFormatWithQuantityIllegalArgument() {
@@ -740,11 +739,11 @@ void RelativeDateTimeFormatterTest::TestCustomNumberFormat() {
 
     // Test copy constructor.
     RelativeDateTimeFormatter fmt2(fmt);
-    RunTest(fmt2, kEnglishDecimal, LENGTHOF(kEnglishDecimal), "en decimal digits");
+    RunTest(fmt2, kEnglishDecimal, uprv_lengthof(kEnglishDecimal), "en decimal digits");
 
     // Test assignment
     fmt = RelativeDateTimeFormatter("es", status);
-    RunTest(fmt, kSpanishNoQuantity, LENGTHOF(kSpanishNoQuantity), "assignment operator");
+    RunTest(fmt, kSpanishNoQuantity, uprv_lengthof(kSpanishNoQuantity), "assignment operator");
 
 }
 
index 3c7796d8bdbc86ca5d42a5ea8dc4eeade3c8f128..bae9efa02f8634a5f705beaea28df9eaa6ae2406 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2011, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  * Copyright (C) 2010 , Yahoo! Inc. 
  ********************************************************************/
@@ -13,8 +13,6 @@
 #include "cmemory.h"
 #include "unicode/selfmt.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define SIMPLE_PATTERN_STRING                                                    "feminine {feminineVerbValue} other{otherVerbValue}"
 
 
@@ -183,7 +181,7 @@ void SelectFormatTest::selectFormatUnitTest(/*char *par*/)
     selFmt = NULL;
 
     selFmt = new SelectFormat( SIMPLE_PATTERN , status); 
-    for (int32_t i = 0; i < LENGTHOF(keywords); i++ ){
+    for (int32_t i = 0; i < uprv_lengthof(keywords); i++ ){
         status = U_ZERO_ERROR;
         selFmt->format( keywords[i], result , ignore , status);
         if (!U_FAILURE(status)) {
index d86cb60d05fa30b2ecf86f34e573ef4a28a38cf1..3b0f2982101636a4b4e94c452d41ad94f021e757 100644 (file)
@@ -12,8 +12,6 @@
 #include "intltest.h"
 #include "simplepatternformatter.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 class SimplePatternFormatterTest : public IntlTest {
 public:
     SimplePatternFormatterTest() {
@@ -105,13 +103,13 @@ void SimplePatternFormatterTest::TestManyPlaceholders() {
             "Prefix: Templates frogtommy{0} and leg are out of order.",
             fmt.format(
                     params,
-                    LENGTHOF(params),
+                    uprv_lengthof(params),
                     appendTo,
                     offsets,
-                    LENGTHOF(offsets),
+                    uprv_lengthof(offsets),
                     status));
     assertSuccess("Status", status);
-    for (int32_t i = 0; i < LENGTHOF(expectedOffsets); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(expectedOffsets); ++i) {
         if (expectedOffsets[i] != offsets[i]) {
             errln("Expected %d, got %d", expectedOffsets[i], offsets[i]);
         }
@@ -119,25 +117,25 @@ void SimplePatternFormatterTest::TestManyPlaceholders() {
     appendTo.remove();
     fmt.format(
             params,
-            LENGTHOF(params) - 1,
+            uprv_lengthof(params) - 1,
             appendTo,
             offsets,
-            LENGTHOF(offsets),
+            uprv_lengthof(offsets),
             status);
     if (status != U_ILLEGAL_ARGUMENT_ERROR) {
         errln("Expected U_ILLEGAL_ARGUMENT_ERROR");
     }
     status = U_ZERO_ERROR;
-    offsets[LENGTHOF(offsets) - 1] = 289;
+    offsets[uprv_lengthof(offsets) - 1] = 289;
     appendTo.remove();
     fmt.format(
             params,
-            LENGTHOF(params),
+            uprv_lengthof(params),
             appendTo,
             offsets,
-            LENGTHOF(offsets) - 1,
+            uprv_lengthof(offsets) - 1,
             status);
-    assertEquals("Offsets buffer length", 289, offsets[LENGTHOF(offsets) - 1]);
+    assertEquals("Offsets buffer length", 289, offsets[uprv_lengthof(offsets) - 1]);
 
     // Test assignment
     SimplePatternFormatter s;
@@ -148,7 +146,7 @@ void SimplePatternFormatterTest::TestManyPlaceholders() {
             "Templates frogtommy{0} and leg are out of order.",
             s.format(
                     params,
-                    LENGTHOF(params),
+                    uprv_lengthof(params),
                     appendTo,
                     NULL,
                     0,
@@ -162,7 +160,7 @@ void SimplePatternFormatterTest::TestManyPlaceholders() {
             "Templates frogtommy{0} and leg are out of order.",
             r.format(
                     params,
-                    LENGTHOF(params),
+                    uprv_lengthof(params),
                     appendTo,
                     NULL,
                     0,
@@ -212,13 +210,13 @@ void SimplePatternFormatterTest::TestOptimization() {
             "leg, freddy, frog and by",
             fmt.format(
                     params,
-                    LENGTHOF(params),
+                    uprv_lengthof(params),
                     values[2],
                     offsets,
-                    LENGTHOF(offsets),
+                    uprv_lengthof(offsets),
                     status));
     assertSuccess("Status", status);
-    for (int32_t i = 0; i < LENGTHOF(expectedOffsets); ++i) {
+    for (int32_t i = 0; i < uprv_lengthof(expectedOffsets); ++i) {
         if (expectedOffsets[i] != offsets[i]) {
             errln("Expected %d, got %d", expectedOffsets[i], offsets[i]);
         }
index a35d5532782707218cc8296b18681731bfbc148b..17656b455769a95027c225b63dbcf6e2a168e35b 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2002-2013, International Business Machines
+*   Copyright (C) 2002-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -26,8 +26,7 @@
 #include "ucase.h"
 #include "ustrtest.h"
 #include "unicode/tstdtmod.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 StringCaseTest::~StringCaseTest() {}
 
@@ -491,7 +490,7 @@ StringCaseTest::TestCasing() {
                         // or even just { 0 } as boundaries.
                         static const UChar rules[] = { 0x2e, 0x2a, 0x3b };  // ".*;"
                         UParseError parseError;
-                        iter.adoptInstead(ubrk_openRules(rules, LENGTHOF(rules), NULL, 0, &parseError, &status));
+                        iter.adoptInstead(ubrk_openRules(rules, uprv_lengthof(rules), NULL, 0, &parseError, &status));
                     }
                 }
 #endif
index b32492f84d6aef5affe8f44c9bff1e1623e10bde..3eeef5d645e507982232b3c8c68dae44679d3e8a 100644 (file)
@@ -1,7 +1,7 @@
 
 /***********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2012, International Business Machines Corporation
+ * Copyright (c) 1997-2014, International Business Machines Corporation
  * and others. All Rights Reserved.
  ***********************************************************************/
 
@@ -11,6 +11,7 @@
 
 #include "intltest.h"
 #include "tfsmalls.h"
+#include "cmemory.h"
 
 #include "unicode/msgfmt.h"
 #include "unicode/choicfmt.h"
@@ -19,8 +20,6 @@
 #include "unicode/fieldpos.h"
 #include "unicode/fmtable.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /*static UBool chkstatus( UErrorCode &status, char* msg = NULL )
 {
     UBool ok = (status == U_ZERO_ERROR);
@@ -255,7 +254,7 @@ void test_Formattable( void )
         ucs,
         ucs_ptr
     };
-    const int32_t ft_cnt = LENGTHOF(ftarray);
+    const int32_t ft_cnt = uprv_lengthof(ftarray);
     Formattable ft_arr( ftarray, ft_cnt );
     UnicodeString temp;
     if ((ft_arr[0].getType() == Formattable::kDate)   && (ft_arr[0].getDate()   == 1.0)
index b141d82b2583e072a17b5e03ff2996c8ab8fdb57..17be2b73115013a1d0541cc8ababc475bdd21307 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************
  * File TMSGFMT.CPP
@@ -18,6 +18,7 @@
 #if !UCONFIG_NO_FORMATTING
 
 #include "tmsgfmt.h"
+#include "cmemory.h"
 
 #include "unicode/format.h"
 #include "unicode/decimfmt.h"
@@ -31,8 +32,6 @@
 #include "unicode/gregocal.h"
 #include <stdio.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void
 TestMessageFormat::runIndexedTest(int32_t index, UBool exec,
                                   const char* &name, char* /*par*/) {
@@ -1606,7 +1605,7 @@ void TestMessageFormat::TestApostropheMode() {
         "I don't know", "I don't know", "I don''t know",
         "I don't know", "I don''t know", "I don''t know"
     };
-    int32_t tuples_count = LENGTHOF(tuples);
+    int32_t tuples_count = uprv_lengthof(tuples);
 
     for (int i = 0; i < tuples_count; i += 3) {
       UnicodeString& desired = tuples[i];
index 56adf201605bd4bbcf7e6695a6113651b4e9584c..9bc3a77a051f546bf8f0ad592157a09657d92e34 100644 (file)
@@ -41,8 +41,6 @@
 #   undef POSIX
 #endif
 
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 /* Needed by z/OS to get usleep */
 #if U_PLATFORM == U_PF_OS390
 #define __DOT1 1
@@ -278,7 +276,7 @@ private:
   IntlTest inteltst =  IntlTest();
  
   status = U_ZERO_ERROR;
-  length = u_shapeArabic(src, -1, dst, LENGTHOF(dst),
+  length = u_shapeArabic(src, -1, dst, uprv_lengthof(dst),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_SEEN_TWOCELL_NEAR, &status);
   if(U_FAILURE(status)) {
           inteltst.errln("Fail: status %s\n", u_errorName(status)); 
@@ -286,7 +284,7 @@ private:
   } else if(length!=2) {
     inteltst.errln("Fail: len %d expected 3\n", length);
        return FALSE;
-  } else if(u_strncmp(dst,dst_old,LENGTHOF(dst))) {
+  } else if(u_strncmp(dst,dst_old,uprv_lengthof(dst))) {
     inteltst.errln("Fail: got U+%04X U+%04X expected U+%04X U+%04X\n",
             dst[0],dst[1],dst_old[0],dst_old[1]);
        return FALSE;
@@ -295,7 +293,7 @@ private:
 
   //"Trying new tail
   status = U_ZERO_ERROR;
-  length = u_shapeArabic(src, -1, dst, LENGTHOF(dst),
+  length = u_shapeArabic(src, -1, dst, uprv_lengthof(dst),
                          U_SHAPE_LETTERS_SHAPE|U_SHAPE_SEEN_TWOCELL_NEAR|U_SHAPE_TAIL_NEW_UNICODE, &status);
   if(U_FAILURE(status)) {
     inteltst.errln("Fail: status %s\n", u_errorName(status)); 
@@ -303,7 +301,7 @@ private:
   } else if(length!=2) {
     inteltst.errln("Fail: len %d expected 3\n", length);
        return FALSE;
-  } else if(u_strncmp(dst,dst_new,LENGTHOF(dst))) {
+  } else if(u_strncmp(dst,dst_new,uprv_lengthof(dst))) {
     inteltst.errln("Fail: got U+%04X U+%04X expected U+%04X U+%04X\n",
             dst[0],dst[1],dst_new[0],dst_new[1]);
        return FALSE;
@@ -1779,9 +1777,9 @@ void MultithreadTest::TestUnifiedCache() {
     gFinishedThreads = 0;
     gObjectsCreated = 0;
 
-    UnifiedCacheThread *threads[CACHE_LOAD][LENGTHOF(gCacheLocales)];
+    UnifiedCacheThread *threads[CACHE_LOAD][uprv_lengthof(gCacheLocales)];
     for (int32_t i=0; i<CACHE_LOAD; ++i) {
-        for (int32_t j=0; j<LENGTHOF(gCacheLocales); ++j) {
+        for (int32_t j=0; j<uprv_lengthof(gCacheLocales); ++j) {
             threads[i][j] = new UnifiedCacheThread(gCacheLocales[j]);
             threads[i][j]->start();
         }
@@ -1789,15 +1787,15 @@ void MultithreadTest::TestUnifiedCache() {
     // Wait on all the threads to complete verify that LENGTHOF(gCacheLocales)
     // objects were created.
     umtx_lock(&gCTMutex);
-    while (gFinishedThreads < CACHE_LOAD*LENGTHOF(gCacheLocales)) {
+    while (gFinishedThreads < CACHE_LOAD*uprv_lengthof(gCacheLocales)) {
         umtx_condWait(&gCTConditionVar, &gCTMutex);
     }
-    assertEquals("Objects created", LENGTHOF(gCacheLocales), gObjectsCreated);
+    assertEquals("Objects created", uprv_lengthof(gCacheLocales), gObjectsCreated);
     umtx_unlock(&gCTMutex);
 
     // clean up threads
     for (int32_t i=0; i<CACHE_LOAD; ++i) {
-        for (int32_t j=0; j<LENGTHOF(gCacheLocales); ++j) {
+        for (int32_t j=0; j<uprv_lengthof(gCacheLocales); ++j) {
             delete threads[i][j];
         }
     }
index cde6dbe88c77ab4a58fbae68a014d24ce2e69fb9..075b83b21d4b8eeffa45c6352fd72ff6fcbedc97 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2011, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -19,8 +19,7 @@
 #include "normalizer2impl.h"
 #include "tstnorm.h"
 
-#define LENGTHOF(array) ((int32_t)(sizeof(array)/sizeof((array)[0])))
-#define ARRAY_LENGTH(array) LENGTHOF(array)
+#define ARRAY_LENGTH(array) uprv_lengthof(array)
 
 #define CASE(id,test) case id:                          \
                           name = #test;                 \
@@ -747,27 +746,27 @@ BasicNormalizerTest::TestPreviousNext() {
     // for both sets of test data
     static const char *const moves="0+0+0--0-0-+++0--+++++++0--------";
 
-    TestPreviousNext(src, LENGTHOF(src),
-                     expect, LENGTHOF(expect),
+    TestPreviousNext(src, uprv_lengthof(src),
+                     expect, uprv_lengthof(expect),
                      expectIndex,
                      SRC_MIDDLE, EXPECT_MIDDLE,
                      moves, UNORM_NFD, "basic");
 
-    TestPreviousNext(src_j2911, LENGTHOF(src_j2911),
-                     expect_j2911, LENGTHOF(expect_j2911),
+    TestPreviousNext(src_j2911, uprv_lengthof(src_j2911),
+                     expect_j2911, uprv_lengthof(expect_j2911),
                      expectIndex_j2911,
                      SRC_MIDDLE, EXPECT_MIDDLE,
                      moves, UNORM_NFKC, "j2911");
 
     // try again from different "middle" indexes
-    TestPreviousNext(src, LENGTHOF(src),
-                     expect, LENGTHOF(expect),
+    TestPreviousNext(src, uprv_lengthof(src),
+                     expect, uprv_lengthof(expect),
                      expectIndex,
                      SRC_MIDDLE_2, EXPECT_MIDDLE_2,
                      moves, UNORM_NFD, "basic_2");
 
-    TestPreviousNext(src_j2911, LENGTHOF(src_j2911),
-                     expect_j2911, LENGTHOF(expect_j2911),
+    TestPreviousNext(src_j2911, uprv_lengthof(src_j2911),
+                     expect_j2911, uprv_lengthof(expect_j2911),
                      expectIndex_j2911,
                      SRC_MIDDLE_2, EXPECT_MIDDLE_2,
                      moves, UNORM_NFKC, "j2911_2");
@@ -1064,7 +1063,7 @@ BasicNormalizerTest::TestCompare() {
         { UNORM_UNICODE_3_2<<UNORM_COMPARE_NORM_OPTIONS_SHIFT, "Unicode 3.2" }
     };
 
-    int32_t i, j, k, count=LENGTHOF(strings);
+    int32_t i, j, k, count=uprv_lengthof(strings);
     int32_t result, refResult;
 
     UErrorCode errorCode;
@@ -1077,7 +1076,7 @@ BasicNormalizerTest::TestCompare() {
     // test them each with each other
     for(i=0; i<count; ++i) {
         for(j=i; j<count; ++j) {
-            for(k=0; k<LENGTHOF(opt); ++k) {
+            for(k=0; k<uprv_lengthof(opt); ++k) {
                 // test Normalizer::compare
                 errorCode=U_ZERO_ERROR;
                 result=_norm_compare(s[i], s[j], opt[k].options, errorCode);
@@ -1117,7 +1116,7 @@ BasicNormalizerTest::TestCompare() {
     }
 
     // collect all sets into one for contiguous output
-    for(i=0; i<LENGTHOF(iI); ++i) {
+    for(i=0; i<uprv_lengthof(iI); ++i) {
         if(nfcImpl->getCanonStartSet(iI[i], iSet)) {
             set.addAll(iSet);
         }
@@ -1134,7 +1133,7 @@ BasicNormalizerTest::TestCompare() {
         }
 
         s1.setTo(c);
-        for(k=0; k<LENGTHOF(opt); ++k) {
+        for(k=0; k<uprv_lengthof(opt); ++k) {
             // test Normalizer::compare
             errorCode=U_ZERO_ERROR;
             result=_norm_compare(s1, s2, opt[k].options, errorCode);
@@ -1438,7 +1437,7 @@ BasicNormalizerTest::TestCustomComp() {
     if(errorCode.logDataIfFailureAndReset("unable to load testdata/testnorm.nrm")) {
         return;
     }
-    for(int32_t i=0; i<LENGTHOF(pairs); ++i) {
+    for(int32_t i=0; i<uprv_lengthof(pairs); ++i) {
         const StringPair &pair=pairs[i];
         UnicodeString input=UnicodeString(pair.input, -1, US_INV).unescape();
         UnicodeString expected=UnicodeString(pair.expected, -1, US_INV).unescape();
@@ -1470,7 +1469,7 @@ BasicNormalizerTest::TestCustomFCC() {
     if(errorCode.logDataIfFailureAndReset("unable to load testdata/testnorm.nrm")) {
         return;
     }
-    for(int32_t i=0; i<LENGTHOF(pairs); ++i) {
+    for(int32_t i=0; i<uprv_lengthof(pairs); ++i) {
         const StringPair &pair=pairs[i];
         UnicodeString input=UnicodeString(pair.input, -1, US_INV).unescape();
         UnicodeString expected=UnicodeString(pair.expected, -1, US_INV).unescape();
index 20ffe253f27f064397dff584dd2835a47569b819..9a1d2ccfcc954b6fbb15771f0d0a3a7d211b8476 100644 (file)
@@ -12,6 +12,7 @@
 #include "unicode/tmutamt.h"
 #include "unicode/tmutfmt.h"
 #include "tufmtts.h"
+#include "cmemory.h"
 #include "unicode/ustring.h"
 
 //TODO: put as compilation flag
@@ -21,8 +22,6 @@
 #include <iostream>
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 void TimeUnitTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) {
     if (exec) logln("TestSuite TimeUnitTest");
     switch (index) {
@@ -422,8 +421,8 @@ void TimeUnitTest::test10219Plurals() {
         dataerrln("generating NumberFormat Object failed: %s", u_errorName(status));
         return;
     }
-    for (int32_t j = 0; j < LENGTHOF(values); ++j) {
-        for (int32_t i = 0; i < LENGTHOF(expected[j]); ++i) {
+    for (int32_t j = 0; j < uprv_lengthof(values); ++j) {
+        for (int32_t i = 0; i < uprv_lengthof(expected[j]); ++i) {
             nf->setMinimumFractionDigits(i);
             nf->setMaximumFractionDigits(i);
             nf->setRoundingMode(DecimalFormat::kRoundDown);
index fc4b40cba0da0122d10ada8c7c03eeb78dafc37b..192cc17b735a3f51c72dfc5a35790bf9bb925218 100644 (file)
@@ -21,8 +21,6 @@
 #include "cstring.h"
 #include "olsontz.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define CASE(id,test) case id:                               \
                           name = #test;                      \
                           if (exec) {                        \
@@ -1907,9 +1905,9 @@ void TimeZoneTest::TestFebruary() {
     TimeZone *tz;
     UDate dt;
     int32_t t, i, raw, dst;
-    for (t = 0; t < LENGTHOF(timezones); ++t) {
+    for (t = 0; t < uprv_lengthof(timezones); ++t) {
         tz = timezones[t];
-        for (i = 0; i < LENGTHOF(data); ++i) {
+        for (i = 0; i < uprv_lengthof(data); ++i) {
             gc.set(data[i].year, data[i].month, data[i].day,
                    data[i].hour, data[i].minute, data[i].second);
             dt = gc.getTime(status);
index f15da713652426d1130e5338aa28c3cee77fba1a..181fa50bdaa49f36ef95763ae6a4b3f4c66852a5 100644 (file)
@@ -16,8 +16,6 @@
 #include "uparse.h"
 #include "ucdtest.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0]))
-
 static const char *ignorePropNames[]={
     "FC_NFKC",
     "NFD_QC",
@@ -40,7 +38,7 @@ UnicodeTest::UnicodeTest()
         unknownPropertyNames=NULL;
     }
     // Ignore some property names altogether.
-    for(int32_t i=0; i<LENGTHOF(ignorePropNames); ++i) {
+    for(int32_t i=0; i<uprv_lengthof(ignorePropNames); ++i) {
         unknownPropertyNames->puti(UnicodeString(ignorePropNames[i], -1, US_INV), 1, errorCode);
     }
 }
@@ -150,7 +148,7 @@ derivedPropsIndex[]={
     UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED
 };
 
-static int32_t numErrors[LENGTHOF(derivedPropsIndex)]={ 0 };
+static int32_t numErrors[uprv_lengthof(derivedPropsIndex)]={ 0 };
 
 enum { MAX_ERRORS=50 };
 
@@ -170,7 +168,7 @@ derivedPropsLineFn(void *context,
     }
 
     /* parse derived binary property name, ignore unknown names */
-    i=getTokenIndex(derivedPropsNames, LENGTHOF(derivedPropsNames), fields[1][0]);
+    i=getTokenIndex(derivedPropsNames, uprv_lengthof(derivedPropsNames), fields[1][0]);
     if(i<0) {
         UnicodeString propName(fields[1][0], (int32_t)(fields[1][1]-fields[1][0]));
         propName.trim();
@@ -188,13 +186,13 @@ derivedPropsLineFn(void *context,
 void UnicodeTest::TestAdditionalProperties() {
 #if !UCONFIG_NO_NORMALIZATION
     // test DerivedCoreProperties.txt and DerivedNormalizationProps.txt
-    if(LENGTHOF(derivedProps)<LENGTHOF(derivedPropsNames)) {
+    if(uprv_lengthof(derivedProps)<uprv_lengthof(derivedPropsNames)) {
         errln("error: UnicodeTest::derivedProps[] too short, need at least %d UnicodeSets\n",
-              LENGTHOF(derivedPropsNames));
+              uprv_lengthof(derivedPropsNames));
         return;
     }
-    if(LENGTHOF(derivedPropsIndex)!=LENGTHOF(derivedPropsNames)) {
-        errln("error in ucdtest.cpp: LENGTHOF(derivedPropsIndex)!=LENGTHOF(derivedPropsNames)\n");
+    if(uprv_lengthof(derivedPropsIndex)!=uprv_lengthof(derivedPropsNames)) {
+        errln("error in ucdtest.cpp: uprv_lengthof(derivedPropsIndex)!=uprv_lengthof(derivedPropsNames)\n");
         return;
     }
 
@@ -228,7 +226,7 @@ void UnicodeTest::TestAdditionalProperties() {
     UChar32 start, end;
 
     // test all TRUE properties
-    for(i=0; i<LENGTHOF(derivedPropsNames); ++i) {
+    for(i=0; i<uprv_lengthof(derivedPropsNames); ++i) {
         rangeCount=derivedProps[i].getRangeCount();
         for(range=0; range<rangeCount && numErrors[i]<MAX_ERRORS; ++range) {
             start=derivedProps[i].getRangeStart(range);
@@ -246,12 +244,12 @@ void UnicodeTest::TestAdditionalProperties() {
     }
 
     // invert all properties
-    for(i=0; i<LENGTHOF(derivedPropsNames); ++i) {
+    for(i=0; i<uprv_lengthof(derivedPropsNames); ++i) {
         derivedProps[i].complement();
     }
 
     // test all FALSE properties
-    for(i=0; i<LENGTHOF(derivedPropsNames); ++i) {
+    for(i=0; i<uprv_lengthof(derivedPropsNames); ++i) {
         rangeCount=derivedProps[i].getRangeCount();
         for(range=0; range<rangeCount && numErrors[i]<MAX_ERRORS; ++range) {
             start=derivedProps[i].getRangeStart(range);
@@ -285,7 +283,7 @@ void UnicodeTest::TestBinaryValues() {
     static const char *const falseValues[]={ "N", "No", "F", "False" };
     static const char *const trueValues[]={ "Y", "Yes", "T", "True" };
     int32_t i;
-    for(i=0; i<LENGTHOF(falseValues); ++i) {
+    for(i=0; i<uprv_lengthof(falseValues); ++i) {
         UnicodeString pattern=UNICODE_STRING_SIMPLE("[:Alphabetic=:]");
         pattern.insert(pattern.length()-2, UnicodeString(falseValues[i], -1, US_INV));
         errorCode=U_ZERO_ERROR;
@@ -299,7 +297,7 @@ void UnicodeTest::TestBinaryValues() {
             errln("UnicodeSet([:Alphabetic=%s:]).complement()!=UnicodeSet([:Alphabetic:])\n", falseValues[i]);
         }
     }
-    for(i=0; i<LENGTHOF(trueValues); ++i) {
+    for(i=0; i<uprv_lengthof(trueValues); ++i) {
         UnicodeString pattern=UNICODE_STRING_SIMPLE("[:Alphabetic=:]");
         pattern.insert(pattern.length()-2, UnicodeString(trueValues[i], -1, US_INV));
         errorCode=U_ZERO_ERROR;
index 92f9bcee4c24f45be46d68c0ec5d62590a47cf67..71672e383328fb31a6fea86b934b80b963113fca 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2010-2013, International Business Machines
+*   Copyright (C) 2010-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  ucharstrietest.cpp
@@ -22,8 +22,7 @@
 #include "unicode/uniset.h"
 #include "unicode/unistr.h"
 #include "intltest.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 struct StringAndValue {
     const char *s;
@@ -138,14 +137,14 @@ void UCharsTrieTest::TestEmpty() {
     static const StringAndValue data[]={
         { "", 0 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::Test_a() {
     static const StringAndValue data[]={
         { "a", 1 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::Test_a_ab() {
@@ -153,7 +152,7 @@ void UCharsTrieTest::Test_a_ab() {
         { "a", 1 },
         { "ab", 100 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestShortestBranch() {
@@ -161,7 +160,7 @@ void UCharsTrieTest::TestShortestBranch() {
         { "a", 1000 },
         { "b", 2000 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestBranches() {
@@ -181,7 +180,7 @@ void UCharsTrieTest::TestBranches() {
         { "vv", 0x7fffffff },
         { "zz", (int32_t)0x80000000 }
     };
-    for(int32_t length=2; length<=LENGTHOF(data); ++length) {
+    for(int32_t length=2; length<=uprv_lengthof(data); ++length) {
         logln("TestBranches length=%d", (int)length);
         checkData(data, length);
     }
@@ -200,7 +199,7 @@ void UCharsTrieTest::TestLongSequence() {
           "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
           "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -3 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestLongBranch() {
@@ -228,7 +227,7 @@ void UCharsTrieTest::TestLongBranch() {
         { "t234567890", 0x77777777 },
         { "z", (int32_t)0x80000001 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestValuesForState() {
@@ -242,7 +241,7 @@ void UCharsTrieTest::TestValuesForState() {
         { "abcde", -5 },
         { "abcdef", -6 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestCompact() {
@@ -269,7 +268,7 @@ void UCharsTrieTest::TestCompact() {
         { "xjuly", 7 },
         { "xjune", 6 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestFirstForCodePoint() {
@@ -284,7 +283,7 @@ void UCharsTrieTest::TestFirstForCodePoint() {
         { "\\U00050000xy", 8 },
         { "\\U00050000xyz", 9 }
     };
-    checkData(data, LENGTHOF(data));
+    checkData(data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestNextForCodePoint() {
@@ -293,7 +292,7 @@ void UCharsTrieTest::TestNextForCodePoint() {
         { "\\u4dff\\U00010000\\u9999\\U00020002", 44444 },
         { "\\u4dff\\U000103ff", 99999 }
     };
-    LocalPointer<UCharsTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
+    LocalPointer<UCharsTrie> trie(buildTrie(data, uprv_lengthof(data), USTRINGTRIE_BUILD_FAST));
     if(trie.isNull()) {
         return;  // buildTrie() reported an error
     }
@@ -457,7 +456,7 @@ UCharsTrie *UCharsTrieTest::buildMonthsTrie(UStringTrieBuildOption buildOption)
         { "jun.", 6 },
         { "june", 6 }
     };
-    return buildTrie(data, LENGTHOF(data), buildOption);
+    return buildTrie(data, uprv_lengthof(data), buildOption);
 }
 
 void UCharsTrieTest::TestHasUniqueValue() {
@@ -589,10 +588,10 @@ void UCharsTrieTest::TestIteratorFromBranch() {
         { "uar", 1 },
         { "uary", 1 }
     };
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), data, LENGTHOF(data));
+    checkIterator(iter.reset(), data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestIteratorFromLinearMatch() {
@@ -617,10 +616,10 @@ void UCharsTrieTest::TestIteratorFromLinearMatch() {
         { "r", 1 },
         { "ry", 1 }
     };
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), data, LENGTHOF(data));
+    checkIterator(iter.reset(), data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestTruncatingIteratorFromRoot() {
@@ -663,10 +662,10 @@ void UCharsTrieTest::TestTruncatingIteratorFromRoot() {
         { "jun.", 6 },
         { "june", 6 }
     };
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), data, LENGTHOF(data));
+    checkIterator(iter.reset(), data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchShort() {
@@ -675,7 +674,7 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchShort() {
         { "abcdepq", 200 },
         { "abcdeyz", 3000 }
     };
-    LocalPointer<UCharsTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
+    LocalPointer<UCharsTrie> trie(buildTrie(data, uprv_lengthof(data), USTRINGTRIE_BUILD_FAST));
     if(trie.isNull()) {
         return;  // buildTrie() reported an error
     }
@@ -691,10 +690,10 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchShort() {
     static const StringAndValue expected[]={
         { "cd", -1 }
     };
-    checkIterator(iter, expected, LENGTHOF(expected));
+    checkIterator(iter, expected, uprv_lengthof(expected));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), expected, LENGTHOF(expected));
+    checkIterator(iter.reset(), expected, uprv_lengthof(expected));
 }
 
 void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
@@ -703,7 +702,7 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
         { "abcdepq", 200 },
         { "abcdeyz", 3000 }
     };
-    LocalPointer<UCharsTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST));
+    LocalPointer<UCharsTrie> trie(buildTrie(data, uprv_lengthof(data), USTRINGTRIE_BUILD_FAST));
     if(trie.isNull()) {
         return;  // buildTrie() reported an error
     }
@@ -722,10 +721,10 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchLong() {
         { "dep", -1 },
         { "dey", -1 }
     };
-    checkIterator(iter, expected, LENGTHOF(expected));
+    checkIterator(iter, expected, uprv_lengthof(expected));
     // Reset, and we should get the same result.
     logln("after iter.reset()");
-    checkIterator(iter.reset(), expected, LENGTHOF(expected));
+    checkIterator(iter.reset(), expected, uprv_lengthof(expected));
 }
 
 void UCharsTrieTest::TestIteratorFromUChars() {
@@ -736,13 +735,13 @@ void UCharsTrieTest::TestIteratorFromUChars() {
     };
     builder_->clear();
     IcuTestErrorCode errorCode(*this, "TestIteratorFromUChars()");
-    for(int32_t i=0; i<LENGTHOF(data); ++i) {
+    for(int32_t i=0; i<uprv_lengthof(data); ++i) {
         builder_->add(data[i].s, data[i].value, errorCode);
     }
     UnicodeString trieUChars;
     builder_->buildUnicodeString(USTRINGTRIE_BUILD_FAST, trieUChars, errorCode);
     UCharsTrie::Iterator iter(trieUChars.getBuffer(), 0, errorCode);
-    checkIterator(iter, data, LENGTHOF(data));
+    checkIterator(iter, data, uprv_lengthof(data));
 }
 
 void UCharsTrieTest::checkData(const StringAndValue data[], int32_t dataLength) {
@@ -1035,7 +1034,7 @@ void UCharsTrieTest::checkIterator(UCharsTrie::Iterator &iter,
         if(iter.getString()!=expectedString) {
             char buffer[1000];
             UnicodeString invString(prettify(iter.getString()));
-            invString.extract(0, invString.length(), buffer, LENGTHOF(buffer), US_INV);
+            invString.extract(0, invString.length(), buffer, uprv_lengthof(buffer), US_INV);
             errln("trie iterator next().getString()=%s but expected %s for item %d",
                   buffer, data[i].s, (int)i);
         }
index 8edf6679b65a2d57f8b898b391e43f73fa61473c..e4955ff363477661cc37987f987e135b81a4361f 100644 (file)
@@ -24,8 +24,6 @@
 #include "unicode/uversion.h"
 #include "hash.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
     dataerrln("fail in file \"%s\", line %d: \"%s\"", __FILE__, __LINE__, \
     u_errorName(status));}}
@@ -2322,7 +2320,7 @@ public:
             const UnicodeString *s;
             char *s8=utf8;
             int32_t length8, utf8Count=0;
-            while(iter.nextRange() && stringsLength<LENGTHOF(strings)) {
+            while(iter.nextRange() && stringsLength<uprv_lengthof(strings)) {
                 if(iter.isString()) {
                     // Store the pointer to the set's string element
                     // which we happen to know is a stable pointer.
@@ -3076,7 +3074,7 @@ void UnicodeSetTest::testSpan(const UnicodeSetWithStrings *sets[4],
                                  s, length, isUTF16,
                                  whichSpans,
                                  type, typeName,
-                                 limits, LENGTHOF(limits), expectCount);
+                                 limits, uprv_lengthof(limits), expectCount);
             if(typeName[0]==0) {
                 break; // All types tried.
             }
@@ -3085,9 +3083,9 @@ void UnicodeSetTest::testSpan(const UnicodeSetWithStrings *sets[4],
             }
             if(expectCount<0) {
                 expectCount=limitsCount;
-                if(limitsCount>LENGTHOF(limits)) {
+                if(limitsCount>uprv_lengthof(limits)) {
                     errln("FAIL: %s[0x%lx].%s.%s span count=%ld > %ld capacity - too many spans",
-                          testName, (long)index, setNames[i], typeName, (long)limitsCount, (long)LENGTHOF(limits));
+                          testName, (long)index, setNames[i], typeName, (long)limitsCount, (long)uprv_lengthof(limits));
                     return;
                 }
                 memcpy(expectLimits, limits, limitsCount*4);
@@ -3280,7 +3278,7 @@ void UnicodeSetTest::testSpanContents(const UnicodeSetWithStrings *sets[4], uint
 
     UChar32 c, first;
     for(first=c=0;; c=nextCodePoint(c)) {
-        if(c>0x10ffff || length>(LENGTHOF(s)-U16_MAX_LENGTH)) {
+        if(c>0x10ffff || length>(uprv_lengthof(s)-U16_MAX_LENGTH)) {
             localWhichSpans=whichSpans;
             if(stringContainsUnpairedSurrogate(s, length) && inconsistentSurrogates) {
                 localWhichSpans&=~SPAN_UTF8;
@@ -3316,7 +3314,7 @@ void UnicodeSetTest::testSpanUTF16String(const UnicodeSetWithStrings *sets[4], u
         return;
     }
     testSpan(sets, s, -1, TRUE, (whichSpans&~SPAN_UTF8), testName, 0);
-    testSpan(sets, s, LENGTHOF(s)-1, TRUE, (whichSpans&~SPAN_UTF8), testName, 1);
+    testSpan(sets, s, uprv_lengthof(s)-1, TRUE, (whichSpans&~SPAN_UTF8), testName, 1);
 }
 
 void UnicodeSetTest::testSpanUTF8String(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName) {
@@ -3413,7 +3411,7 @@ void UnicodeSetTest::testSpanUTF8String(const UnicodeSetWithStrings *sets[4], ui
         return;
     }
     testSpan(sets, s, -1, FALSE, (whichSpans&~SPAN_UTF16), testName, 0);
-    testSpan(sets, s, LENGTHOF(s)-1, FALSE, (whichSpans&~SPAN_UTF16), testName, 1);
+    testSpan(sets, s, uprv_lengthof(s)-1, FALSE, (whichSpans&~SPAN_UTF16), testName, 1);
 }
 
 // Take a set of span options and multiply them so that
@@ -3615,7 +3613,7 @@ void UnicodeSetTest::TestSpan() {
     char *testNameLimit=testName;
 
     int32_t i, j;
-    for(i=0; i<LENGTHOF(testdata); ++i) {
+    for(i=0; i<uprv_lengthof(testdata); ++i) {
         const char *s=testdata[i];
         if(s[0]=='[') {
             // Create new test sets from this pattern.
index c13fce8b2990da98e8f6561c644e4a722d6fef68..200b8251650c0dc4b886b0d73d9ac03ec35dc83c 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -25,8 +25,6 @@ using namespace std;
 
 #endif
 
-#define LENGTHOF(array) (int32_t)((sizeof(array)/sizeof((array)[0])))
-
 UnicodeStringTest::~UnicodeStringTest() {}
 
 void UnicodeStringTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char *par)
@@ -199,9 +197,9 @@ UnicodeStringTest::TestBasicManipulation()
         }
 
         UChar buffer[10]={ 0x61, 0x62, 0x20ac, 0xd900, 0xdc05, 0,   0x62, 0xffff, 0xdbff, 0xdfff };
-        UnicodeString s, t(buffer, -1, LENGTHOF(buffer));
+        UnicodeString s, t(buffer, -1, uprv_lengthof(buffer));
 
-        if(s.setTo(buffer, -1, LENGTHOF(buffer)).length()!=u_strlen(buffer)) {
+        if(s.setTo(buffer, -1, uprv_lengthof(buffer)).length()!=u_strlen(buffer)) {
             errln("UnicodeString.setTo(buffer, length, capacity) does not work with length==-1");
         }
         if(t.length()!=u_strlen(buffer)) {
@@ -216,11 +214,11 @@ UnicodeStringTest::TestBasicManipulation()
         }
 
         buffer[u_strlen(buffer)]=0xe4;
-        UnicodeString u(buffer, -1, LENGTHOF(buffer));
-        if(s.setTo(buffer, -1, LENGTHOF(buffer)).length()!=LENGTHOF(buffer)) {
+        UnicodeString u(buffer, -1, uprv_lengthof(buffer));
+        if(s.setTo(buffer, -1, uprv_lengthof(buffer)).length()!=uprv_lengthof(buffer)) {
             errln("UnicodeString.setTo(buffer without NUL, length, capacity) does not work with length==-1");
         }
-        if(u.length()!=LENGTHOF(buffer)) {
+        if(u.length()!=uprv_lengthof(buffer)) {
             errln("UnicodeString(buffer without NUL, length, capacity) does not work with length==-1");
         }
 
@@ -243,7 +241,7 @@ UnicodeStringTest::TestBasicManipulation()
         static const UChar utf16[]={ 0x61, 0xE4, 0xDF, 0x4E00 };
         UnicodeString from8a = UnicodeString((const char *)utf8);
         UnicodeString from8b = UnicodeString((const char *)utf8, (int32_t)sizeof(utf8)-1);
-        UnicodeString from16(FALSE, utf16, LENGTHOF(utf16));
+        UnicodeString from16(FALSE, utf16, uprv_lengthof(utf16));
         if(from8a != from16 || from8b != from16) {
             errln("UnicodeString(const char * U_CHARSET_IS_UTF8) failed");
         }
@@ -1410,7 +1408,7 @@ UnicodeStringTest::TestCountChar32(void) {
         0xd804, 0xdc04, 0xd805, 0xdc05,
         0x67
     };
-    UnicodeString string(str, LENGTHOF(str));
+    UnicodeString string(str, uprv_lengthof(str));
     int32_t start, length, number;
 
     /* test hasMoreChar32Than() */
@@ -1664,11 +1662,11 @@ public:
     TestEnumeration() : i(0) {}
 
     virtual int32_t count(UErrorCode& /*status*/) const {
-        return LENGTHOF(testEnumStrings);
+        return uprv_lengthof(testEnumStrings);
     }
 
     virtual const UnicodeString *snext(UErrorCode &status) {
-        if(U_SUCCESS(status) && i<LENGTHOF(testEnumStrings)) {
+        if(U_SUCCESS(status) && i<uprv_lengthof(testEnumStrings)) {
             unistr=UnicodeString(testEnumStrings[i++], "");
             return &unistr;
         }
@@ -1706,7 +1704,7 @@ UnicodeStringTest::TestStringEnumeration() {
     const char *pc;
 
     // test the next() default implementation and ensureCharsCapacity()
-    for(i=0; i<LENGTHOF(testEnumStrings); ++i) {
+    for(i=0; i<uprv_lengthof(testEnumStrings); ++i) {
         status=U_ZERO_ERROR;
         pc=ten.next(&length, status);
         s=UnicodeString(testEnumStrings[i], "");
@@ -1721,7 +1719,7 @@ UnicodeStringTest::TestStringEnumeration() {
 
     // test the unext() default implementation
     ten.reset(status);
-    for(i=0; i<LENGTHOF(testEnumStrings); ++i) {
+    for(i=0; i<uprv_lengthof(testEnumStrings); ++i) {
         status=U_ZERO_ERROR;
         pu=ten.unext(&length, status);
         s=UnicodeString(testEnumStrings[i], "");
@@ -1750,7 +1748,7 @@ UnicodeStringTest::TestStringEnumeration() {
     }
     
     // test  uenum_next()
-    for(i=0; i<LENGTHOF(testEnumStrings); ++i) {
+    for(i=0; i<uprv_lengthof(testEnumStrings); ++i) {
         status=U_ZERO_ERROR;
         pc=uenum_next(uten, &length, &status);
         if(U_FAILURE(status) || pc==NULL || strcmp(pc, testEnumStrings[i]) != 0) {
@@ -1764,7 +1762,7 @@ UnicodeStringTest::TestStringEnumeration() {
 
     // test the uenum_unext()
     uenum_reset(uten, &status);
-    for(i=0; i<LENGTHOF(testEnumStrings); ++i) {
+    for(i=0; i<uprv_lengthof(testEnumStrings); ++i) {
         status=U_ZERO_ERROR;
         pu=uenum_unext(uten, &length, &status);
         s=UnicodeString(testEnumStrings[i], "");
@@ -1829,8 +1827,8 @@ UnicodeStringTest::TestUTF32() {
         0x41, 0xfffd, 0x61, 0xfffd, 0xfffd, 0xfffd, 0x5a, 0xd900, 0xdc00, 0x7a,
         0xd800, 0xdc00, 0xd840, 0xdc00, 0xdb40, 0xdc00, 0xdbff, 0xdfff
     };
-    UnicodeString from32 = UnicodeString::fromUTF32(utf32, LENGTHOF(utf32));
-    UnicodeString expected(FALSE, expected_utf16, LENGTHOF(expected_utf16));
+    UnicodeString from32 = UnicodeString::fromUTF32(utf32, uprv_lengthof(utf32));
+    UnicodeString expected(FALSE, expected_utf16, uprv_lengthof(expected_utf16));
     if(from32 != expected) {
         errln("UnicodeString::fromUTF32() did not create the expected string.");
     }
@@ -1844,9 +1842,9 @@ UnicodeStringTest::TestUTF32() {
     UChar32 result32[16];
     UErrorCode errorCode = U_ZERO_ERROR;
     int32_t length32 =
-        UnicodeString(FALSE, utf16, LENGTHOF(utf16)).
-        toUTF32(result32, LENGTHOF(result32), errorCode);
-    if( length32 != LENGTHOF(expected_utf32) ||
+        UnicodeString(FALSE, utf16, uprv_lengthof(utf16)).
+        toUTF32(result32, uprv_lengthof(result32), errorCode);
+    if( length32 != uprv_lengthof(expected_utf32) ||
         0 != uprv_memcmp(result32, expected_utf32, length32*4) ||
         result32[length32] != 0
     ) {
@@ -1888,7 +1886,7 @@ UnicodeStringTest::TestUTF8() {
         0xdb40, 0xdc00, 0xdbff, 0xdfff
     };
     UnicodeString from8 = UnicodeString::fromUTF8(StringPiece((const char *)utf8, (int32_t)sizeof(utf8)));
-    UnicodeString expected(FALSE, expected_utf16, LENGTHOF(expected_utf16));
+    UnicodeString expected(FALSE, expected_utf16, uprv_lengthof(expected_utf16));
 
     if(from8 != expected) {
         errln("UnicodeString::fromUTF8(StringPiece) did not create the expected string.");
@@ -1908,7 +1906,7 @@ UnicodeStringTest::TestUTF8() {
         0x41, 0xef, 0xbf, 0xbd, 0x61, 0xef, 0xbf, 0xbd, 0x5a, 0xf1, 0x90, 0x80, 0x80, 0x7a,
         0xf0, 0x90, 0x80, 0x80, 0xf4, 0x8f, 0xbf, 0xbf
     };
-    UnicodeString us(FALSE, utf16, LENGTHOF(utf16));
+    UnicodeString us(FALSE, utf16, uprv_lengthof(utf16));
 
     char buffer[64];
     TestCheckedArrayByteSink sink(buffer, (int32_t)sizeof(buffer));
index e71414180810bcf4caf70439a5ace95435dfffe8..28563a71551246badd1f42f047001d2a50d88604 100644 (file)
@@ -25,8 +25,7 @@
 #include "unicode/uidna.h"
 #include "unicode/unistr.h"
 #include "intltest.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 class UTS46Test : public IntlTest {
 public:
@@ -147,7 +146,7 @@ void UTS46Test::TestAPI() {
     }
     // UTF-8
     char buffer[100];
-    TestCheckedArrayByteSink sink(buffer, LENGTHOF(buffer));
+    TestCheckedArrayByteSink sink(buffer, uprv_lengthof(buffer));
     errorCode=U_ZERO_ERROR;
     nontrans->labelToUnicodeUTF8(StringPiece(NULL, 5), sink, info, errorCode);
     if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || sink.NumberOfBytesWritten()!=0) {
@@ -214,7 +213,7 @@ void UTS46Test::TestNotSTD3() {
             UNICODE_STRING_SIMPLE("\\u0000a_2+2=4\\u000A.essen.net").unescape() ||
         info.hasErrors()
     ) {
-        prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+        prettify(result).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
         errln("notSTD3.nameToUnicode(non-LDH ASCII) unexpected errors %04lx string %s",
               (long)info.getErrors(), buffer);
     }
@@ -228,7 +227,7 @@ void UTS46Test::TestNotSTD3() {
     input=UNICODE_STRING_SIMPLE("a\\u2260b\\u226Ec\\u226Fd").unescape();
     not3->nameToUnicode(input, result, info, errorCode);
     if(result!=input || info.hasErrors()) {
-        prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+        prettify(result).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
         errln("notSTD3.nameToUnicode(equiv to non-LDH ASCII) unexpected errors %04lx string %s",
               (long)info.getErrors(), buffer);
     }
@@ -583,7 +582,7 @@ void UTS46Test::TestSomeCases() {
     IcuTestErrorCode errorCode(*this, "TestSomeCases");
     char buffer[400], buffer2[400];
     int32_t i;
-    for(i=0; i<LENGTHOF(testCases); ++i) {
+    for(i=0; i<uprv_lengthof(testCases); ++i) {
         const TestCase &testCase=testCases[i];
         UnicodeString input(ctou(testCase.s));
         UnicodeString expected(ctou(testCase.u));
@@ -612,7 +611,7 @@ void UTS46Test::TestSomeCases() {
                 continue;
             }
             if(uN!=expected) {
-                prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+                prettify(uN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
                 errln("N.nameToUnicode([%d] %s) unexpected string %s",
                       (int)i, testCase.s, buffer);
                 continue;
@@ -630,7 +629,7 @@ void UTS46Test::TestSomeCases() {
                 continue;
             }
             if(uT!=expected) {
-                prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+                prettify(uT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
                 errln("T.nameToUnicode([%d] %s) unexpected string %s",
                       (int)i, testCase.s, buffer);
                 continue;
@@ -643,24 +642,24 @@ void UTS46Test::TestSomeCases() {
         }
         // ToASCII is all-ASCII if no severe errors
         if((aNInfo.getErrors()&severeErrors)==0 && !isASCII(aN)) {
-            prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+            prettify(aN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
             errln("N.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s",
                   (int)i, testCase.s, aNInfo.getErrors(), buffer);
             continue;
         }
         if((aTInfo.getErrors()&severeErrors)==0 && !isASCII(aT)) {
-            prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+            prettify(aT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
             errln("T.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s",
                   (int)i, testCase.s, aTInfo.getErrors(), buffer);
             continue;
         }
         if(verbose) {
             char m= mode=='B' ? mode : 'N';
-            prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+            prettify(aN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
             logln("%c.nameToASCII([%d] %s) (errors %04lx) result string: %s",
                   m, (int)i, testCase.s, aNInfo.getErrors(), buffer);
             if(mode!='B') {
-                prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
+                prettify(aT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
                 logln("T.nameToASCII([%d] %s) (errors %04lx) result string: %s",
                       (int)i, testCase.s, aTInfo.getErrors(), buffer);
             }
@@ -678,32 +677,32 @@ void UTS46Test::TestSomeCases() {
             continue;
         }
         if(aN!=uNaN) {
-            prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-            prettify(uNaN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+            prettify(aN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+            prettify(uNaN).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
             errln("N.nameToASCII([%d] %s)!=N.nameToUnicode().N.nameToASCII() "
                   "(errors %04lx) %s vs. %s",
                   (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2);
             continue;
         }
         if(aT!=uTaN) {
-            prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-            prettify(uTaN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+            prettify(aT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+            prettify(uTaN).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
             errln("T.nameToASCII([%d] %s)!=T.nameToUnicode().N.nameToASCII() "
                   "(errors %04lx) %s vs. %s",
                   (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2);
             continue;
         }
         if(uN!=aNuN) {
-            prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-            prettify(aNuN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+            prettify(uN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+            prettify(aNuN).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
             errln("N.nameToUnicode([%d] %s)!=N.nameToASCII().N.nameToUnicode() "
                   "(errors %04lx) %s vs. %s",
                   (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2);
             continue;
         }
         if(uT!=aTuN) {
-            prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-            prettify(aTuN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+            prettify(uT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+            prettify(aTuN).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
             errln("T.nameToUnicode([%d] %s)!=T.nameToASCII().N.nameToUnicode() "
                   "(errors %04lx) %s vs. %s",
                   (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2);
@@ -723,8 +722,8 @@ void UTS46Test::TestSomeCases() {
         }
         if(aN.indexOf((UChar)0x2e)<0) {
             if(aN!=aNL || aNInfo.getErrors()!=aNLInfo.getErrors()) {
-                prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-                prettify(aNL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+                prettify(aN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+                prettify(aNL).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
                 errln("N.nameToASCII([%d] %s)!=N.labelToASCII() "
                       "(errors %04lx vs %04lx) %s vs. %s",
                       (int)i, testCase.s, aNInfo.getErrors(), aNLInfo.getErrors(), buffer, buffer2);
@@ -739,8 +738,8 @@ void UTS46Test::TestSomeCases() {
         }
         if(aT.indexOf((UChar)0x2e)<0) {
             if(aT!=aTL || aTInfo.getErrors()!=aTLInfo.getErrors()) {
-                prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-                prettify(aTL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+                prettify(aT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+                prettify(aTL).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
                 errln("T.nameToASCII([%d] %s)!=T.labelToASCII() "
                       "(errors %04lx vs %04lx) %s vs. %s",
                       (int)i, testCase.s, aTInfo.getErrors(), aTLInfo.getErrors(), buffer, buffer2);
@@ -755,8 +754,8 @@ void UTS46Test::TestSomeCases() {
         }
         if(uN.indexOf((UChar)0x2e)<0) {
             if(uN!=uNL || uNInfo.getErrors()!=uNLInfo.getErrors()) {
-                prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-                prettify(uNL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+                prettify(uN).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+                prettify(uNL).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
                 errln("N.nameToUnicode([%d] %s)!=N.labelToUnicode() "
                       "(errors %04lx vs %04lx) %s vs. %s",
                       (int)i, testCase.s, uNInfo.getErrors(), uNLInfo.getErrors(), buffer, buffer2);
@@ -771,8 +770,8 @@ void UTS46Test::TestSomeCases() {
         }
         if(uT.indexOf((UChar)0x2e)<0) {
             if(uT!=uTL || uTInfo.getErrors()!=uTLInfo.getErrors()) {
-                prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
-                prettify(uTL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
+                prettify(uT).extract(0, 0x7fffffff, buffer, uprv_lengthof(buffer));
+                prettify(uTL).extract(0, 0x7fffffff, buffer2, uprv_lengthof(buffer2));
                 errln("T.nameToUnicode([%d] %s)!=T.labelToUnicode() "
                       "(errors %04lx vs %04lx) %s vs. %s",
                       (int)i, testCase.s, uTInfo.getErrors(), uTLInfo.getErrors(), buffer, buffer2);
index dabbef7f6ef24f14e6abec13700c4f39cfeb3aab..73410c51e1511e23644d5bb9fa285a904534c436 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (c) 2002-2005, International Business Machines
+* Copyright (c) 2002-2014, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 **********************************************************************
@@ -139,7 +139,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_OpenAllConverters() {
 
 UPerfFunction* ConverterPerformanceTest::TestICU_UTF8_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("utf-8",utf8_uniSource, LENGTHOF(utf8_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("utf-8",utf8_uniSource, uprv_lengthof(utf8_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -148,7 +148,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_UTF8_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_UTF8_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("utf-8",(char*)utf8_encSource, LENGTHOF(utf8_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("utf-8",(char*)utf8_encSource, uprv_lengthof(utf8_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -158,7 +158,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_UTF8_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_UTF8_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("utf-8",utf8_uniSource, LENGTHOF(utf8_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("utf-8",utf8_uniSource, uprv_lengthof(utf8_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -167,7 +167,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_UTF8_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_UTF8_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("utf-8",(char*)utf8_encSource, LENGTHOF(utf8_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("utf-8",(char*)utf8_encSource, uprv_lengthof(utf8_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -176,7 +176,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_UTF8_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_UTF8_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("utf-8",utf8_uniSource, LENGTHOF(utf8_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("utf-8",utf8_uniSource, uprv_lengthof(utf8_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -185,7 +185,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_UTF8_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_UTF8_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("utf-8",(char*)utf8_encSource, LENGTHOF(utf8_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("utf-8",(char*)utf8_encSource, uprv_lengthof(utf8_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -196,7 +196,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_UTF8_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_Latin1_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-1",latin1_uniSource, LENGTHOF(latin1_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-1",latin1_uniSource, uprv_lengthof(latin1_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -205,7 +205,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_Latin1_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_Latin1_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-8859-1",(char*)latin1_encSource, LENGTHOF(latin1_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-8859-1",(char*)latin1_encSource, uprv_lengthof(latin1_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -215,7 +215,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_Latin1_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_Latin1_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-8859-1",latin1_uniSource, LENGTHOF(latin1_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-8859-1",latin1_uniSource, uprv_lengthof(latin1_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -224,7 +224,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_Latin1_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_Latin1_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-8859-1",(char*)latin1_encSource, LENGTHOF(latin1_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-8859-1",(char*)latin1_encSource, uprv_lengthof(latin1_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -233,7 +233,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_Latin1_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_Latin1_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-8859-1",latin1_uniSource, LENGTHOF(latin1_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-8859-1",latin1_uniSource, uprv_lengthof(latin1_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -242,7 +242,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_Latin1_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_Latin1_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-8859-1",(char*)latin1_encSource, LENGTHOF(latin1_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-8859-1",(char*)latin1_encSource, uprv_lengthof(latin1_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -253,7 +253,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_Latin1_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_Latin8_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-8",latin8_uniSource, LENGTHOF(latin8_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-8859-8",latin8_uniSource, uprv_lengthof(latin8_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -262,7 +262,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_Latin8_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_Latin8_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-8859-8",(char*)latin8_encSource, LENGTHOF(latin8_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-8859-8",(char*)latin8_encSource, uprv_lengthof(latin8_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -272,7 +272,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_Latin8_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_Latin8_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-8859-8",latin8_uniSource, LENGTHOF(latin8_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-8859-8",latin8_uniSource, uprv_lengthof(latin8_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -281,7 +281,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_Latin8_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_Latin8_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-8859-8",(char*)latin8_encSource, LENGTHOF(latin8_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-8859-8",(char*)latin8_encSource, uprv_lengthof(latin8_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -289,7 +289,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_Latin8_ToUnicode(){
 }
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_Latin8_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-8859-8",latin8_uniSource, LENGTHOF(latin8_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-8859-8",latin8_uniSource, uprv_lengthof(latin8_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -298,7 +298,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_Latin8_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_Latin8_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-8859-8",(char*)latin8_encSource, LENGTHOF(latin8_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-8859-8",(char*)latin8_encSource, uprv_lengthof(latin8_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -310,7 +310,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_Latin8_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_EBCDIC_Arabic_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("x-EBCDIC-Arabic",ebcdic_arabic_uniSource, LENGTHOF(ebcdic_arabic_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("x-EBCDIC-Arabic",ebcdic_arabic_uniSource, uprv_lengthof(ebcdic_arabic_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -319,7 +319,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_EBCDIC_Arabic_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_EBCDIC_Arabic_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("x-EBCDIC-Arabic",(char*)ebcdic_arabic_encSource, LENGTHOF(ebcdic_arabic_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("x-EBCDIC-Arabic",(char*)ebcdic_arabic_encSource, uprv_lengthof(ebcdic_arabic_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -329,7 +329,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_EBCDIC_Arabic_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_EBCDIC_Arabic_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("x-EBCDIC-Arabic",ebcdic_arabic_uniSource, LENGTHOF(ebcdic_arabic_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("x-EBCDIC-Arabic",ebcdic_arabic_uniSource, uprv_lengthof(ebcdic_arabic_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -338,7 +338,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_EBCDIC_Arabic_FromUnicode()
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_EBCDIC_Arabic_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("x-EBCDIC-Arabic",(char*)ebcdic_arabic_encSource, LENGTHOF(ebcdic_arabic_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("x-EBCDIC-Arabic",(char*)ebcdic_arabic_encSource, uprv_lengthof(ebcdic_arabic_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -347,7 +347,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_EBCDIC_Arabic_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_EBCDIC_Arabic_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("x-EBCDIC-Arabic",ebcdic_arabic_uniSource, LENGTHOF(ebcdic_arabic_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("x-EBCDIC-Arabic",ebcdic_arabic_uniSource, uprv_lengthof(ebcdic_arabic_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -356,7 +356,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_EBCDIC_Arabic_FromUnicode()
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_EBCDIC_Arabic_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("x-EBCDIC-Arabic",(char*)ebcdic_arabic_encSource, LENGTHOF(ebcdic_arabic_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("x-EBCDIC-Arabic",(char*)ebcdic_arabic_encSource, uprv_lengthof(ebcdic_arabic_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -367,7 +367,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_EBCDIC_Arabic_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_SJIS_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("sjis",sjis_uniSource, LENGTHOF(sjis_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("sjis",sjis_uniSource, uprv_lengthof(sjis_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -376,7 +376,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_SJIS_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_SJIS_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("sjis",(char*)sjis_encSource, LENGTHOF(sjis_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("sjis",(char*)sjis_encSource, uprv_lengthof(sjis_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -386,7 +386,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_SJIS_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_SJIS_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("sjis",sjis_uniSource, LENGTHOF(sjis_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("sjis",sjis_uniSource, uprv_lengthof(sjis_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -395,7 +395,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_SJIS_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_SJIS_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("sjis",(char*)sjis_encSource, LENGTHOF(sjis_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("sjis",(char*)sjis_encSource, uprv_lengthof(sjis_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -404,7 +404,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_SJIS_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_SJIS_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("sjis",sjis_uniSource, LENGTHOF(sjis_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("sjis",sjis_uniSource, uprv_lengthof(sjis_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -413,7 +413,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_SJIS_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_SJIS_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("sjis",(char*)sjis_encSource, LENGTHOF(sjis_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("sjis",(char*)sjis_encSource, uprv_lengthof(sjis_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -426,7 +426,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_SJIS_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_EUCJP_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("euc-jp",eucjp_uniSource, LENGTHOF(eucjp_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("euc-jp",eucjp_uniSource, uprv_lengthof(eucjp_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -435,7 +435,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_EUCJP_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_EUCJP_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("euc-jp",(char*)eucjp_encSource, LENGTHOF(eucjp_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("euc-jp",(char*)eucjp_encSource, uprv_lengthof(eucjp_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -445,7 +445,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_EUCJP_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_EUCJP_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("euc-jp",eucjp_uniSource, LENGTHOF(eucjp_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("euc-jp",eucjp_uniSource, uprv_lengthof(eucjp_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -454,7 +454,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_EUCJP_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_EUCJP_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("euc-jp",(char*)eucjp_encSource, LENGTHOF(eucjp_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("euc-jp",(char*)eucjp_encSource, uprv_lengthof(eucjp_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -463,7 +463,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_EUCJP_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_EUCJP_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("euc-jp",eucjp_uniSource, LENGTHOF(eucjp_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("euc-jp",eucjp_uniSource, uprv_lengthof(eucjp_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -472,7 +472,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_EUCJP_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_EUCJP_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("euc-jp",(char*)eucjp_encSource, LENGTHOF(eucjp_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("euc-jp",(char*)eucjp_encSource, uprv_lengthof(eucjp_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -485,7 +485,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_EUCJP_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_GB2312_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("gb2312",gb2312_uniSource, LENGTHOF(gb2312_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("gb2312",gb2312_uniSource, uprv_lengthof(gb2312_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -494,7 +494,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_GB2312_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_GB2312_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("gb2312",(char*)gb2312_encSource, LENGTHOF(gb2312_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("gb2312",(char*)gb2312_encSource, uprv_lengthof(gb2312_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -504,7 +504,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_GB2312_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_GB2312_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("gb2312",gb2312_uniSource, LENGTHOF(gb2312_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("gb2312",gb2312_uniSource, uprv_lengthof(gb2312_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -513,7 +513,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_GB2312_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_GB2312_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("gb2312",(char*)gb2312_encSource, LENGTHOF(gb2312_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("gb2312",(char*)gb2312_encSource, uprv_lengthof(gb2312_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -522,7 +522,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_GB2312_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_GB2312_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("gb2312",gb2312_uniSource, LENGTHOF(gb2312_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("gb2312",gb2312_uniSource, uprv_lengthof(gb2312_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -531,7 +531,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_GB2312_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_GB2312_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("gb2312",(char*)gb2312_encSource, LENGTHOF(gb2312_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("gb2312",(char*)gb2312_encSource, uprv_lengthof(gb2312_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -543,7 +543,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_GB2312_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_ISO2022KR_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-kr",iso2022kr_uniSource, LENGTHOF(iso2022kr_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-kr",iso2022kr_uniSource, uprv_lengthof(iso2022kr_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -552,7 +552,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_ISO2022KR_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_ISO2022KR_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-2022-kr",(char*)iso2022kr_encSource, LENGTHOF(iso2022kr_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-2022-kr",(char*)iso2022kr_encSource, uprv_lengthof(iso2022kr_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -562,7 +562,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_ISO2022KR_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_ISO2022KR_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-2022-kr",iso2022kr_uniSource, LENGTHOF(iso2022kr_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-2022-kr",iso2022kr_uniSource, uprv_lengthof(iso2022kr_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -571,7 +571,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_ISO2022KR_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_ISO2022KR_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-2022-kr",(char*)iso2022kr_encSource, LENGTHOF(iso2022kr_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-2022-kr",(char*)iso2022kr_encSource, uprv_lengthof(iso2022kr_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -580,7 +580,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_ISO2022KR_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_ISO2022KR_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-2022-kr",iso2022kr_uniSource, LENGTHOF(iso2022kr_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-2022-kr",iso2022kr_uniSource, uprv_lengthof(iso2022kr_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -589,7 +589,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_ISO2022KR_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_ISO2022KR_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-2022-kr",(char*)iso2022kr_encSource, LENGTHOF(iso2022kr_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-2022-kr",(char*)iso2022kr_encSource, uprv_lengthof(iso2022kr_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -600,7 +600,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinANSI_ISO2022KR_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestICU_ISO2022JP_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-jp",iso2022jp_uniSource, LENGTHOF(iso2022jp_uniSource), status);
+    ICUFromUnicodePerfFunction* pf = new ICUFromUnicodePerfFunction("iso-2022-jp",iso2022jp_uniSource, uprv_lengthof(iso2022jp_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -609,7 +609,7 @@ UPerfFunction* ConverterPerformanceTest::TestICU_ISO2022JP_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestICU_ISO2022JP_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-2022-jp",(char*)iso2022jp_encSource, LENGTHOF(iso2022jp_encSource), status);
+    UPerfFunction* pf = new ICUToUnicodePerfFunction("iso-2022-jp",(char*)iso2022jp_encSource, uprv_lengthof(iso2022jp_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -619,7 +619,7 @@ UPerfFunction*  ConverterPerformanceTest::TestICU_ISO2022JP_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinIML2_ISO2022JP_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-2022-jp",iso2022jp_uniSource, LENGTHOF(iso2022jp_uniSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2FromUnicodePerfFunction("iso-2022-jp",iso2022jp_uniSource, uprv_lengthof(iso2022jp_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -628,7 +628,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinIML2_ISO2022JP_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinIML2_ISO2022JP_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-2022-jp",(char*)iso2022jp_encSource, LENGTHOF(iso2022jp_encSource), status);
+    UPerfFunction* pf = new WinIMultiLanguage2ToUnicodePerfFunction("iso-2022-jp",(char*)iso2022jp_encSource, uprv_lengthof(iso2022jp_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -637,7 +637,7 @@ UPerfFunction*  ConverterPerformanceTest::TestWinIML2_ISO2022JP_ToUnicode(){
 
 UPerfFunction* ConverterPerformanceTest::TestWinANSI_ISO2022JP_FromUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-2022-jp",iso2022jp_uniSource, LENGTHOF(iso2022jp_uniSource), status);
+    UPerfFunction* pf = new WinANSIFromUnicodePerfFunction("iso-2022-jp",iso2022jp_uniSource, uprv_lengthof(iso2022jp_uniSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
@@ -646,7 +646,7 @@ UPerfFunction* ConverterPerformanceTest::TestWinANSI_ISO2022JP_FromUnicode(){
 
 UPerfFunction*  ConverterPerformanceTest::TestWinANSI_ISO2022JP_ToUnicode(){
     UErrorCode status = U_ZERO_ERROR;
-    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-2022-jp",(char*)iso2022jp_encSource, LENGTHOF(iso2022jp_encSource), status);
+    UPerfFunction* pf = new WinANSIToUnicodePerfFunction("iso-2022-jp",(char*)iso2022jp_encSource, uprv_lengthof(iso2022jp_encSource), status);
     if(U_FAILURE(status)){
         return NULL;
     }
index 994553aa52d829259c7547996a8599957d63f224..a64972f05069f4bf37f1eb9db7940ce04d710b83 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (c) 2002-2005, International Business Machines
+* Copyright (c) 2002-2014, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 **********************************************************************
@@ -19,7 +19,6 @@
 
 #define CONVERSION_FLAGS (0) /*WC_DEFAULTCHAR WC_COMPOSITECHECK & WC_SEPCHARS*/
 #define MAX_BUF_SIZE  3048
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
 
 class ICUToUnicodePerfFunction : public UPerfFunction{
 private:
@@ -159,7 +158,7 @@ public:
         name = cpName;
         src = pszIn;
         srcLen = szLen;
-        dstLen = LENGTHOF(dest);
+        dstLen = uprv_lengthof(dest);
         unsigned short bEnc[30]={'\0'};
         const char* tenc=name;
         for(int i=0;*tenc!='\0';i++){
@@ -213,7 +212,7 @@ public:
         name = cpName;
         src = pszIn;
         srcLen = szLen;
-        dstLen = LENGTHOF(dest);
+        dstLen = uprv_lengthof(dest);
         lpUsedDefaultChar=FALSE;
         unsigned short bEnc[30]={'\0'};
         const char* tenc=name;
@@ -308,7 +307,7 @@ public:
         getErr(err,status);
         src = source;
         srcLen = sourceLen;
-        dstLen = LENGTHOF(dst);
+        dstLen = uprv_lengthof(dst);
         cpName = name;
     }
 
@@ -364,7 +363,7 @@ public:
         getErr(err,status);
         src = source;
         srcLen = sourceLen;
-        dstLen = LENGTHOF(dst);
+        dstLen = uprv_lengthof(dst);
         cpName = name;
 
     }
@@ -404,7 +403,7 @@ public:
 
         src = source;
         srcLen = sourceLen;
-        dstLen = LENGTHOF(dst);
+        dstLen = uprv_lengthof(dst);
         cpName = name;
         unsigned short bEnc[30]={'\0'};
         const char* tenc=name;
@@ -465,7 +464,7 @@ public:
         }
         src = source;
         srcLen = sourceLen;
-        dstLen = LENGTHOF(dst);
+        dstLen = uprv_lengthof(dst);
         cpName = name;
         /* get the charset info */
         MIMECSETINFO mimeInfo;
index 3400e0e863d50656ba59bceb626a9d008157f4d8..bc2d42f72a6f91b4698e4b1d7bb6ba199da0e43d 100644 (file)
@@ -1,6 +1,6 @@
 /*  
  **********************************************************************
- *   Copyright (C) 2010-2012, International Business Machines
+ *   Copyright (C) 2010-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  **********************************************************************
  *  file name:  dicttrieperf.cpp
@@ -38,8 +38,6 @@
 #include "uoptions.h"
 #include "uvectr32.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // Test object.
 class DictionaryTriePerfTest : public UPerfTest {
 public:
@@ -449,7 +447,7 @@ public:
             utext_openUChars(&text, lines[i].name, lines[i].len, pErrorCode);
             int32_t count=0;
             ucharsTrieMatches(*trie, &text, lines[i].len,
-                              lengths, count, LENGTHOF(lengths));
+                              lengths, count, uprv_lengthof(lengths));
             if(count==0 || lengths[count-1]!=lines[i].len) {
                 fprintf(stderr, "word %ld (0-based) not found\n", (long)i);
             }
@@ -598,7 +596,7 @@ public:
             utext_openUChars(&text, lines[i].name, lines[i].len, pErrorCode);
             int32_t count=0;
             bytesTrieMatches(*trie, &text, lines[i].len,
-                             lengths, count, LENGTHOF(lengths));
+                             lengths, count, uprv_lengthof(lengths));
             if(count==0 || lengths[count-1]!=lines[i].len) {
                 fprintf(stderr, "word %ld (0-based) not found\n", (long)i);
             }
index 011bbcbd3ec71487620b4c607e969da94f938cc8..d3c3cf2b281ede7c5cc450319b47b7f4eeb7e493 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (c) 2002-2005, International Business Machines
+* Copyright (c) 2002-2014, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 **********************************************************************
@@ -15,8 +15,6 @@
 #include "uoptions.h"
 #include <stdio.h>
 
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
 UPerfFunction* NormalizerPerformanceTest::runIndexedTest(int32_t index, UBool exec,const char* &name, char* par) {
     switch (index) {
         TESTCASE(0,TestICU_NFC_NFD_Text);
@@ -132,7 +130,7 @@ NormalizerPerformanceTest::NormalizerPerformanceTest(int32_t argc, const char* a
         return;
     }
 
-    _remainingArgc = u_parseArgs(_remainingArgc, (char **)argv, (int32_t)(LENGTHOF(cmdLineOptions)), cmdLineOptions);
+    _remainingArgc = u_parseArgs(_remainingArgc, (char **)argv, (int32_t)(uprv_lengthof(cmdLineOptions)), cmdLineOptions);
     if(cmdLineOptions[0].doesOccur && cmdLineOptions[0].value!=NULL) {
         options=(int32_t)strtol(cmdLineOptions[0].value, NULL, 16);
     }
index 487d0c0985ff903bbe20ed3027eb21e6303c5272..6ea79e4103ed3b8f4c14c7abeaecdf1f53dde2af 100644 (file)
@@ -1,6 +1,6 @@
 /*  
 **********************************************************************
-*   Copyright (C) 2007, International Business Machines
+*   Copyright (C) 2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   file name:  bitset.cpp
@@ -146,7 +146,7 @@ public:
             prevIndex=j;
         }
 
-        if(bitHash->countKeys()>LENGTHOF(shortBits)) {
+        if(bitHash->countKeys()>uprv_lengthof(shortBits)) {
             bits=(int64_t *)uprv_malloc(bitHash->countKeys()*8);
         }
         if(bits!=NULL) {
index 36d61c1e193aef931a738abe5a5ef48153decffe..67b1b59441aa307f2ed2c20d82fd5fbfeb87e83f 100644 (file)
@@ -1,6 +1,6 @@
 /*  
 **********************************************************************
-*   Copyright (C) 2007, International Business Machines
+*   Copyright (C) 2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   file name:  unisetperf.cpp
@@ -20,8 +20,6 @@
 #include "unicode/unistr.h"
 #include "uoptions.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // Command-line options specific to unisetperf.
 // Options do not have abbreviations: Force readable command lines.
 // (Using U+0001 for abbreviation characters.)
@@ -46,7 +44,7 @@ static const char *const unisetperf_usage =
 class UnicodeSetPerformanceTest : public UPerfTest {
 public:
     UnicodeSetPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status)
-            : UPerfTest(argc, argv, options, LENGTHOF(options), unisetperf_usage, status),
+            : UPerfTest(argc, argv, options, uprv_lengthof(options), unisetperf_usage, status),
               utf8(NULL), utf8Length(0), countInputCodePoints(0), spanCount(0) {
         if (U_SUCCESS(status)) {
             UnicodeString pattern=UnicodeString(options[SET_PATTERN].value, -1, US_INV).unescape();
index e5e26ca49eae9564d8bcf7353553c9aeda6ed7a4..e62db57e437248961b682701a2532b24362d21f1 100644 (file)
@@ -1,6 +1,6 @@
 /*  
  **********************************************************************
- *   Copyright (C) 2002-2007, International Business Machines
+ *   Copyright (C) 2002-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  **********************************************************************
  *   file name:  utfperf.cpp
@@ -20,8 +20,6 @@
 #include "unicode/uperf.h"
 #include "uoptions.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* definitions and text buffers */
 
 #define INPUT_CAPACITY (1024*1024)
@@ -67,7 +65,7 @@ static const char *const utfperf_usage =
 class  UtfPerformanceTest : public UPerfTest{
 public:
     UtfPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status)
-            : UPerfTest(argc, argv, options, LENGTHOF(options), utfperf_usage, status) {
+            : UPerfTest(argc, argv, options, uprv_lengthof(options), utfperf_usage, status) {
         if (U_SUCCESS(status)) {
             charset = options[CHARSET].value;
 
index 18c386c7566317e3707b4cc4fb030c745b7c3e19..c92f6b1f816e26ae3b6fa318523930f469089b0e 100644 (file)
@@ -1,6 +1,6 @@
 /*  
  **********************************************************************
- *   Copyright (C) 2002-2008, International Business Machines
+ *   Copyright (C) 2002-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  **********************************************************************
  *  file name:  utrie2perf.cpp
@@ -21,8 +21,6 @@
 #include "unicode/uperf.h"
 #include "uoptions.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #if 0
 // Left over from when icu/branches/markus/utf8 could use both old UTrie
 // and new UTrie2, switched with #if in unorm.cpp and ubidi_props.c.
index 597300da24e1c2e770f729d15da6dbcc84928e0c..2633385adcf839bc870801d84d5153351ccecfa0 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2009-2012, International Business Machines
+*   Copyright (C) 2009-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -38,8 +38,6 @@
 #include "unewdata.h"
 #endif
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 UBool beVerbose=FALSE, haveCopyright=TRUE;
@@ -239,7 +237,7 @@ void parseFile(FILE *f, Normalizer2DataBuilder &builder) {
         }
         if(*delimiter=='=' || *delimiter=='>') {
             UChar uchars[Normalizer2Impl::MAPPING_LENGTH_MASK];
-            int32_t length=u_parseString(delimiter+1, uchars, LENGTHOF(uchars), NULL, errorCode);
+            int32_t length=u_parseString(delimiter+1, uchars, uprv_lengthof(uchars), NULL, errorCode);
             if(errorCode.isFailure()) {
                 fprintf(stderr, "gennorm2 error: parsing mapping string from %s\n", line);
                 exit(errorCode.reset());
index 843b1f703572f6075a8966e1c861090df77d8a33..187833c2de6d12e6f8ae1fb6fb7ffd5fa326678c 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2009-2012, International Business Machines
+*   Copyright (C) 2009-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -40,8 +40,6 @@
 #include "utrie2.h"
 #include "uvectr32.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #if !UCONFIG_NO_NORMALIZATION
 
 /* UDataInfo cf. udata.h */
@@ -70,7 +68,7 @@ public:
 
     HangulIterator() : rangeIndex(0) {}
     const Range *nextRange() {
-        if(rangeIndex<LENGTHOF(ranges)) {
+        if(rangeIndex<uprv_lengthof(ranges)) {
             return ranges+rangeIndex++;
         } else {
             return NULL;
index 5f64660c104d7754e51a781dab088ad478a1adbb..89f8a063c9dd3c9028ed53e8c53b0b2f4c04da5f 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2005-2013, International Business Machines
+*   Copyright (C) 2005-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -47,8 +47,6 @@ U_NAMESPACE_USE
 
 // general definitions ----------------------------------------------------- ***
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // main() ------------------------------------------------------------------ ***
 
 static void
@@ -266,7 +264,7 @@ main(int argc, char *argv[]) {
     /* get the program basename */
     pname=findBasename(argv[0]);
 
-    argc=u_parseArgs(argc, argv, LENGTHOF(options), options);
+    argc=u_parseArgs(argc, argv, uprv_lengthof(options), options);
     isHelp=options[OPT_HELP_H].doesOccur || options[OPT_HELP_QUESTION_MARK].doesOccur;
     if(isHelp) {
         printUsage(pname, TRUE);
index a5295df651f91d78ce574d01c473eb0542ee7a8a..b2b53947c15c8e2a847156fc2232b605baa0342f 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2003-2007, International Business Machines
+*   Copyright (C) 2003-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -41,7 +41,6 @@
 
 /* definitions */
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 #define DEFAULT_PADDING_LENGTH 15
 
 static UOption options[]={
@@ -130,7 +129,7 @@ main(int argc, char *argv[]) {
         pname=argv[0];
     }
 
-    argc=u_parseArgs(argc, argv, LENGTHOF(options), options);
+    argc=u_parseArgs(argc, argv, uprv_lengthof(options), options);
     ishelp=options[OPT_HELP_H].doesOccur || options[OPT_HELP_QUESTION_MARK].doesOccur;
     if(ishelp || argc!=3) {
         return printUsage(pname, ishelp);
index 10a0571c6b9e36e9b773b62f1322b8b7d07cdeca..88315a4917c5e42d788d0c43c3c9bfe9d3bd5ef8 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2003-2013, International Business Machines
+*   Copyright (C) 2003-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -27,9 +27,6 @@
 #include "makeconv.h"
 #include "genmbcs.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
-
 static void
 CnvExtClose(NewConverter *cnvData);
 
@@ -849,7 +846,7 @@ addFromUTrieEntry(CnvExtData *extData, UChar32 c, uint32_t value) {
 
         extData->stage1[i1]=(uint16_t)newBlock;
         extData->stage2Top=newBlock+MBCS_STAGE_2_BLOCK_SIZE;
-        if(extData->stage2Top>LENGTHOF(extData->stage2)) {
+        if(extData->stage2Top>uprv_lengthof(extData->stage2)) {
             fprintf(stderr, "error: too many stage 2 entries at U+%04x\n", (int)c);
             exit(U_MEMORY_ALLOCATION_ERROR);
         }
@@ -871,7 +868,7 @@ addFromUTrieEntry(CnvExtData *extData, UChar32 c, uint32_t value) {
         extData->stage2[i2]=(uint16_t)(newBlock>>UCNV_EXT_STAGE_2_LEFT_SHIFT);
 
         extData->stage3Top=newBlock+MBCS_STAGE_3_BLOCK_SIZE;
-        if(extData->stage3Top>LENGTHOF(extData->stage3)) {
+        if(extData->stage3Top>uprv_lengthof(extData->stage3)) {
             fprintf(stderr, "error: too many stage 3 entries at U+%04x\n", (int)c);
             exit(U_MEMORY_ALLOCATION_ERROR);
         }
@@ -915,7 +912,7 @@ addFromUTrieEntry(CnvExtData *extData, UChar32 c, uint32_t value) {
             }
         }
     } else {
-        if((i3b=extData->stage3bTop++)>=LENGTHOF(extData->stage3b)) {
+        if((i3b=extData->stage3bTop++)>=uprv_lengthof(extData->stage3b)) {
             fprintf(stderr, "error: too many stage 3b entries at U+%04x\n", (int)c);
             exit(U_MEMORY_ALLOCATION_ERROR);
         }
index 424c962251138ce7dc9de7cb865fe198d689f0d6..8a9a9ec6616c0fca7084aadfbbcdac9f99558463 100644 (file)
@@ -1,7 +1,7 @@
 /*
  ********************************************************************************
  *
- *   Copyright (C) 1998-2012, International Business Machines
+ *   Copyright (C) 1998-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  ********************************************************************************
@@ -34,8 +34,6 @@
 #include "makeconv.h"
 #include "genmbcs.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define DEBUG 0
 
 typedef struct ConvData {
@@ -213,7 +211,7 @@ int main(int argc, char* argv[])
 
     /* preset then read command line options */
     options[OPT_DESTDIR].value=u_getDataDirectory();
-    argc=u_parseArgs(argc, argv, LENGTHOF(options), options);
+    argc=u_parseArgs(argc, argv, uprv_lengthof(options), options);
 
     /* error handling, printing usage message */
     if(argc<0) {
index bd0ea80ebe5af03b53e827f27fba27aa314f471f..624c6e498d81e8a386695986122909f5ac5ee486 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1999-2013, International Business Machines
+*   Copyright (C) 1999-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -42,8 +42,6 @@ static const int32_t kItemsChunk = 256; /* How much to increase the filesarray b
 
 // general definitions ----------------------------------------------------- ***
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* UDataInfo cf. udata.h */
 static const UDataInfo dataInfo={
     (uint16_t)sizeof(UDataInfo),
@@ -594,7 +592,7 @@ Package::readPackage(const char *filename) {
                 exit(U_INVALID_FORMAT_ERROR);
             }
             prefixLength=(int32_t)(prefixLimit-s);
-            if(prefixLength==0 || prefixLength>=LENGTHOF(pkgPrefix)) {
+            if(prefixLength==0 || prefixLength>=uprv_lengthof(pkgPrefix)) {
                 fprintf(stderr,
                         "icupkg: --auto_toc_prefix[_with_type] but "
                         "the prefix of the first entry \"%s\" is empty or too long\n",
index e543220a05697ff1fafd077928539fff0ba4fe8d..c452e3db6bd5945d211d9d4b9224f454150d8981 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************
- *   Copyright (C) 2008-2013, International Business Machines
+ *   Copyright (C) 2008-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
  */
@@ -16,9 +16,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 // read a file list -------------------------------------------------------- ***
 
 U_NAMESPACE_USE
@@ -38,7 +35,7 @@ isListTextFile(const char *listname) {
     const char *listNameEnd=strchr(listname, 0);
     const char *suffix;
     int32_t i, length;
-    for(i=0; i<LENGTHOF(listFileSuffixes); ++i) {
+    for(i=0; i<uprv_lengthof(listFileSuffixes); ++i) {
         suffix=listFileSuffixes[i].suffix;
         length=listFileSuffixes[i].length;
         if((listNameEnd-listname)>length && 0==memcmp(listNameEnd-length, suffix, length)) {
index 4a5a72180e3832e46b9f48cf1e89316fd6107801..e48b6036bb842c1e6e75d8078f408113efdc7651 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2003-2011, International Business Machines
+*   Copyright (C) 2003-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -43,8 +43,6 @@
 
 // general definitions ----------------------------------------------------- ***
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_CDECL_BEGIN
 
 static void U_CALLCONV
index ae51ed132dfe11168292d3fbad27633294a69df4..23b0f99ad14b53270226397489615515bd84f014 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-*   Copyright (C) 2011-2013, International Business Machines
+*   Copyright (C) 2011-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  ppucd.cpp
@@ -23,8 +23,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 PropertyNames::~PropertyNames() {}
@@ -298,7 +296,7 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV
     int32_t prop=pnames->getPropertyEnum(p);
     if(prop<0) {
         for(int32_t i=0;; ++i) {
-            if(i==LENGTHOF(ppucdProperties)) {
+            if(i==uprv_lengthof(ppucdProperties)) {
                 // Ignore unknown property names.
                 return TRUE;
             }
index 59e20863a0bb78d8487ff9df35ca6df5690e5608..0f92e261aa3345d38ec2111619c223d817deaa96 100644 (file)
@@ -67,8 +67,6 @@ U_NAMESPACE_USE
 
 /* definitions */
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* Unicode property (value) aliases data swapping --------------------------- */
 
 static int32_t U_CALLCONV
@@ -792,7 +790,7 @@ udata_swap(const UDataSwapper *ds,
     }
 
     /* dispatch to the swap function for the dataFormat */
-    for(i=0; i<LENGTHOF(swapFns); ++i) {
+    for(i=0; i<uprv_lengthof(swapFns); ++i) {
         if(0==memcmp(swapFns[i].dataFormat, pInfo->dataFormat, 4)) {
             swappedLength=swapFns[i].swapFn(ds, inData, length, outData, pErrorCode);