]> granicus.if.org Git - icu/commitdiff
ICU-7653 change a few straggler LENGTHOFs
authorMarkus Scherer <markus.icu@gmail.com>
Thu, 28 Aug 2014 23:20:12 +0000 (23:20 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Thu, 28 Aug 2014 23:20:12 +0000 (23:20 +0000)
X-SVN-Rev: 36277

icu4c/source/common/loclikely.cpp
icu4c/source/common/ucnvmbcs.cpp
icu4c/source/test/cintltst/reapits.c
icu4c/source/test/intltest/numfmtspectest.cpp

index aa4a95b85c41a812f71a87b5611cb673417b7828..e5887081308262e8d1363f28e9f38fec5682d9af 100644 (file)
@@ -28,8 +28,6 @@
 #include "ulocimp.h"
 #include "ustr_imp.h"
 
-#define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /**
  * This function looks for the localeID in the likelySubtags resource.
  *
index a3706feaf3be9221575b273cfb3c475c97025c2f..f03f8a88c077ef83b8aa325108dab43a850cf4b3 100644 (file)
@@ -58,8 +58,6 @@
 #include "cstring.h"
 #include "umutex.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 /* control optimizations according to the platform */
 #define MBCS_UNROLL_SINGLE_TO_BMP 1
 #define MBCS_UNROLL_SINGLE_FROM_BMP 0
@@ -1126,7 +1124,7 @@ _extFromU(UConverter *cnv, const UConverterSharedData *sharedData,
         int32_t i;
 
         range=gb18030Ranges[0];
-        for(i=0; i<LENGTHOF(gb18030Ranges); range+=4, ++i) {
+        for(i=0; i<UPRV_LENGTHOF(gb18030Ranges); range+=4, ++i) {
             if(range[0]<=(uint32_t)cp && (uint32_t)cp<=range[1]) {
                 /* found the Unicode code point, output the four-byte sequence for it */
                 uint32_t linear;
@@ -1193,7 +1191,7 @@ _extToU(UConverter *cnv, const UConverterSharedData *sharedData,
 
         linear=LINEAR_18030(cnv->toUBytes[0], cnv->toUBytes[1], cnv->toUBytes[2], cnv->toUBytes[3]);
         range=gb18030Ranges[0];
-        for(i=0; i<LENGTHOF(gb18030Ranges); range+=4, ++i) {
+        for(i=0; i<UPRV_LENGTHOF(gb18030Ranges); range+=4, ++i) {
             if(range[2]<=linear && linear<=range[3]) {
                 /* found the sequence, output the Unicode code point for it */
                 *pErrorCode=U_ZERO_ERROR;
index 33897f3000878189dd1ab181cc459fc98d692f11..61751c51c6132214836b3738aa5b6ca88234182e 100644 (file)
@@ -28,8 +28,7 @@
 #include "unicode/ustring.h"
 #include "unicode/utext.h"
 #include "cintltst.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "cmemory.h"
 
 #define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
 log_data_err("Failure at file %s:%d - error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));}}
@@ -208,7 +207,7 @@ static void TestRegexCAPI(void) {
     memset(&minus1, -1, sizeof(minus1));
 
     /* Mimimalist open/close */
-    u_uastrncpy(pat, "abc*", LENGTHOF(pat));
+    u_uastrncpy(pat, "abc*", UPRV_LENGTHOF(pat));
     re = uregex_open(pat, -1, 0, 0, &status);
     if (U_FAILURE(status)) {
          log_data_err("Failed to open regular expression, %s:%d, error is \"%s\" (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));
@@ -260,7 +259,7 @@ static void TestRegexCAPI(void) {
 
         /* The TEST_ASSERT_SUCCESS above should change too... */
         if(U_SUCCESS(status)) {
-            u_uastrncpy(pat, "abc*", LENGTHOF(pat));
+            u_uastrncpy(pat, "abc*", UPRV_LENGTHOF(pat));
             TEST_ASSERT(u_strcmp(pat, p) == 0);
             TEST_ASSERT(len==(int32_t)strlen("abc*"));
         }
@@ -300,8 +299,8 @@ static void TestRegexCAPI(void) {
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT(clone3 != NULL);
 
-        u_uastrncpy(testString1, "abcccd", LENGTHOF(pat));
-        u_uastrncpy(testString2, "xxxabcccd", LENGTHOF(pat));
+        u_uastrncpy(testString1, "abcccd", UPRV_LENGTHOF(pat));
+        u_uastrncpy(testString2, "xxxabcccd", UPRV_LENGTHOF(pat));
 
         status = U_ZERO_ERROR;
         uregex_setText(clone1, testString1, -1, &status);
@@ -332,7 +331,7 @@ static void TestRegexCAPI(void) {
     {
         const UChar  *resultPat;
         int32_t       resultLen;
-        u_uastrncpy(pat, "hello", LENGTHOF(pat));
+        u_uastrncpy(pat, "hello", UPRV_LENGTHOF(pat));
         status = U_ZERO_ERROR;
         re = uregex_open(pat, -1, 0, NULL, &status);
         resultPat = uregex_pattern(re, &resultLen, &status);
@@ -398,10 +397,10 @@ static void TestRegexCAPI(void) {
         UChar  text2[50];
         UBool  result;
 
-        u_uastrncpy(text1, "abcccd",  LENGTHOF(text1));
-        u_uastrncpy(text2, "abcccxd", LENGTHOF(text2));
+        u_uastrncpy(text1, "abcccd",  UPRV_LENGTHOF(text1));
+        u_uastrncpy(text2, "abcccxd", UPRV_LENGTHOF(text2));
         status = U_ZERO_ERROR;
-        u_uastrncpy(pat, "abc*d", LENGTHOF(pat));
+        u_uastrncpy(pat, "abc*d", UPRV_LENGTHOF(pat));
         re = uregex_open(pat, -1, 0, NULL, &status);
         TEST_ASSERT_SUCCESS(status);
 
@@ -453,10 +452,10 @@ static void TestRegexCAPI(void) {
         const UChar   *result;
         int32_t  textLength;
 
-        u_uastrncpy(text1, "abcccd",  LENGTHOF(text1));
-        u_uastrncpy(text2, "abcccxd", LENGTHOF(text2));
+        u_uastrncpy(text1, "abcccd",  UPRV_LENGTHOF(text1));
+        u_uastrncpy(text2, "abcccxd", UPRV_LENGTHOF(text2));
         status = U_ZERO_ERROR;
-        u_uastrncpy(pat, "abc*d", LENGTHOF(pat));
+        u_uastrncpy(pat, "abc*d", UPRV_LENGTHOF(pat));
         re = uregex_open(pat, -1, 0, NULL, &status);
 
         uregex_setText(re, text1, -1, &status);
@@ -490,9 +489,9 @@ static void TestRegexCAPI(void) {
         int     len;
         UChar   nullString[] = {0,0,0};
 
-        u_uastrncpy(text1, "abcccde",  LENGTHOF(text1));
+        u_uastrncpy(text1, "abcccde",  UPRV_LENGTHOF(text1));
         status = U_ZERO_ERROR;
-        u_uastrncpy(pat, "abc*d", LENGTHOF(pat));
+        u_uastrncpy(pat, "abc*d", UPRV_LENGTHOF(pat));
         re = uregex_open(pat, -1, 0, NULL, &status);
 
         uregex_setText(re, text1, -1, &status);
@@ -542,7 +541,7 @@ static void TestRegexCAPI(void) {
     {
         UChar    text1[50];
         UBool    result;
-        u_uastrncpy(text1, "012rx5rx890rxrx...",  LENGTHOF(text1));
+        u_uastrncpy(text1, "012rx5rx890rxrx...",  UPRV_LENGTHOF(text1));
         status = U_ZERO_ERROR;
         re = uregex_openC("rx", 0, NULL, &status);
 
@@ -625,7 +624,7 @@ static void TestRegexCAPI(void) {
         UChar    buf[80];
         UBool    result;
         int32_t  resultSz;
-        u_uastrncpy(text1, "noise abc interior def, and this is off the end",  LENGTHOF(text1));
+        u_uastrncpy(text1, "noise abc interior def, and this is off the end",  UPRV_LENGTHOF(text1));
 
         status = U_ZERO_ERROR;
         re = uregex_openC("abc(.*?)def", 0, NULL, &status);
@@ -638,21 +637,21 @@ static void TestRegexCAPI(void) {
 
         /*  Capture Group 0, the full match.  Should succeed.  */
         status = U_ZERO_ERROR;
-        resultSz = uregex_group(re, 0, buf, LENGTHOF(buf), &status);
+        resultSz = uregex_group(re, 0, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("abc interior def", buf, TRUE);
         TEST_ASSERT(resultSz == (int32_t)strlen("abc interior def"));
 
         /*  Capture group #1.  Should succeed. */
         status = U_ZERO_ERROR;
-        resultSz = uregex_group(re, 1, buf, LENGTHOF(buf), &status);
+        resultSz = uregex_group(re, 1, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING(" interior ", buf, TRUE);
         TEST_ASSERT(resultSz == (int32_t)strlen(" interior "));
 
         /*  Capture group out of range.  Error. */
         status = U_ZERO_ERROR;
-        uregex_group(re, 2, buf, LENGTHOF(buf), &status);
+        uregex_group(re, 2, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT(status == U_INDEX_OUTOFBOUNDS_ERROR);
 
         /* NULL buffer, pure pre-flight */
@@ -696,7 +695,7 @@ static void TestRegexCAPI(void) {
         TEST_ASSERT(uregex_regionStart(re, &status) == 3);
         TEST_ASSERT(uregex_regionEnd(re, &status) == 6);
         TEST_ASSERT(uregex_findNext(re, &status));
-        TEST_ASSERT(uregex_group(re, 0, resultString, LENGTHOF(resultString), &status) == 3)
+        TEST_ASSERT(uregex_group(re, 0, resultString, UPRV_LENGTHOF(resultString), &status) == 3)
         TEST_ASSERT_STRING("345", resultString, TRUE);
         TEST_TEARDOWN;
         
@@ -820,9 +819,9 @@ static void TestRegexCAPI(void) {
         UChar    replText[80];
         UChar    buf[80];
         int32_t  resultSz;
-        u_uastrncpy(text1, "Replace xaax x1x x...x.",  LENGTHOF(text1));
-        u_uastrncpy(text2, "No match here.",  LENGTHOF(text2));
-        u_uastrncpy(replText, "<$1>", LENGTHOF(replText));
+        u_uastrncpy(text1, "Replace xaax x1x x...x.",  UPRV_LENGTHOF(text1));
+        u_uastrncpy(text2, "No match here.",  UPRV_LENGTHOF(text2));
+        u_uastrncpy(replText, "<$1>", UPRV_LENGTHOF(replText));
 
         status = U_ZERO_ERROR;
         re = uregex_openC("x(.*?)x", 0, NULL, &status);
@@ -830,7 +829,7 @@ static void TestRegexCAPI(void) {
 
         /*  Normal case, with match */
         uregex_setText(re, text1, -1, &status);
-        resultSz = uregex_replaceFirst(re, replText, -1, buf, LENGTHOF(buf), &status);
+        resultSz = uregex_replaceFirst(re, replText, -1, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("Replace <aa> x1x x...x.", buf, TRUE);
         TEST_ASSERT(resultSz == (int32_t)strlen("Replace xaax x1x x...x."));
@@ -838,7 +837,7 @@ static void TestRegexCAPI(void) {
         /* No match.  Text should copy to output with no changes.  */
         status = U_ZERO_ERROR;
         uregex_setText(re, text2, -1, &status);
-        resultSz = uregex_replaceFirst(re, replText, -1, buf, LENGTHOF(buf), &status);
+        resultSz = uregex_replaceFirst(re, replText, -1, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("No match here.", buf, TRUE);
         TEST_ASSERT(resultSz == (int32_t)strlen("No match here."));
@@ -900,10 +899,10 @@ static void TestRegexCAPI(void) {
         int32_t  expectedResultSize2;
         int32_t  i;
 
-        u_uastrncpy(text1, "Replace xaax x1x x...x.",  LENGTHOF(text1));
-        u_uastrncpy(text2, "No match here.",  LENGTHOF(text2));
-        u_uastrncpy(replText, "<$1>", LENGTHOF(replText));
-        u_uastrncpy(replText2, "<<$1>>", LENGTHOF(replText2));
+        u_uastrncpy(text1, "Replace xaax x1x x...x.",  UPRV_LENGTHOF(text1));
+        u_uastrncpy(text2, "No match here.",  UPRV_LENGTHOF(text2));
+        u_uastrncpy(replText, "<$1>", UPRV_LENGTHOF(replText));
+        u_uastrncpy(replText2, "<<$1>>", UPRV_LENGTHOF(replText2));
         expectedResultSize = strlen(expectedResult);
         expectedResultSize2 = strlen(expectedResult2);
 
@@ -913,7 +912,7 @@ static void TestRegexCAPI(void) {
 
         /*  Normal case, with match */
         uregex_setText(re, text1, -1, &status);
-        resultSize = uregex_replaceAll(re, replText, -1, buf, LENGTHOF(buf), &status);
+        resultSize = uregex_replaceAll(re, replText, -1, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING(expectedResult, buf, TRUE);
         TEST_ASSERT(resultSize == expectedResultSize);
@@ -921,7 +920,7 @@ static void TestRegexCAPI(void) {
         /* No match.  Text should copy to output with no changes.  */
         status = U_ZERO_ERROR;
         uregex_setText(re, text2, -1, &status);
-        resultSize = uregex_replaceAll(re, replText, -1, buf, LENGTHOF(buf), &status);
+        resultSize = uregex_replaceAll(re, replText, -1, buf, UPRV_LENGTHOF(buf), &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("No match here.", buf, TRUE);
         TEST_ASSERT(resultSize == u_strlen(text2));
@@ -1005,15 +1004,15 @@ static void TestRegexCAPI(void) {
         re = uregex_openC(".*", 0, 0, &status);
         TEST_ASSERT_SUCCESS(status);
 
-        u_uastrncpy(text, "whatever",  LENGTHOF(text));
-        u_uastrncpy(repl, "some other", LENGTHOF(repl));
+        u_uastrncpy(text, "whatever",  UPRV_LENGTHOF(text));
+        u_uastrncpy(repl, "some other", UPRV_LENGTHOF(repl));
         uregex_setText(re, text, -1, &status);
 
         /* match covers whole target string */
         uregex_find(re, 0, &status);
         TEST_ASSERT_SUCCESS(status);
         bufPtr = buf;
-        bufCap = LENGTHOF(buf);
+        bufCap = UPRV_LENGTHOF(buf);
         uregex_appendReplacement(re, repl, -1, &bufPtr, &bufCap, &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("some other", buf, TRUE);
@@ -1022,8 +1021,8 @@ static void TestRegexCAPI(void) {
         uregex_find(re, 0, &status);
         TEST_ASSERT_SUCCESS(status);
         bufPtr = buf;
-        bufCap = LENGTHOF(buf);
-        u_uastrncpy(repl, "abc\\u0041\\U00000042 \\\\ $ \\abc", LENGTHOF(repl));
+        bufCap = UPRV_LENGTHOF(buf);
+        u_uastrncpy(repl, "abc\\u0041\\U00000042 \\\\ $ \\abc", UPRV_LENGTHOF(repl));
         uregex_appendReplacement(re, repl, -1, &bufPtr, &bufCap, &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("abcAB \\ $ abc", buf, TRUE); 
@@ -1058,8 +1057,8 @@ static void TestRegexCAPI(void) {
         int32_t  spaceNeeded;
         int32_t  sz;
 
-        u_uastrncpy(textToSplit, "first : second:  third",  LENGTHOF(textToSplit));
-        u_uastrncpy(text2, "No match here.",  LENGTHOF(text2));
+        u_uastrncpy(textToSplit, "first : second:  third",  UPRV_LENGTHOF(textToSplit));
+        u_uastrncpy(text2, "No match here.",  UPRV_LENGTHOF(text2));
 
         status = U_ZERO_ERROR;
         re = uregex_openC(":", 0, NULL, &status);
@@ -1074,7 +1073,7 @@ static void TestRegexCAPI(void) {
         if (U_SUCCESS(status)) {
             memset(fields, -1, sizeof(fields));
             numFields = 
-                uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 10, &status);
+                uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 10, &status);
             TEST_ASSERT_SUCCESS(status);
 
             /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1106,7 +1105,7 @@ static void TestRegexCAPI(void) {
         if(U_SUCCESS(status)) {
             memset(fields, -1, sizeof(fields));
             numFields = 
-                uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 2, &status);
+                uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 2, &status);
             TEST_ASSERT_SUCCESS(status);
 
             /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1164,7 +1163,7 @@ static void TestRegexCAPI(void) {
         int32_t  spaceNeeded;
         int32_t  sz;
 
-        u_uastrncpy(textToSplit, "first <tag-a> second<tag-b>  third",  LENGTHOF(textToSplit));
+        u_uastrncpy(textToSplit, "first <tag-a> second<tag-b>  third",  UPRV_LENGTHOF(textToSplit));
 
         status = U_ZERO_ERROR;
         re = uregex_openC("<(.*?)>", 0, NULL, &status);
@@ -1176,7 +1175,7 @@ static void TestRegexCAPI(void) {
         if(U_SUCCESS(status)) {
             memset(fields, -1, sizeof(fields));
             numFields = 
-                uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 10, &status);
+                uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 10, &status);
             TEST_ASSERT_SUCCESS(status);
 
             /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1197,7 +1196,7 @@ static void TestRegexCAPI(void) {
         status = U_ZERO_ERROR;
         memset(fields, -1, sizeof(fields));
         numFields = 
-            uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 2, &status);
+            uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 2, &status);
         TEST_ASSERT_SUCCESS(status);
 
         /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1215,7 +1214,7 @@ static void TestRegexCAPI(void) {
         status = U_ZERO_ERROR;
         memset(fields, -1, sizeof(fields));
         numFields = 
-            uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 3, &status);
+            uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 3, &status);
         TEST_ASSERT_SUCCESS(status);
 
         /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1234,7 +1233,7 @@ static void TestRegexCAPI(void) {
         status = U_ZERO_ERROR;
         memset(fields, -1, sizeof(fields));
         numFields = 
-            uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 5, &status);
+            uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 5, &status);
         TEST_ASSERT_SUCCESS(status);
 
         /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1261,7 +1260,7 @@ static void TestRegexCAPI(void) {
         if(U_SUCCESS(status)) {
             memset(fields, -1, sizeof(fields));
             numFields = 
-                uregex_split(re, buf, LENGTHOF(buf), &requiredCapacity, fields, 9, &status);
+                uregex_split(re, buf, UPRV_LENGTHOF(buf), &requiredCapacity, fields, 9, &status);
             TEST_ASSERT_SUCCESS(status);
 
             /* The TEST_ASSERT_SUCCESS call above should change too... */
@@ -1468,8 +1467,8 @@ static void TestUTextAPI(void) {
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT(clone3 != NULL);
 
-        u_uastrncpy(testString1, "abcccd", LENGTHOF(pat));
-        u_uastrncpy(testString2, "xxxabcccd", LENGTHOF(pat));
+        u_uastrncpy(testString1, "abcccd", UPRV_LENGTHOF(pat));
+        u_uastrncpy(testString2, "xxxabcccd", UPRV_LENGTHOF(pat));
 
         status = U_ZERO_ERROR;
         uregex_setText(clone1, testString1, -1, &status);
@@ -1503,7 +1502,7 @@ static void TestUTextAPI(void) {
         UText        *resultText;
         const char str_hello[] = { 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00 }; /* hello */
         const char str_hel[] = { 0x68, 0x65, 0x6c, 0x00 }; /* hel */
-        u_uastrncpy(pat, "hello", LENGTHOF(pat)); /* for comparison */
+        u_uastrncpy(pat, "hello", UPRV_LENGTHOF(pat)); /* for comparison */
         status = U_ZERO_ERROR;
         
         utext_openUTF8(&patternText, str_hello, -1, &status);
@@ -1606,7 +1605,7 @@ static void TestUTextAPI(void) {
 
         status = U_ZERO_ERROR;
         utext_openUTF8(&text1, str_abcccd, -1, &status);
-        u_uastrncpy(text2Chars, str_abcccxd, LENGTHOF(text2Chars));
+        u_uastrncpy(text2Chars, str_abcccxd, UPRV_LENGTHOF(text2Chars));
         utext_openUChars(&text2, text2Chars, -1, &status);
         
         utext_openUTF8(&patternText, str_abcd, -1, &status);
@@ -1702,7 +1701,7 @@ static void TestUTextAPI(void) {
     {
         UChar    text1[50];
         UBool    result;
-        u_uastrncpy(text1, "012rx5rx890rxrx...",  LENGTHOF(text1));
+        u_uastrncpy(text1, "012rx5rx890rxrx...",  UPRV_LENGTHOF(text1));
         status = U_ZERO_ERROR;
         re = uregex_openC("rx", 0, NULL, &status);
 
@@ -1766,7 +1765,7 @@ static void TestUTextAPI(void) {
         const char str_interior[] = { 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x69, 0x6f, 0x72, 0x20, 0x00 }; /* ' interior ' */
         
 
-        u_uastrncpy(text1, "noise abc interior def, and this is off the end",  LENGTHOF(text1));
+        u_uastrncpy(text1, "noise abc interior def, and this is off the end",  UPRV_LENGTHOF(text1));
 
         status = U_ZERO_ERROR;
         re = uregex_openC("abc(.*?)def", 0, NULL, &status);
@@ -1844,8 +1843,8 @@ static void TestUTextAPI(void) {
         const char str_1x[] = { 0x3c, 0x24, 0x31, 0x3e, 0x00 }; /* <$1> */
         const char str_ReplaceAaaBax1xxx[] = { 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x5c, 0x41, 0x61, 0x61, 0x42, 0x24, 0x61, 0x20, 0x78, 0x31, 0x78, 0x20, 0x78, 0x2e, 0x2e, 0x2e, 0x78, 0x2e, 0x00 }; /* Replace \AaaB$a x1x x...x. */
         status = U_ZERO_ERROR;
-        u_uastrncpy(text1, "Replace xaax x1x x...x.",  LENGTHOF(text1));
-        u_uastrncpy(text2, "No match here.",  LENGTHOF(text2));
+        u_uastrncpy(text1, "Replace xaax x1x x...x.",  UPRV_LENGTHOF(text1));
+        u_uastrncpy(text2, "No match here.",  UPRV_LENGTHOF(text2));
         utext_openUTF8(&replText, str_1x, -1, &status);
 
         re = uregex_openC("x(.*?)x", 0, NULL, &status);
@@ -1890,8 +1889,8 @@ static void TestUTextAPI(void) {
         const char str_Replaceaa1[] = { 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3c, 0x61, 0x61, 0x3e, 0x20, 0x3c, 0x31, 0x3e, 0x20, 0x3c, 0x2e, 0x2e, 0x2e, 0x3e, 0x2e, 0x00 }; /* Replace <aa> <1> <...>. */
         const char str_Nomatchhere[] = { 0x4e, 0x6f, 0x20, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x20, 0x68, 0x65, 0x72, 0x65, 0x2e, 0x00 }; /* No match here. */
         status = U_ZERO_ERROR;
-        u_uastrncpy(text1, "Replace xaax x1x x...x.",  LENGTHOF(text1));
-        u_uastrncpy(text2, "No match here.",  LENGTHOF(text2));
+        u_uastrncpy(text1, "Replace xaax x1x x...x.",  UPRV_LENGTHOF(text1));
+        u_uastrncpy(text2, "No match here.",  UPRV_LENGTHOF(text2));
         utext_openUTF8(&replText, str_1, -1, &status);
 
         re = uregex_openC("x(.*?)x", 0, NULL, &status);
@@ -1930,15 +1929,15 @@ static void TestUTextAPI(void) {
         re = uregex_openC(".*", 0, 0, &status);
         TEST_ASSERT_SUCCESS(status);
 
-        u_uastrncpy(text, "whatever",  LENGTHOF(text));
-        u_uastrncpy(repl, "some other", LENGTHOF(repl));
+        u_uastrncpy(text, "whatever",  UPRV_LENGTHOF(text));
+        u_uastrncpy(repl, "some other", UPRV_LENGTHOF(repl));
         uregex_setText(re, text, -1, &status);
 
         /* match covers whole target string */
         uregex_find(re, 0, &status);
         TEST_ASSERT_SUCCESS(status);
         bufPtr = buf;
-        bufCap = LENGTHOF(buf);
+        bufCap = UPRV_LENGTHOF(buf);
         uregex_appendReplacement(re, repl, -1, &bufPtr, &bufCap, &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("some other", buf, TRUE);
@@ -1947,8 +1946,8 @@ static void TestUTextAPI(void) {
         uregex_find(re, 0, &status);
         TEST_ASSERT_SUCCESS(status);
         bufPtr = buf;
-        bufCap = LENGTHOF(buf);
-        u_uastrncpy(repl, "abc\\u0041\\U00000042 \\\\ $ \\abc", LENGTHOF(repl));
+        bufCap = UPRV_LENGTHOF(buf);
+        u_uastrncpy(repl, "abc\\u0041\\U00000042 \\\\ $ \\abc", UPRV_LENGTHOF(repl));
         uregex_appendReplacement(re, repl, -1, &bufPtr, &bufCap, &status);
         TEST_ASSERT_SUCCESS(status);
         TEST_ASSERT_STRING("abcAB \\ $ abc", buf, TRUE); 
@@ -1971,8 +1970,8 @@ static void TestUTextAPI(void) {
         int32_t  numFields;
         int32_t i;
 
-        u_uastrncpy(textToSplit, "first : second:  third",  LENGTHOF(textToSplit));
-        u_uastrncpy(text2, "No match here.",  LENGTHOF(text2));
+        u_uastrncpy(textToSplit, "first : second:  third",  UPRV_LENGTHOF(textToSplit));
+        u_uastrncpy(text2, "No match here.",  UPRV_LENGTHOF(text2));
 
         status = U_ZERO_ERROR;
         re = uregex_openC(":", 0, NULL, &status);
@@ -2047,7 +2046,7 @@ static void TestUTextAPI(void) {
         int32_t  numFields;
         int32_t i;
 
-        u_uastrncpy(textToSplit, "first <tag-a> second<tag-b>  third",  LENGTHOF(textToSplit));
+        u_uastrncpy(textToSplit, "first <tag-a> second<tag-b>  third",  UPRV_LENGTHOF(textToSplit));
 
         status = U_ZERO_ERROR;
         re = uregex_openC("<(.*?)>", 0, NULL, &status);
@@ -2292,7 +2291,7 @@ static void TestBug10815() {
     re = uregex_openC(".z", 0, 0, &status);
     TEST_ASSERT_SUCCESS(status);
 
-    u_uastrncpy(text, "Hello, World.",  LENGTHOF(text));
+    u_uastrncpy(text, "Hello, World.",  UPRV_LENGTHOF(text));
     uregex_setText(re, text, -1, &status);
     TEST_ASSERT_SUCCESS(status);
 
@@ -2312,7 +2311,7 @@ static void TestBug10815() {
 
     // Pattern + this text gives an exponential time match. Without the callback to stop the match,
     // it will appear to be stuck in a (near) infinite loop.
-    u_uastrncpy(text, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",  LENGTHOF(text));
+    u_uastrncpy(text, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",  UPRV_LENGTHOF(text));
     uregex_setText(re, text, -1, &status);
     TEST_ASSERT_SUCCESS(status);
 
index d98f78b4475bc4c8fc6aca25aa8ba62c7d80a7fb..e9dd50af8ac3b2c3cff82bf0aaeee5e273d8f65e 100644 (file)
@@ -20,8 +20,6 @@
 #include "unicode/dtfmtsym.h"
 #include "uassert.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0]))
-
 static const UChar kJPY[] = {0x4A, 0x50, 0x59};
 
 static void fixNonBreakingSpace(UnicodeString &str) {