X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..340931cb2e044a2141d11567dd0f782524e32994:/icuSources/test/cintltst/cmsccoll.c diff --git a/icuSources/test/cintltst/cmsccoll.c b/icuSources/test/cintltst/cmsccoll.c index d6b1a13c..e5d3d0d8 100644 --- a/icuSources/test/cintltst/cmsccoll.c +++ b/icuSources/test/cintltst/cmsccoll.c @@ -1,7 +1,8 @@ - +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** * COPYRIGHT: - * Copyright (c) 2001-2013, International Business Machines Corporation and + * Copyright (c) 2001-2016, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************* @@ -29,7 +30,6 @@ #include "unicode/ustring.h" #include "string.h" #include "ucol_imp.h" -#include "ucol_tok.h" #include "cmemory.h" #include "cstring.h" #include "uassert.h" @@ -42,8 +42,6 @@ #include "putilimp.h" -#define LEN(a) (sizeof(a)/sizeof(a[0])) - #define MAX_TOKEN_LEN 16 typedef UCollationResult tst_strcoll(void *collator, const int object, @@ -95,7 +93,7 @@ static void IncompleteCntTest(void) coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL,&status); if(U_SUCCESS(status)) { - size = sizeof(cnt1)/sizeof(cnt1[0]); + size = UPRV_LENGTHOF(cnt1); for(i = 0; i < size-1; i++) { for(j = i+1; j < size; j++) { UCollationElements *iter; @@ -121,7 +119,7 @@ static void IncompleteCntTest(void) coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status); if(U_SUCCESS(status)) { - size = sizeof(cnt2)/sizeof(cnt2[0]); + size = UPRV_LENGTHOF(cnt2); for(i = 0; i < size-1; i++) { for(j = i+1; j < size; j++) { UCollationElements *iter; @@ -195,7 +193,7 @@ static void BlackBirdTest(void) { ucol_setAttribute(coll, UCOL_ALTERNATE_HANDLING, UCOL_NON_IGNORABLE, &status); if(U_SUCCESS(status)) { - size = sizeof(nonignorable)/sizeof(nonignorable[0]); + size = UPRV_LENGTHOF(nonignorable); for(i = 0; i < size-1; i++) { for(j = i+1; j < size; j++) { u_uastrcpy(t1, nonignorable[i]); @@ -209,7 +207,7 @@ static void BlackBirdTest(void) { ucol_setAttribute(coll, UCOL_STRENGTH, UCOL_QUATERNARY, &status); if(U_SUCCESS(status)) { - size = sizeof(shifted)/sizeof(shifted[0]); + size = UPRV_LENGTHOF(shifted); for(i = 0; i < size-1; i++) { for(j = i+1; j < size; j++) { u_uastrcpy(t1, shifted[i]); @@ -221,7 +219,7 @@ static void BlackBirdTest(void) { ucol_setAttribute(coll, UCOL_STRENGTH, UCOL_TERTIARY, &status); if(U_SUCCESS(status)) { - size = sizeof(shifted)/sizeof(shifted[0]); + size = UPRV_LENGTHOF(shifted); for(i = 1; i < size; i++) { u_uastrcpy(t1, shifted[i-1]); u_uastrcpy(t2, shifted[i]); @@ -355,19 +353,19 @@ static void PrintMarkDavis(void) } fprintf(stderr, "\n"); - for(h = 0; h0x0400 && *p<0x0500)?0x00e1:0x491; - UChar preQ = (*p>0x0400 && *p<0x0500)?0x0041:0x413; -*/ - /*log_verbose("Testing primary\n");*/ - - doTest(col, p, q, UCOL_LESS); -/* - UCollationResult result = ucol_strcoll(col,p,u_strlen(p),q,u_strlen(q)); - - if(result!=UCOL_LESS){ - aescstrdup(p,utfSource,256); - aescstrdup(q,utfTarget,256); - fprintf(file,"Primary failed source: %s target: %s \n", utfSource,utfTarget); - } -*/ - source[0] = preP; - u_strcpy(source+1,p); - target[0] = preQ; - u_strcpy(target+1,q); - doTest(col, source, target, UCOL_LESS); -/* - fprintf(file,"Primary swamps 2nd failed source: %s target: %s \n", utfSource,utfTarget); -*/ -} - -static void testSecondary(UCollator* col, const UChar* p,const UChar* q){ - UChar source[256] = { '\0'}; - UChar target[256] = { '\0'}; - - /*log_verbose("Testing secondary\n");*/ - - doTest(col, p, q, UCOL_LESS); -/* - fprintf(file,"secondary failed source: %s target: %s \n", utfSource,utfTarget); -*/ - source[0] = 0x0053; - u_strcpy(source+1,p); - target[0]= 0x0073; - u_strcpy(target+1,q); - - doTest(col, source, target, UCOL_LESS); -/* - fprintf(file,"secondary swamps 3rd failed source: %s target: %s \n",utfSource,utfTarget); -*/ - - - u_strcpy(source,p); - source[u_strlen(p)] = 0x62; - source[u_strlen(p)+1] = 0; - - - u_strcpy(target,q); - target[u_strlen(q)] = 0x61; - target[u_strlen(q)+1] = 0; - - doTest(col, source, target, UCOL_GREATER); - -/* - fprintf(file,"secondary is swamped by 1 failed source: %s target: %s \n",utfSource,utfTarget); -*/ -} - -static void testTertiary(UCollator* col, const UChar* p,const UChar* q){ - UChar source[256] = { '\0'}; - UChar target[256] = { '\0'}; - - /*log_verbose("Testing tertiary\n");*/ - - doTest(col, p, q, UCOL_LESS); -/* - fprintf(file,"Tertiary failed source: %s target: %s \n",utfSource,utfTarget); -*/ - source[0] = 0x0020; - u_strcpy(source+1,p); - target[0]= 0x002D; - u_strcpy(target+1,q); - - doTest(col, source, target, UCOL_LESS); -/* - fprintf(file,"Tertiary swamps 4th failed source: %s target: %s \n", utfSource,utfTarget); -*/ - - u_strcpy(source,p); - source[u_strlen(p)] = 0xE0; - source[u_strlen(p)+1] = 0; - - u_strcpy(target,q); - target[u_strlen(q)] = 0x61; - target[u_strlen(q)+1] = 0; - - doTest(col, source, target, UCOL_GREATER); - -/* - fprintf(file,"Tertiary is swamped by 3rd failed source: %s target: %s \n",utfSource,utfTarget); -*/ -} - -static void testEquality(UCollator* col, const UChar* p,const UChar* q){ -/* - UChar source[256] = { '\0'}; - UChar target[256] = { '\0'}; -*/ - - doTest(col, p, q, UCOL_EQUAL); -/* - fprintf(file,"Primary failed source: %s target: %s \n", utfSource,utfTarget); -*/ -} - -static void testCollator(UCollator *coll, UErrorCode *status) { - const UChar *rules = NULL, *current = NULL; - int32_t ruleLen = 0; - uint32_t strength = 0; - uint32_t chOffset = 0; uint32_t chLen = 0; - uint32_t exOffset = 0; uint32_t exLen = 0; - uint32_t prefixOffset = 0; uint32_t prefixLen = 0; - uint32_t firstEx = 0; -/* uint32_t rExpsLen = 0; */ - uint32_t firstLen = 0; - UBool varT = FALSE; UBool top_ = TRUE; - uint16_t specs = 0; - UBool startOfRules = TRUE; - UBool lastReset = FALSE; - UBool before = FALSE; - uint32_t beforeStrength = 0; - UColTokenParser src; - UColOptionSet opts; - - UChar first[256]; - UChar second[256]; - UChar tempB[256]; - uint32_t tempLen; - UChar *rulesCopy = NULL; - UParseError parseError; - - uprv_memset(&src, 0, sizeof(UColTokenParser)); - - src.opts = &opts; - - rules = ucol_getRules(coll, &ruleLen); - if(U_SUCCESS(*status) && ruleLen > 0) { - rulesCopy = (UChar *)uprv_malloc((ruleLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); - uprv_memcpy(rulesCopy, rules, ruleLen*sizeof(UChar)); - src.current = src.source = rulesCopy; - src.end = rulesCopy+ruleLen; - src.extraCurrent = src.end; - src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; - *first = *second = 0; - - /* Note that as a result of tickets 7015 or 6912, ucol_tok_parseNextToken can cause the pointer to - the rules copy in src.source to get reallocated, freeing the original pointer in rulesCopy */ - while ((current = ucol_tok_parseNextToken(&src, startOfRules,&parseError, status)) != NULL) { - strength = src.parsedToken.strength; - chOffset = src.parsedToken.charsOffset; - chLen = src.parsedToken.charsLen; - exOffset = src.parsedToken.extensionOffset; - exLen = src.parsedToken.extensionLen; - prefixOffset = src.parsedToken.prefixOffset; - prefixLen = src.parsedToken.prefixLen; - specs = src.parsedToken.flags; - - startOfRules = FALSE; - varT = (UBool)((specs & UCOL_TOK_VARIABLE_TOP) != 0); - top_ = (UBool)((specs & UCOL_TOK_TOP) != 0); - if(top_) { /* if reset is on top, the sequence is broken. We should have an empty string */ - second[0] = 0; - } else { - u_strncpy(second,src.source+chOffset, chLen); - second[chLen] = 0; - - if(exLen > 0 && firstEx == 0) { - u_strncat(first, src.source+exOffset, exLen); - first[firstLen+exLen] = 0; - } - - if(lastReset == TRUE && prefixLen != 0) { - u_strncpy(first+prefixLen, first, firstLen); - u_strncpy(first, src.source+prefixOffset, prefixLen); - first[firstLen+prefixLen] = 0; - firstLen = firstLen+prefixLen; - } - - if(before == TRUE) { /* swap first and second */ - u_strcpy(tempB, first); - u_strcpy(first, second); - u_strcpy(second, tempB); - - tempLen = firstLen; - firstLen = chLen; - chLen = tempLen; - - tempLen = firstEx; - firstEx = exLen; - exLen = tempLen; - if(beforeStrength < strength) { - strength = beforeStrength; - } - } - } - lastReset = FALSE; - - switch(strength){ - case UCOL_IDENTICAL: - testEquality(coll,first,second); - break; - case UCOL_PRIMARY: - testPrimary(coll,first,second); - break; - case UCOL_SECONDARY: - testSecondary(coll,first,second); - break; - case UCOL_TERTIARY: - testTertiary(coll,first,second); - break; - case UCOL_TOK_RESET: - lastReset = TRUE; - before = (UBool)((specs & UCOL_TOK_BEFORE) != 0); - if(before) { - beforeStrength = (specs & UCOL_TOK_BEFORE)-1; - } - break; - default: - break; - } - - if(before == TRUE && strength != UCOL_TOK_RESET) { /* first and second were swapped */ - before = FALSE; - } else { - firstLen = chLen; - firstEx = exLen; - u_strcpy(first, second); - } - } - uprv_free(src.source); - uprv_free(src.reorderCodes); - } -} - -static UCollationResult ucaTest(void *collator, const int object, const UChar *source, const int sLen, const UChar *target, const int tLen) { - UCollator *UCA = (UCollator *)collator; - return ucol_strcoll(UCA, source, sLen, target, tLen); -} - -/* -static UCollationResult winTest(void *collator, const int object, const UChar *source, const int sLen, const UChar *target, const int tLen) { -#if U_PLATFORM_HAS_WIN32_API - LCID lcid = (LCID)collator; - return (UCollationResult)CompareString(lcid, 0, source, sLen, target, tLen); -#else - return 0; -#endif -} -*/ - -static UCollationResult swampEarlier(tst_strcoll* func, void *collator, int opts, - UChar s1, UChar s2, - const UChar *s, const uint32_t sLen, - const UChar *t, const uint32_t tLen) { - UChar source[256] = {0}; - UChar target[256] = {0}; - - source[0] = s1; - u_strcpy(source+1, s); - target[0] = s2; - u_strcpy(target+1, t); - - return func(collator, opts, source, sLen+1, target, tLen+1); -} - -static UCollationResult swampLater(tst_strcoll* func, void *collator, int opts, - UChar s1, UChar s2, - const UChar *s, const uint32_t sLen, - const UChar *t, const uint32_t tLen) { - UChar source[256] = {0}; - UChar target[256] = {0}; - - u_strcpy(source, s); - source[sLen] = s1; - u_strcpy(target, t); - target[tLen] = s2; - - return func(collator, opts, source, sLen+1, target, tLen+1); -} - -static uint32_t probeStrength(tst_strcoll* func, void *collator, int opts, - const UChar *s, const uint32_t sLen, - const UChar *t, const uint32_t tLen, - UCollationResult result) { - /*UChar fPrimary = 0x6d;*/ - /*UChar sPrimary = 0x6e;*/ - UChar fSecondary = 0x310d; - UChar sSecondary = 0x31a3; - UChar fTertiary = 0x310f; - UChar sTertiary = 0x31b7; - - UCollationResult oposite; - if(result == UCOL_EQUAL) { - return UCOL_IDENTICAL; - } else if(result == UCOL_GREATER) { - oposite = UCOL_LESS; - } else { - oposite = UCOL_GREATER; - } - - if(swampEarlier(func, collator, opts, sSecondary, fSecondary, s, sLen, t, tLen) == result) { - return UCOL_PRIMARY; - } else if((swampEarlier(func, collator, opts, sTertiary, 0x310f, s, sLen, t, tLen) == result) && - (swampEarlier(func, collator, opts, 0x310f, sTertiary, s, sLen, t, tLen) == result)) { - return UCOL_SECONDARY; - } else if((swampLater(func, collator, opts, sTertiary, fTertiary, s, sLen, t, tLen) == result) && - (swampLater(func, collator, opts, fTertiary, sTertiary, s, sLen, t, tLen) == result)) { - return UCOL_TERTIARY; - } else if((swampLater(func, collator, opts, sTertiary, 0x310f, s, sLen, t, tLen) == oposite) && - (swampLater(func, collator, opts, fTertiary, sTertiary, s, sLen, t, tLen) == oposite)) { - return UCOL_QUATERNARY; - } else { - return UCOL_IDENTICAL; - } -} - -static char *getRelationSymbol(UCollationResult res, uint32_t strength, char *buffer) { - uint32_t i = 0; - - if(res == UCOL_EQUAL || strength == 0xdeadbeef) { - buffer[0] = '='; - buffer[1] = '='; - buffer[2] = '\0'; - } else if(res == UCOL_GREATER) { - for(i = 0; i maxOutputLength) { - maxOutputLength = outputLength; - U_ASSERT(outputLength < sizeof(output)); - } - - log_verbose("%s\n", output); - -} - -/* -static void printOutRules(const UChar *rules) { - uint32_t len = u_strlen(rules); - uint32_t i = 0; - char toPrint; - uint32_t line = 0; - - fprintf(stdout, "Rules:"); - - for(i = 0; i=0x20) { - toPrint = (char)rules[i]; - if(toPrint == '&') { - line = 1; - fprintf(stdout, "\n&"); - } else if(toPrint == ';') { - fprintf(stdout, "<<"); - line+=2; - } else if(toPrint == ',') { - fprintf(stdout, "<<<"); - line+=3; - } else { - fprintf(stdout, "%c", toPrint); - line++; - } - } else if(rules[i]<0x3400 || rules[i]>=0xa000) { - fprintf(stdout, "\\u%04X", rules[i]); - line+=6; - } - if(line>72) { - fprintf(stdout, "\n"); - line = 0; - } - } - - log_verbose("\n"); - -} -*/ - -static uint32_t testSwitch(tst_strcoll* func, void *collator, int opts, uint32_t strength, const UChar *first, const UChar *second, const char* msg, UBool error) { - uint32_t diffs = 0; - UCollationResult realResult; - uint32_t realStrength; - - uint32_t sLen = u_strlen(first); - uint32_t tLen = u_strlen(second); - - realResult = func(collator, opts, first, sLen, second, tLen); - realStrength = probeStrength(func, collator, opts, first, sLen, second, tLen, realResult); - - if(strength == UCOL_IDENTICAL && realResult != UCOL_EQUAL) { - logFailure(msg, "tailoring", first, sLen, second, tLen, realResult, realStrength, UCOL_EQUAL, strength, error); - diffs++; - } else if(realResult != UCOL_LESS || realStrength != strength) { - logFailure(msg, "tailoring", first, sLen, second, tLen, realResult, realStrength, UCOL_LESS, strength, error); - diffs++; - } - return diffs; -} - - -static void testAgainstUCA(UCollator *coll, UCollator *UCA, const char *refName, UBool error, UErrorCode *status) { - const UChar *rules = NULL, *current = NULL; - int32_t ruleLen = 0; - uint32_t strength = 0; - uint32_t chOffset = 0; uint32_t chLen = 0; - uint32_t exOffset = 0; uint32_t exLen = 0; - uint32_t prefixOffset = 0; uint32_t prefixLen = 0; -/* uint32_t rExpsLen = 0; */ - uint32_t firstLen = 0, secondLen = 0; - UBool varT = FALSE; UBool top_ = TRUE; - uint16_t specs = 0; - UBool startOfRules = TRUE; - UColTokenParser src; - UColOptionSet opts; - - UChar first[256]; - UChar second[256]; - UChar *rulesCopy = NULL; - - uint32_t UCAdiff = 0; - uint32_t Windiff = 1; - UParseError parseError; - - uprv_memset(&src, 0, sizeof(UColTokenParser)); - src.opts = &opts; - - rules = ucol_getRules(coll, &ruleLen); - - /*printOutRules(rules);*/ - - if(U_SUCCESS(*status) && ruleLen > 0) { - rulesCopy = (UChar *)uprv_malloc((ruleLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); - uprv_memcpy(rulesCopy, rules, ruleLen*sizeof(UChar)); - src.current = src.source = rulesCopy; - src.end = rulesCopy+ruleLen; - src.extraCurrent = src.end; - src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; - *first = *second = 0; - - /* Note that as a result of tickets 7015 or 6912, ucol_tok_parseNextToken can cause the pointer to - the rules copy in src.source to get reallocated, freeing the original pointer in rulesCopy */ - while ((current = ucol_tok_parseNextToken(&src, startOfRules, &parseError,status)) != NULL) { - strength = src.parsedToken.strength; - chOffset = src.parsedToken.charsOffset; - chLen = src.parsedToken.charsLen; - exOffset = src.parsedToken.extensionOffset; - exLen = src.parsedToken.extensionLen; - prefixOffset = src.parsedToken.prefixOffset; - prefixLen = src.parsedToken.prefixLen; - specs = src.parsedToken.flags; - - startOfRules = FALSE; - varT = (UBool)((specs & UCOL_TOK_VARIABLE_TOP) != 0); - top_ = (UBool)((specs & UCOL_TOK_TOP) != 0); - - u_strncpy(second,src.source+chOffset, chLen); - second[chLen] = 0; - secondLen = chLen; - - if(exLen > 0) { - u_strncat(first, src.source+exOffset, exLen); - first[firstLen+exLen] = 0; - firstLen += exLen; - } - - if(strength != UCOL_TOK_RESET) { - if((*first<0x3400 || *first>=0xa000) && (*second<0x3400 || *second>=0xa000)) { - UCAdiff += testSwitch(&ucaTest, (void *)UCA, 0, strength, first, second, refName, error); - /*Windiff += testSwitch(&winTest, (void *)lcid, 0, strength, first, second, "Win32");*/ - } - } - - - firstLen = chLen; - u_strcpy(first, second); - - } - if(UCAdiff != 0 && Windiff != 0) { - log_verbose("\n"); - } - if(UCAdiff == 0) { - log_verbose("No immediate difference with %s!\n", refName); - } - if(Windiff == 0) { - log_verbose("No immediate difference with Win32!\n"); - } - uprv_free(src.source); - uprv_free(src.reorderCodes); - } -} - -/* - * Takes two CEs (lead and continuation) and - * compares them as CEs should be compared: - * primary vs. primary, secondary vs. secondary - * tertiary vs. tertiary - */ -static int32_t compareCEs(uint32_t s1, uint32_t s2, - uint32_t t1, uint32_t t2) { - uint32_t s = 0, t = 0; - if(s1 == t1 && s2 == t2) { - return 0; - } - s = (s1 & 0xFFFF0000)|((s2 & 0xFFFF0000)>>16); - t = (t1 & 0xFFFF0000)|((t2 & 0xFFFF0000)>>16); - if(s < t) { - return -1; - } else if(s > t) { - return 1; - } else { - s = (s1 & 0x0000FF00) | (s2 & 0x0000FF00)>>8; - t = (t1 & 0x0000FF00) | (t2 & 0x0000FF00)>>8; - if(s < t) { - return -1; - } else if(s > t) { - return 1; - } else { - s = (s1 & 0x000000FF)<<8 | (s2 & 0x000000FF); - t = (t1 & 0x000000FF)<<8 | (t2 & 0x000000FF); - if(s < t) { - return -1; - } else { - return 1; - } - } - } -} - -typedef struct { - uint32_t startCE; - uint32_t startContCE; - uint32_t limitCE; - uint32_t limitContCE; -} indirectBoundaries; - -/* these values are used for finding CE values for indirect positioning. */ -/* Indirect positioning is a mechanism for allowing resets on symbolic */ -/* values. It only works for resets and you cannot tailor indirect names */ -/* An indirect name can define either an anchor point or a range. An */ -/* anchor point behaves in exactly the same way as a code point in reset */ -/* would, except that it cannot be tailored. A range (we currently only */ -/* know for the [top] range will explicitly set the upper bound for */ -/* generated CEs, thus allowing for better control over how many CEs can */ -/* be squeezed between in the range without performance penalty. */ -/* In that respect, we use [top] for tailoring of locales that use CJK */ -/* characters. Other indirect values are currently a pure convenience, */ -/* they can be used to assure that the CEs will be always positioned in */ -/* the same place relative to a point with known properties (e.g. first */ -/* primary ignorable). */ -static indirectBoundaries ucolIndirectBoundaries[15]; -static UBool indirectBoundariesSet = FALSE; -static void setIndirectBoundaries(uint32_t indexR, uint32_t *start, uint32_t *end) { - /* Set values for the top - TODO: once we have values for all the indirects, we are going */ - /* to initalize here. */ - ucolIndirectBoundaries[indexR].startCE = start[0]; - ucolIndirectBoundaries[indexR].startContCE = start[1]; - if(end) { - ucolIndirectBoundaries[indexR].limitCE = end[0]; - ucolIndirectBoundaries[indexR].limitContCE = end[1]; - } else { - ucolIndirectBoundaries[indexR].limitCE = 0; - ucolIndirectBoundaries[indexR].limitContCE = 0; - } -} - -static void testCEs(UCollator *coll, UErrorCode *status) { - const UChar *rules = NULL, *current = NULL; - int32_t ruleLen = 0; - - uint32_t strength = 0; - uint32_t maxStrength = UCOL_IDENTICAL; - uint32_t baseCE, baseContCE, nextCE, nextContCE, currCE, currContCE; - uint32_t lastCE; - uint32_t lastContCE; - - int32_t result = 0; - uint32_t chOffset = 0; uint32_t chLen = 0; - uint32_t exOffset = 0; uint32_t exLen = 0; - uint32_t prefixOffset = 0; uint32_t prefixLen = 0; - uint32_t oldOffset = 0; - - /* uint32_t rExpsLen = 0; */ - /* uint32_t firstLen = 0; */ - uint16_t specs = 0; - UBool varT = FALSE; UBool top_ = TRUE; - UBool startOfRules = TRUE; - UBool before = FALSE; - UColTokenParser src; - UColOptionSet opts; - UParseError parseError; - UChar *rulesCopy = NULL; - collIterate *c = uprv_new_collIterate(status); - UCAConstants *consts = NULL; - uint32_t UCOL_RESET_TOP_VALUE, /*UCOL_RESET_TOP_CONT, */ - UCOL_NEXT_TOP_VALUE, UCOL_NEXT_TOP_CONT; - const char *colLoc; - UCollator *UCA = ucol_open("root", status); - - if (U_FAILURE(*status)) { - log_err("Could not open root collator %s\n", u_errorName(*status)); - uprv_delete_collIterate(c); - return; - } - - colLoc = ucol_getLocaleByType(coll, ULOC_ACTUAL_LOCALE, status); - if (U_FAILURE(*status)) { - log_err("Could not get collator name: %s\n", u_errorName(*status)); - ucol_close(UCA); - uprv_delete_collIterate(c); - return; - } - - uprv_memset(&src, 0, sizeof(UColTokenParser)); - - consts = (UCAConstants *)((uint8_t *)UCA->image + UCA->image->UCAConsts); - UCOL_RESET_TOP_VALUE = consts->UCA_LAST_NON_VARIABLE[0]; - /*UCOL_RESET_TOP_CONT = consts->UCA_LAST_NON_VARIABLE[1]; */ - UCOL_NEXT_TOP_VALUE = consts->UCA_FIRST_IMPLICIT[0]; - UCOL_NEXT_TOP_CONT = consts->UCA_FIRST_IMPLICIT[1]; - - baseCE=baseContCE=nextCE=nextContCE=currCE=currContCE=lastCE=lastContCE = UCOL_NOT_FOUND; - - src.opts = &opts; - - rules = ucol_getRules(coll, &ruleLen); - - src.invUCA = ucol_initInverseUCA(status); - - if(indirectBoundariesSet == FALSE) { - /* UCOL_RESET_TOP_VALUE */ - setIndirectBoundaries(0, consts->UCA_LAST_NON_VARIABLE, consts->UCA_FIRST_IMPLICIT); - /* UCOL_FIRST_PRIMARY_IGNORABLE */ - setIndirectBoundaries(1, consts->UCA_FIRST_PRIMARY_IGNORABLE, 0); - /* UCOL_LAST_PRIMARY_IGNORABLE */ - setIndirectBoundaries(2, consts->UCA_LAST_PRIMARY_IGNORABLE, 0); - /* UCOL_FIRST_SECONDARY_IGNORABLE */ - setIndirectBoundaries(3, consts->UCA_FIRST_SECONDARY_IGNORABLE, 0); - /* UCOL_LAST_SECONDARY_IGNORABLE */ - setIndirectBoundaries(4, consts->UCA_LAST_SECONDARY_IGNORABLE, 0); - /* UCOL_FIRST_TERTIARY_IGNORABLE */ - setIndirectBoundaries(5, consts->UCA_FIRST_TERTIARY_IGNORABLE, 0); - /* UCOL_LAST_TERTIARY_IGNORABLE */ - setIndirectBoundaries(6, consts->UCA_LAST_TERTIARY_IGNORABLE, 0); - /* UCOL_FIRST_VARIABLE */ - setIndirectBoundaries(7, consts->UCA_FIRST_VARIABLE, 0); - /* UCOL_LAST_VARIABLE */ - setIndirectBoundaries(8, consts->UCA_LAST_VARIABLE, 0); - /* UCOL_FIRST_NON_VARIABLE */ - setIndirectBoundaries(9, consts->UCA_FIRST_NON_VARIABLE, 0); - /* UCOL_LAST_NON_VARIABLE */ - setIndirectBoundaries(10, consts->UCA_LAST_NON_VARIABLE, consts->UCA_FIRST_IMPLICIT); - /* UCOL_FIRST_IMPLICIT */ - setIndirectBoundaries(11, consts->UCA_FIRST_IMPLICIT, 0); - /* UCOL_LAST_IMPLICIT */ - setIndirectBoundaries(12, consts->UCA_LAST_IMPLICIT, consts->UCA_FIRST_TRAILING); - /* UCOL_FIRST_TRAILING */ - setIndirectBoundaries(13, consts->UCA_FIRST_TRAILING, 0); - /* UCOL_LAST_TRAILING */ - setIndirectBoundaries(14, consts->UCA_LAST_TRAILING, 0); - ucolIndirectBoundaries[14].limitCE = (consts->UCA_PRIMARY_SPECIAL_MIN<<24); - indirectBoundariesSet = TRUE; - } - - - if(U_SUCCESS(*status) && ruleLen > 0) { - rulesCopy = (UChar *)uprv_malloc((ruleLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); - uprv_memcpy(rulesCopy, rules, ruleLen*sizeof(UChar)); - src.current = src.source = rulesCopy; - src.end = rulesCopy+ruleLen; - src.extraCurrent = src.end; - src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; - - /* Note that as a result of tickets 7015 or 6912, ucol_tok_parseNextToken can cause the pointer to - the rules copy in src.source to get reallocated, freeing the original pointer in rulesCopy */ - while ((current = ucol_tok_parseNextToken(&src, startOfRules, &parseError,status)) != NULL) { - strength = src.parsedToken.strength; - chOffset = src.parsedToken.charsOffset; - chLen = src.parsedToken.charsLen; - exOffset = src.parsedToken.extensionOffset; - exLen = src.parsedToken.extensionLen; - prefixOffset = src.parsedToken.prefixOffset; - prefixLen = src.parsedToken.prefixLen; - specs = src.parsedToken.flags; - - startOfRules = FALSE; - varT = (UBool)((specs & UCOL_TOK_VARIABLE_TOP) != 0); - top_ = (UBool)((specs & UCOL_TOK_TOP) != 0); - - uprv_init_collIterate(coll, src.source+chOffset, chLen, c, status); - - currCE = ucol_getNextCE(coll, c, status); - if(currCE == 0 && UCOL_ISTHAIPREVOWEL(*(src.source+chOffset))) { - log_verbose("Thai prevowel detected. Will pick next CE\n"); - currCE = ucol_getNextCE(coll, c, status); - } - - currContCE = ucol_getNextCE(coll, c, status); - if(!isContinuation(currContCE)) { - currContCE = 0; - } - - /* we need to repack CEs here */ - - if(strength == UCOL_TOK_RESET) { - before = (UBool)((specs & UCOL_TOK_BEFORE) != 0); - if(top_ == TRUE) { - int32_t tokenIndex = src.parsedToken.indirectIndex; - - nextCE = baseCE = currCE = ucolIndirectBoundaries[tokenIndex].startCE; - nextContCE = baseContCE = currContCE = ucolIndirectBoundaries[tokenIndex].startContCE; - } else { - nextCE = baseCE = currCE; - nextContCE = baseContCE = currContCE; - } - maxStrength = UCOL_IDENTICAL; - } else { - if(strength < maxStrength) { - maxStrength = strength; - if(baseCE == UCOL_RESET_TOP_VALUE) { - log_verbose("Resetting to [top]\n"); - nextCE = UCOL_NEXT_TOP_VALUE; - nextContCE = UCOL_NEXT_TOP_CONT; - } else { - result = ucol_inv_getNextCE(&src, baseCE & 0xFFFFFF3F, baseContCE, &nextCE, &nextContCE, maxStrength); - } - if(result < 0) { - if(ucol_isTailored(coll, *(src.source+oldOffset), status)) { - log_verbose("Reset is tailored codepoint %04X, don't know how to continue, taking next test\n", *(src.source+oldOffset)); - return; - } else { - log_err("%s: couldn't find the CE\n", colLoc); - return; - } - } - } - - currCE &= 0xFFFFFF3F; - currContCE &= 0xFFFFFFBF; - - if(maxStrength == UCOL_IDENTICAL) { - if(baseCE != currCE || baseContCE != currContCE) { - log_err("%s: current CE (initial strength UCOL_EQUAL)\n", colLoc); - } - } else { - if(strength == UCOL_IDENTICAL) { - if(lastCE != currCE || lastContCE != currContCE) { - log_err("%s: current CE (initial strength UCOL_EQUAL)\n", colLoc); - } - } else { - if(compareCEs(currCE, currContCE, nextCE, nextContCE) > 0) { - /*if(currCE > nextCE || (currCE == nextCE && currContCE >= nextContCE)) {*/ - log_err("%s: current CE is not less than base CE\n", colLoc); - } - if(!before) { - if(compareCEs(currCE, currContCE, lastCE, lastContCE) < 0) { - /*if(currCE < lastCE || (currCE == lastCE && currContCE <= lastContCE)) {*/ - log_err("%s: sequence of generated CEs is broken\n", colLoc); - } - } else { - before = FALSE; - if(compareCEs(currCE, currContCE, lastCE, lastContCE) > 0) { - /*if(currCE < lastCE || (currCE == lastCE && currContCE <= lastContCE)) {*/ - log_err("%s: sequence of generated CEs is broken\n", colLoc); - } - } - } - } - - } - - oldOffset = chOffset; - lastCE = currCE & 0xFFFFFF3F; - lastContCE = currContCE & 0xFFFFFFBF; - } - uprv_free(src.source); - uprv_free(src.reorderCodes); - } - ucol_close(UCA); - uprv_delete_collIterate(c); -} - -#if 0 -/* these locales are now picked from index RB */ -static const char* localesToTest[] = { -"ar", "bg", "ca", "cs", "da", -"el", "en_BE", "en_US_POSIX", -"es", "et", "fi", "fr", "hi", -"hr", "hu", "is", "iw", "ja", -"ko", "lt", "lv", "mk", "mt", -"nb", "nn", "nn_NO", "pl", "ro", -"ru", "sh", "sk", "sl", "sq", -"sr", "sv", "th", "tr", "uk", -"vi", "zh", "zh_TW" -}; -#endif - -static const char* rulesToTest[] = { - /* Funky fa rule */ - "&\\u0622 < \\u0627 << \\u0671 < \\u0621", - /*"& Z < p, P",*/ - /* Cui Mins rules */ - "&[top]image->jamoSpecial == TRUE) { - log_err("%s has special JAMOs\n", locName); - } - ucol_setAttribute(coll, UCOL_CASE_FIRST, UCOL_OFF, &status); - testCollator(coll, &status); - testCEs(coll, &status); - } else { - log_verbose("Skipping %s: %s\n", locName, u_errorName(status)); - } - ucol_close(coll); - } else { - log_err("Could not open %s: %s\n", locName, u_errorName(status)); - } - } - } - - for(i = 0; i %s (Are you missing data?)\n", u_errorName(status)); + uset_close(charsToTest); return; } charsToTestSize = uset_size(charsToTest); if (charsToTestSize <= 0) { log_err("Set was zero. Missing data?\n"); + uset_close(charsToTest); return; } t = (tester **)malloc(charsToTestSize * sizeof(tester *)); @@ -1862,7 +776,7 @@ static void TestBefore(void) { "&[before 1]o<\\u014d<\\u00f3<\\u01d2<\\u00f2" "&[before 1]u<\\u016b<\\u00fa<\\u01d4<\\u00f9" "&u<\\u01d6<\\u01d8<\\u01da<\\u01dc<\\u00fc", - data, sizeof(data)/sizeof(data[0])); + data, UPRV_LENGTHOF(data)); } #if 0 @@ -1877,244 +791,42 @@ static void TestJ784(void) { "\\u00fc", "\\u01d6", "\\u01d8", "\\u01da", "\\u01dc" }; - genericLocaleStarter("zh", data, sizeof(data)/sizeof(data[0])); + genericLocaleStarter("zh", data, UPRV_LENGTHOF(data)); } #endif -#if 0 -/* superceded by the changes to the lv locale */ -static void TestJ831(void) { +static void TestUpperCaseFirst(void) { const static char *data[] = { "I", "i", "Y", "y" - }; - genericLocaleStarter("lv", data, sizeof(data)/sizeof(data[0])); -} -#endif - -static void TestJ815(void) { - const static char *data[] = { - "aa", - "Aa", - "ab", - "Ab", - "ad", - "Ad", - "ae", - "Ae", - "\\u00e6", - "\\u00c6", - "af", - "Af", - "b", - "B" - }; - genericLocaleStarter("fr", data, sizeof(data)/sizeof(data[0])); - genericRulesStarter("[backwards 2]&A<<\\u00e6/e<<<\\u00c6/E", data, sizeof(data)/sizeof(data[0])); -} - - -/* -"& a < b < c < d& r < c", "& a < b < d& r < c", -"& a < b < c < d& c < m", "& a < b < c < m < d", -"& a < b < c < d& a < m", "& a < m < b < c < d", -"& a <<< b << c < d& a < m", "& a <<< b << c < m < d", -"& a < b < c < d& [before 1] c < m", "& a < b < m < c < d", -"& a < b <<< c << d <<< e& [before 3] e <<< x", "& a < b <<< c << d <<< x <<< e", -"& a < b <<< c << d <<< e& [before 2] e <<< x", "& a < b <<< c <<< x << d <<< e", -"& a < b <<< c << d <<< e& [before 1] e <<< x", "& a <<< x < b <<< c << d <<< e", -"& a < b <<< c << d <<< e <<< f < g& [before 1] g < x", "& a < b <<< c << d <<< e <<< f < x < g", -*/ -static void TestRedundantRules(void) { - int32_t i; - - static const struct { - const char *rules; - const char *expectedRules; - const char *testdata[8]; - uint32_t testdatalen; - } tests[] = { - /* this test conflicts with positioning of CODAN placeholder */ - /*{ - "& a <<< b <<< c << d <<< e& [before 1] e <<< x", - "&\\u2089<<image)->jamoSpecial = TRUE; /* don't try this at home */ - genericOrderingTest(coll, koreanData, sizeof(koreanData)/sizeof(koreanData[0])); - ucol_close(coll); log_verbose("Using ko__LOTUS locale\n"); - genericLocaleStarter("ko__LOTUS", koreanData, sizeof(koreanData)/sizeof(koreanData[0])); + genericLocaleStarter("ko__LOTUS", koreanData, UPRV_LENGTHOF(koreanData)); } +/* + * The secondary/tertiary compression middle byte + * as used by the current implementation. + * Subject to change as the sort key compression changes. + * See class CollationKeys. + */ +enum { + SEC_COMMON_MIDDLE = 0x25, /* range 05..45 */ + TER_ONLY_COMMON_MIDDLE = 0x65 /* range 05..C5 */ +}; + static void TestCompressOverlap(void) { UChar secstr[150]; UChar tertstr[150]; UErrorCode status = U_ZERO_ERROR; UCollator *coll; - char result[200]; + uint8_t result[500]; uint32_t resultlen; int count = 0; - char *tempptr; + uint8_t *tempptr; coll = ucol_open("", &status); @@ -2580,28 +1299,29 @@ static void TestCompressOverlap(void) { /* no compression secstr should have 150 secondary bytes, tertstr should have 150 tertiary bytes. - with correct overlapping compression, secstr should have 4 secondary - bytes, tertstr should have > 2 tertiary bytes */ - resultlen = ucol_getSortKey(coll, secstr, 150, (uint8_t *)result, 250); - tempptr = uprv_strchr(result, 1) + 1; + with correct compression, secstr should have 6 secondary + bytes (149/33 rounded up + accent), tertstr should have > 2 tertiary bytes */ + resultlen = ucol_getSortKey(coll, secstr, 150, result, UPRV_LENGTHOF(result)); + (void)resultlen; /* Suppress set but not used warning. */ + tempptr = (uint8_t *)uprv_strchr((char *)result, 1) + 1; while (*(tempptr + 1) != 1) { /* the last secondary collation element is not checked since it is not part of the compression */ - if (*tempptr < UCOL_COMMON_TOP2 - UCOL_TOP_COUNT2) { - log_err("Secondary compression overlapped\n"); + if (*tempptr < SEC_COMMON_MIDDLE) { + log_err("Secondary top down compression overlapped\n"); } tempptr ++; } /* tertiary top/bottom/common for en_US is similar to the secondary top/bottom/common */ - resultlen = ucol_getSortKey(coll, tertstr, 150, (uint8_t *)result, 250); - tempptr = uprv_strrchr(result, 1) + 1; + resultlen = ucol_getSortKey(coll, tertstr, 150, result, UPRV_LENGTHOF(result)); + tempptr = (uint8_t *)uprv_strrchr((char *)result, 1) + 1; while (*(tempptr + 1) != 0) { /* the last secondary collation element is not checked since it is not part of the compression */ - if (*tempptr < coll->tertiaryTop - coll->tertiaryTopCount) { - log_err("Tertiary compression overlapped\n"); + if (*tempptr < TER_ONLY_COMMON_MIDDLE) { + log_err("Tertiary top down compression overlapped\n"); } tempptr ++; } @@ -2609,26 +1329,26 @@ static void TestCompressOverlap(void) { /* bottom up compression ------------------------------------- */ secstr[count] = 0; tertstr[count] = 0; - resultlen = ucol_getSortKey(coll, secstr, 150, (uint8_t *)result, 250); - tempptr = uprv_strchr(result, 1) + 1; + resultlen = ucol_getSortKey(coll, secstr, 150, result, UPRV_LENGTHOF(result)); + tempptr = (uint8_t *)uprv_strchr((char *)result, 1) + 1; while (*(tempptr + 1) != 1) { /* the last secondary collation element is not checked since it is not part of the compression */ - if (*tempptr > UCOL_COMMON_BOT2 + UCOL_BOT_COUNT2) { - log_err("Secondary compression overlapped\n"); + if (*tempptr > SEC_COMMON_MIDDLE) { + log_err("Secondary bottom up compression overlapped\n"); } tempptr ++; } /* tertiary top/bottom/common for en_US is similar to the secondary top/bottom/common */ - resultlen = ucol_getSortKey(coll, tertstr, 150, (uint8_t *)result, 250); - tempptr = uprv_strrchr(result, 1) + 1; + resultlen = ucol_getSortKey(coll, tertstr, 150, result, UPRV_LENGTHOF(result)); + tempptr = (uint8_t *)uprv_strrchr((char *)result, 1) + 1; while (*(tempptr + 1) != 0) { /* the last secondary collation element is not checked since it is not part of the compression */ - if (*tempptr > coll->tertiaryBottom + coll->tertiaryBottomCount) { - log_err("Tertiary compression overlapped\n"); + if (*tempptr > TER_ONLY_COMMON_MIDDLE) { + log_err("Tertiary bottom up compression overlapped\n"); } tempptr ++; } @@ -2646,13 +1366,17 @@ static void TestCyrillicTailoring(void) { /* Russian overrides contractions, so this test is not valid anymore */ /*genericLocaleStarter("ru", test, 3);*/ - genericLocaleStarter("root", test, 3); - genericRulesStarter("&\\u0410 = \\u0410", test, 3); - genericRulesStarter("&Z < \\u0410", test, 3); + // Most of the following are commented out because UCA 8.0 + // drops most of the Cyrillic contractions from the default order. + // See CLDR ticket #7246 "root collation: remove Cyrillic contractions". + + // genericLocaleStarter("root", test, 3); + // genericRulesStarter("&\\u0410 = \\u0410", test, 3); + // genericRulesStarter("&Z < \\u0410", test, 3); genericRulesStarter("&\\u0410 = \\u0410 < \\u04d0", test, 3); genericRulesStarter("&Z < \\u0410 < \\u04d0", test, 3); - genericRulesStarter("&\\u0410 = \\u0410 < \\u0410\\u0301", test, 3); - genericRulesStarter("&Z < \\u0410 < \\u0410\\u0301", test, 3); + // genericRulesStarter("&\\u0410 = \\u0410 < \\u0410\\u0301", test, 3); + // genericRulesStarter("&Z < \\u0410 < \\u0410\\u0301", test, 3); } static void TestSuppressContractions(void) { @@ -2688,6 +1412,13 @@ static void TestContraction(void) { {0x0063 /* 'c' */, 0x0068 /* 'h' */}, {0x0063 /* 'c' */, 0x006C /* 'l' */} }; +#if 0 + /* + * These pairs of rule strings are not guaranteed to yield the very same mappings. + * In fact, LDML 24 recommends an improved way of creating mappings + * which always yields different mappings for such pairs. See + * http://www.unicode.org/reports/tr35/tr35-33/tr35-collation.html#Orderings + */ const static char *testrules3[] = { "&z < xyz &xyzw << B", "&z < xyz &xyz << B / w", @@ -2698,6 +1429,7 @@ static void TestContraction(void) { "&a\\ud800\\udc00m << B", "&a << B / \\ud800\\udc00m", }; +#endif UErrorCode status = U_ZERO_ERROR; UCollator *coll; @@ -2705,7 +1437,7 @@ static void TestContraction(void) { uint32_t rlen = 0; int i; - for (i = 0; i < sizeof(testrules) / sizeof(testrules[0]); i ++) { + for (i = 0; i < UPRV_LENGTHOF(testrules); i ++) { UCollationElements *iter1; int j = 0; log_verbose("Rule %s for testing\n", testrules[i]); @@ -2724,14 +1456,14 @@ static void TestContraction(void) { UCollationElements *iter2 = ucol_openElements(coll, &(testdata[i][j]), 1, &status); - uint32_t ce; + int32_t ce; if (U_FAILURE(status)) { log_err("Collation iterator creation failed\n"); return; } ce = ucol_next(iter2, &status); while (ce != UCOL_NULLORDER) { - if ((uint32_t)ucol_next(iter1, &status) != ce) { + if (ucol_next(iter1, &status) != ce) { log_err("Collation elements in contraction split does not match\n"); return; } @@ -2763,8 +1495,9 @@ static void TestContraction(void) { return; } ucol_close(coll); - - for (i = 0; i < sizeof(testrules3) / sizeof(testrules3[0]); i += 2) { +#if 0 /* see above */ + for (i = 0; i < UPRV_LENGTHOF(testrules3); i += 2) { + log_verbose("testrules3 i==%d \"%s\" vs. \"%s\"\n", i, testrules3[i], testrules3[i + 1]); UCollator *coll1, *coll2; UCollationElements *iter1, @@ -2791,8 +1524,11 @@ static void TestContraction(void) { return; } while (ce != UCOL_NULLORDER) { - if (ce != (uint32_t)ucol_next(iter2, &status)) { - log_err("CEs does not match\n"); + uint32_t ce2 = (uint32_t)ucol_next(iter2, &status); + if (ce == ce2) { + log_verbose("CEs match: %08x\n", ce); + } else { + log_err("CEs do not match: %08x vs. %08x\n", ce, ce2); return; } ce = ucol_next(iter1, &status); @@ -2810,11 +1546,23 @@ static void TestContraction(void) { ucol_close(coll1); ucol_close(coll2); } +#endif } static void TestExpansion(void) { const static char *testrules[] = { +#if 0 + /* + * This seems to have tested that M was not mapped to an expansion. + * I believe the old builder just did that because it computed the extension CEs + * at the very end, which was a bug. + * Among other problems, it violated the core tailoring principle + * by making an earlier rule depend on a later one. + * And, of course, if M did not get an expansion, then it was primary different from K, + * unlike what the rule &K< %08x\n", varTopOriginal); + ucol_setAttribute(coll, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &status); - if(getTestOption(QUICK_OPTION) <= 0) { - setTestOption(QUICK_OPTION, 1); + varTop1 = ucol_setVariableTop(coll, &space, 1, &status); + varTop2 = ucol_getVariableTop(coll, &status); + log_verbose("ucol_setVariableTop(space) -> %08x\n", varTop1); + if(U_FAILURE(status) || varTop1 != varTop2 || + !ucol_equal(coll, &nul, 0, &space, 1) || + ucol_equal(coll, &nul, 0, &dot, 1) || + ucol_equal(coll, &nul, 0, °ree, 1) || + ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, &space, 1, &dot, 1)) { + log_err("ucol_setVariableTop(space) did not work - %s\n", u_errorName(status)); } - /* this test will fail when normalization is turned on */ - /* therefore we always turn off exhaustive mode for it */ - { /* QUICK > 0*/ - log_verbose("Slide variable top over UCARules\n"); - rulesLen = ucol_getRulesEx(coll, UCOL_FULL_RULES, rulesCopy, 0); - rulesCopy = (UChar *)uprv_malloc((rulesLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); - rulesLen = ucol_getRulesEx(coll, UCOL_FULL_RULES, rulesCopy, rulesLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE); - - if(U_SUCCESS(status) && rulesLen > 0) { - ucol_setAttribute(coll, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &status); - src.current = src.source = rulesCopy; - src.end = rulesCopy+rulesLen; - src.extraCurrent = src.end; - src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; - - /* Note that as a result of tickets 7015 or 6912, ucol_tok_parseNextToken can cause the pointer to - the rules copy in src.source to get reallocated, freeing the original pointer in rulesCopy */ - while ((current = ucol_tok_parseNextToken(&src, startOfRules, &parseError,&status)) != NULL) { - strength = src.parsedToken.strength; - chOffset = src.parsedToken.charsOffset; - chLen = src.parsedToken.charsLen; - exOffset = src.parsedToken.extensionOffset; - exLen = src.parsedToken.extensionLen; - prefixOffset = src.parsedToken.prefixOffset; - prefixLen = src.parsedToken.prefixLen; - specs = src.parsedToken.flags; - - startOfRules = FALSE; - { - log_verbose("%04X %d ", *(src.source+chOffset), chLen); - } - if(strength == UCOL_PRIMARY) { - status = U_ZERO_ERROR; - varTopOriginal = ucol_getVariableTop(coll, &status); - varTop1 = ucol_setVariableTop(coll, src.source+oldChOffset, oldChLen, &status); - if(U_FAILURE(status)) { - char buffer[256]; - char *buf = buffer; - uint32_t i = 0, j; - uint32_t CE = UCOL_NO_MORE_CES; - - /* before we start screaming, let's see if there is a problem with the rules */ - UErrorCode collIterateStatus = U_ZERO_ERROR; - collIterate *s = uprv_new_collIterate(&collIterateStatus); - uprv_init_collIterate(coll, src.source+oldChOffset, oldChLen, s, &collIterateStatus); - - CE = ucol_getNextCE(coll, s, &status); - - for(i = 0; i < oldChLen; i++) { - j = sprintf(buf, "%04X ", *(src.source+oldChOffset+i)); - buf += j; - } - if(status == U_PRIMARY_TOO_LONG_ERROR) { - log_verbose("= Expected failure for %s =", buffer); - } else { - if(uprv_collIterateAtEnd(s)) { - log_err("Unexpected failure setting variable top at offset %d. Error %s. Codepoints: %s\n", - oldChOffset, u_errorName(status), buffer); - } else { - log_verbose("There is a goofy contraction in UCA rules that does not appear in the fractional UCA. Codepoints: %s\n", - buffer); - } - } - uprv_delete_collIterate(s); - } - varTop2 = ucol_getVariableTop(coll, &status); - if((varTop1 & 0xFFFF0000) != (varTop2 & 0xFFFF0000)) { - log_err("cannot retrieve set varTop value!\n"); - continue; - } + varTop1 = ucol_setVariableTop(coll, &dot, 1, &status); + varTop2 = ucol_getVariableTop(coll, &status); + log_verbose("ucol_setVariableTop(dot) -> %08x\n", varTop1); + if(U_FAILURE(status) || varTop1 != varTop2 || + !ucol_equal(coll, &nul, 0, &space, 1) || + !ucol_equal(coll, &nul, 0, &dot, 1) || + ucol_equal(coll, &nul, 0, °ree, 1) || + ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, &dot, 1, °ree, 1)) { + log_err("ucol_setVariableTop(dot) did not work - %s\n", u_errorName(status)); + } - if((varTop1 & 0xFFFF0000) > 0 && oldExLen == 0) { - - u_strncpy(first, src.source+oldChOffset, oldChLen); - u_strncpy(first+oldChLen, src.source+chOffset, chLen); - u_strncpy(first+oldChLen+chLen, src.source+oldChOffset, oldChLen); - first[2*oldChLen+chLen] = 0; - - if(oldExLen == 0) { - u_strncpy(second, src.source+chOffset, chLen); - second[chLen] = 0; - } else { /* This is skipped momentarily, but should work once UCARules are fully UCA conformant */ - u_strncpy(second, src.source+oldExOffset, oldExLen); - u_strncpy(second+oldChLen, src.source+chOffset, chLen); - u_strncpy(second+oldChLen+chLen, src.source+oldExOffset, oldExLen); - second[2*oldExLen+chLen] = 0; - } - result = ucol_strcoll(coll, first, -1, second, -1); - if(result == UCOL_EQUAL) { - doTest(coll, first, second, UCOL_EQUAL); - } else { - log_verbose("Suspicious strcoll result for %04X and %04X\n", *(src.source+oldChOffset), *(src.source+chOffset)); - } - } - } - if(strength != UCOL_TOK_RESET) { - oldChOffset = chOffset; - oldChLen = chLen; - oldExOffset = exOffset; - oldExLen = exLen; - } - } - status = U_ZERO_ERROR; - } - else { - log_err("Unexpected failure getting rules %s\n", u_errorName(status)); - return; - } - if (U_FAILURE(status)) { - log_err("Error parsing rules %s\n", u_errorName(status)); - return; - } - status = U_ZERO_ERROR; + varTop1 = ucol_setVariableTop(coll, °ree, 1, &status); + varTop2 = ucol_getVariableTop(coll, &status); + log_verbose("ucol_setVariableTop(degree) -> %08x\n", varTop1); + if(U_FAILURE(status) || varTop1 != varTop2 || + !ucol_equal(coll, &nul, 0, &space, 1) || + !ucol_equal(coll, &nul, 0, &dot, 1) || + !ucol_equal(coll, &nul, 0, °ree, 1) || + ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, °ree, 1, &dollar, 1)) { + log_err("ucol_setVariableTop(degree) did not work - %s\n", u_errorName(status)); } - setTestOption(QUICK_OPTION, myQ); + varTop1 = ucol_setVariableTop(coll, &dollar, 1, &status); + varTop2 = ucol_getVariableTop(coll, &status); + log_verbose("ucol_setVariableTop(dollar) -> %08x\n", varTop1); + if(U_FAILURE(status) || varTop1 != varTop2 || + !ucol_equal(coll, &nul, 0, &space, 1) || + !ucol_equal(coll, &nul, 0, &dot, 1) || + !ucol_equal(coll, &nul, 0, °ree, 1) || + !ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, &dollar, 1, &zero, 1)) { + log_err("ucol_setVariableTop(dollar) did not work - %s\n", u_errorName(status)); + } log_verbose("Testing setting variable top to contractions\n"); { - UChar *conts = (UChar *)((uint8_t *)coll->image + coll->image->contractionUCACombos); - int32_t maxUCAContractionLength = coll->image->contractionUCACombosWidth; - while(*conts != 0) { - /* - * A continuation is NUL-terminated and NUL-padded - * except if it has the maximum length. - */ - int32_t contractionLength = maxUCAContractionLength; - while(contractionLength > 0 && conts[contractionLength - 1] == 0) { - --contractionLength; - } - if(*(conts+1)==0) { /* pre-context */ - varTop1 = ucol_setVariableTop(coll, conts, 1, &status); - } else { - varTop1 = ucol_setVariableTop(coll, conts, contractionLength, &status); - } - if(U_FAILURE(status)) { - if(status == U_PRIMARY_TOO_LONG_ERROR) { - /* ucol_setVariableTop() is documented to not accept 3-byte primaries, - * therefore it is not an error when it complains about them. */ - log_verbose("Couldn't set variable top to a contraction %04X %04X %04X - U_PRIMARY_TOO_LONG_ERROR\n", - *conts, *(conts+1), *(conts+2)); - } else { - log_err("Couldn't set variable top to a contraction %04X %04X %04X - %s\n", - *conts, *(conts+1), *(conts+2), u_errorName(status)); - } - status = U_ZERO_ERROR; - } - conts+=maxUCAContractionLength; - } - - status = U_ZERO_ERROR; - + UChar first[4] = { 0 }; first[0] = 0x0040; first[1] = 0x0050; first[2] = 0x0000; + status = U_ZERO_ERROR; ucol_setVariableTop(coll, first, -1, &status); if(U_SUCCESS(status)) { @@ -3178,21 +1806,110 @@ static void TestVariableTopSetting(void) { log_verbose("Testing calling with error set\n"); status = U_INTERNAL_PROGRAM_ERROR; - varTop1 = ucol_setVariableTop(coll, first, 1, &status); + varTop1 = ucol_setVariableTop(coll, &space, 1, &status); varTop2 = ucol_getVariableTop(coll, &status); ucol_restoreVariableTop(coll, varTop2, &status); - varTop1 = ucol_setVariableTop(NULL, first, 1, &status); + varTop1 = ucol_setVariableTop(NULL, &dot, 1, &status); varTop2 = ucol_getVariableTop(NULL, &status); ucol_restoreVariableTop(NULL, varTop2, &status); if(status != U_INTERNAL_PROGRAM_ERROR) { log_err("Bad reaction to passed error!\n"); } - uprv_free(src.source); ucol_close(coll); } else { log_data_err("Couldn't open UCA collator\n"); } +} + +static void TestMaxVariable(void) { + UErrorCode status = U_ZERO_ERROR; + UColReorderCode oldMax, max; + UCollator *coll; + + static const UChar nul = 0; + static const UChar space = 0x20; + static const UChar dot = 0x2e; /* punctuation */ + static const UChar degree = 0xb0; /* symbol */ + static const UChar dollar = 0x24; /* currency symbol */ + static const UChar zero = 0x30; /* digit */ + + coll = ucol_open("", &status); + if(U_FAILURE(status)) { + log_data_err("Couldn't open root collator\n"); + return; + } + + oldMax = ucol_getMaxVariable(coll); + log_verbose("ucol_getMaxVariable(root) -> %04x\n", oldMax); + ucol_setAttribute(coll, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &status); + + ucol_setMaxVariable(coll, UCOL_REORDER_CODE_SPACE, &status); + max = ucol_getMaxVariable(coll); + log_verbose("ucol_setMaxVariable(space) -> %04x\n", max); + if(U_FAILURE(status) || max != UCOL_REORDER_CODE_SPACE || + !ucol_equal(coll, &nul, 0, &space, 1) || + ucol_equal(coll, &nul, 0, &dot, 1) || + ucol_equal(coll, &nul, 0, °ree, 1) || + ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, &space, 1, &dot, 1)) { + log_err("ucol_setMaxVariable(space) did not work - %s\n", u_errorName(status)); + } + ucol_setMaxVariable(coll, UCOL_REORDER_CODE_PUNCTUATION, &status); + max = ucol_getMaxVariable(coll); + log_verbose("ucol_setMaxVariable(punctuation) -> %04x\n", max); + if(U_FAILURE(status) || max != UCOL_REORDER_CODE_PUNCTUATION || + !ucol_equal(coll, &nul, 0, &space, 1) || + !ucol_equal(coll, &nul, 0, &dot, 1) || + ucol_equal(coll, &nul, 0, °ree, 1) || + ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, &dot, 1, °ree, 1)) { + log_err("ucol_setMaxVariable(punctuation) did not work - %s\n", u_errorName(status)); + } + + ucol_setMaxVariable(coll, UCOL_REORDER_CODE_SYMBOL, &status); + max = ucol_getMaxVariable(coll); + log_verbose("ucol_setMaxVariable(symbol) -> %04x\n", max); + if(U_FAILURE(status) || max != UCOL_REORDER_CODE_SYMBOL || + !ucol_equal(coll, &nul, 0, &space, 1) || + !ucol_equal(coll, &nul, 0, &dot, 1) || + !ucol_equal(coll, &nul, 0, °ree, 1) || + ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, °ree, 1, &dollar, 1)) { + log_err("ucol_setMaxVariable(symbol) did not work - %s\n", u_errorName(status)); + } + + ucol_setMaxVariable(coll, UCOL_REORDER_CODE_CURRENCY, &status); + max = ucol_getMaxVariable(coll); + log_verbose("ucol_setMaxVariable(currency) -> %04x\n", max); + if(U_FAILURE(status) || max != UCOL_REORDER_CODE_CURRENCY || + !ucol_equal(coll, &nul, 0, &space, 1) || + !ucol_equal(coll, &nul, 0, &dot, 1) || + !ucol_equal(coll, &nul, 0, °ree, 1) || + !ucol_equal(coll, &nul, 0, &dollar, 1) || + ucol_equal(coll, &nul, 0, &zero, 1) || + ucol_greaterOrEqual(coll, &dollar, 1, &zero, 1)) { + log_err("ucol_setMaxVariable(currency) did not work - %s\n", u_errorName(status)); + } + + log_verbose("Test restoring maxVariable\n"); + status = U_ZERO_ERROR; + ucol_setMaxVariable(coll, oldMax, &status); + if(oldMax != ucol_getMaxVariable(coll)) { + log_err("Couldn't restore old maxVariable\n"); + } + + log_verbose("Testing calling with error set\n"); + status = U_INTERNAL_PROGRAM_ERROR; + ucol_setMaxVariable(coll, UCOL_REORDER_CODE_SPACE, &status); + max = ucol_getMaxVariable(coll); + if(max != oldMax || status != U_INTERNAL_PROGRAM_ERROR) { + log_err("Bad reaction to passed error!\n"); + } + ucol_close(coll); } static void TestNonChars(void) { @@ -3327,7 +2044,7 @@ static void TestPrefix(void) { }; - for(i = 0; i<(sizeof(tests)/sizeof(tests[0])); i++) { + for(i = 0; i= 0 && i <= TST_UCOL_MAX_INPUT) { - log_verbose("%08X\t%08X\n", i, uprv_uca_getImplicitFromRaw(i)); - } -} - -static void TestImplicitGeneration(void) { - UErrorCode status = U_ZERO_ERROR; - UChar32 last = 0; - UChar32 current; - UChar32 i = 0, j = 0; - UChar32 roundtrip = 0; - UChar32 lastBottom = 0; - UChar32 currentBottom = 0; - UChar32 lastTop = 0; - UChar32 currentTop = 0; - - UCollator *coll = ucol_open("root", &status); - if(U_FAILURE(status)) { - log_err_status(status, "Couldn't open UCA -> %s\n", u_errorName(status)); - return; - } - - uprv_uca_getRawFromImplicit(0xE20303E7); - - for (i = 0; i <= TST_UCOL_MAX_INPUT; ++i) { - current = uprv_uca_getImplicitFromRaw(i) & fourBytes; - - /* check that it round-trips AND that all intervening ones are illegal*/ - roundtrip = uprv_uca_getRawFromImplicit(current); - if (roundtrip != i) { - log_err("No roundtrip %08X\n", i); - } - if (last != 0) { - for (j = last + 1; j < current; ++j) { - roundtrip = uprv_uca_getRawFromImplicit(j); - /* raise an error if it *doesn't* find an error*/ - if (roundtrip != -1) { - log_err("Fails to recognize illegal %08X\n", j); - } - } - } - /* now do other consistency checks*/ - lastBottom = last & bottomByte; - currentBottom = current & bottomByte; - lastTop = last & topByte; - currentTop = current & topByte; - - /* print out some values for spot-checking*/ - if (lastTop != currentTop || i == 0x10000 || i == 0x110000) { - showImplicit(i-3); - showImplicit(i-2); - showImplicit(i-1); - showImplicit(i); - showImplicit(i+1); - showImplicit(i+2); - } - last = current; - - if(uprv_uca_getCodePointFromRaw(uprv_uca_getRawFromCodePoint(i)) != i) { - log_err("No raw <-> code point roundtrip for 0x%08X\n", i); - } - } - showImplicit(TST_UCOL_MAX_INPUT-2); - showImplicit(TST_UCOL_MAX_INPUT-1); - showImplicit(TST_UCOL_MAX_INPUT); - ucol_close(coll); + genericLocaleStarter("zh__PINYIN", test, UPRV_LENGTHOF(test)); } /** @@ -4518,7 +3170,8 @@ static void TestSeparateTrees(void) { if (e != NULL) { assertSuccess("ucol_openAvailableLocales", &ec); assertTrue("ucol_openAvailableLocales!=0", e!=0); - n = checkUEnumeration("ucol_openAvailableLocales", e, AVAIL, LEN(AVAIL)); + n = checkUEnumeration("ucol_openAvailableLocales", e, AVAIL, UPRV_LENGTHOF(AVAIL)); + (void)n; /* Suppress set but not used warnings. */ /* Don't need to check n because we check list */ uenum_close(e); } else { @@ -4530,7 +3183,7 @@ static void TestSeparateTrees(void) { if (e != NULL) { assertSuccess("ucol_getKeywords", &ec); assertTrue("ucol_getKeywords!=0", e!=0); - n = checkUEnumeration("ucol_getKeywords", e, KW, LEN(KW)); + n = checkUEnumeration("ucol_getKeywords", e, KW, UPRV_LENGTHOF(KW)); /* Don't need to check n because we check list */ uenum_close(e); } else { @@ -4541,7 +3194,7 @@ static void TestSeparateTrees(void) { if (e != NULL) { assertSuccess("ucol_getKeywordValues", &ec); assertTrue("ucol_getKeywordValues!=0", e!=0); - n = checkUEnumeration("ucol_getKeywordValues", e, KWVAL, LEN(KWVAL)); + n = checkUEnumeration("ucol_getKeywordValues", e, KWVAL, UPRV_LENGTHOF(KWVAL)); /* Don't need to check n because we check list */ uenum_close(e); } else { @@ -4553,7 +3206,7 @@ static void TestSeparateTrees(void) { e = ucol_getKeywordValues(KW[0], &ec); if (assertSuccess("ucol_getKeywordValues [with warning code set]", &ec)) { assertTrue("ucol_getKeywordValues!=0 [with warning code set]", e!=0); - n = checkUEnumeration("ucol_getKeywordValues [with warning code set]", e, KWVAL, LEN(KWVAL)); + n = checkUEnumeration("ucol_getKeywordValues [with warning code set]", e, KWVAL, UPRV_LENGTHOF(KWVAL)); /* Don't need to check n because we check list */ uenum_close(e); } @@ -4568,7 +3221,7 @@ ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity, n = ucol_getFunctionalEquivalent(loc, sizeof(loc), "collation", "de", &isAvailable, &ec); if (assertSuccess("getFunctionalEquivalent", &ec)) { - assertEquals("getFunctionalEquivalent(de)", "de", loc); + assertEquals("getFunctionalEquivalent(de)", "root", loc); assertTrue("getFunctionalEquivalent(de).isAvailable==TRUE", isAvailable == TRUE); } @@ -4576,9 +3229,9 @@ ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity, n = ucol_getFunctionalEquivalent(loc, sizeof(loc), "collation", "de_DE", &isAvailable, &ec); if (assertSuccess("getFunctionalEquivalent", &ec)) { - assertEquals("getFunctionalEquivalent(de_DE)", "de", loc); - assertTrue("getFunctionalEquivalent(de_DE).isAvailable==TRUE", - isAvailable == TRUE); + assertEquals("getFunctionalEquivalent(de_DE)", "root", loc); + assertTrue("getFunctionalEquivalent(de_DE).isAvailable==FALSE", + isAvailable == FALSE); } } @@ -4637,10 +3290,19 @@ static void TestBeforePinyin(void) { "xAx" }; - genericRulesStarter(rules, test, sizeof(test)/sizeof(test[0])); - genericLocaleStarter("zh", test, sizeof(test)/sizeof(test[0])); - genericRulesStarter(rules, test2, sizeof(test2)/sizeof(test2[0])); - genericLocaleStarter("zh", test2, sizeof(test2)/sizeof(test2[0])); + const static char *test3[] = { // rdar://53741390 + "\\u85CF", // 藏 cáng + "\\u92BA", // 銺 zàng + "\\u85CF\\u6587", // 藏文 zàngwén + "\\u85CF\\u8BED", // 藏语 zàngyǔ + "\\u81D3", // 臓 zàng + }; + + genericRulesStarter(rules, test, UPRV_LENGTHOF(test)); + genericLocaleStarter("zh", test, UPRV_LENGTHOF(test)); + genericRulesStarter(rules, test2, UPRV_LENGTHOF(test2)); + genericLocaleStarter("zh", test2, UPRV_LENGTHOF(test2)); + genericLocaleStarter("zh", test3, UPRV_LENGTHOF(test3)); } static void TestBeforeTightening(void) { @@ -4672,7 +3334,7 @@ static void TestBeforeTightening(void) { UCollator *coll = NULL; - for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { + for(i = 0; i < UPRV_LENGTHOF(tests); i++) { rlen = u_unescape(tests[i].rules, rlz, RULE_BUFFER_LEN); coll = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT,NULL, &status); if(status != tests[i].expectedStatus) { @@ -4788,7 +3450,7 @@ static void TestMoreBefore(void) { int32_t i = 0; - for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) { + for(i = 0; i < UPRV_LENGTHOF(tests); i++) { genericRulesStarter(tests[i].rules, tests[i].order, tests[i].size); } } @@ -4827,7 +3489,7 @@ TestUpperFirstQuaternary(void) const char* tests[] = { "B", "b", "Bb", "bB" }; UColAttribute att[] = { UCOL_STRENGTH, UCOL_CASE_FIRST }; UColAttributeValue attVals[] = { UCOL_QUATERNARY, UCOL_UPPER_FIRST }; - genericLocaleStarterWithOptions("root", tests, sizeof(tests)/sizeof(tests[0]), att, attVals, sizeof(att)/sizeof(att[0])); + genericLocaleStarterWithOptions("root", tests, UPRV_LENGTHOF(tests), att, attVals, UPRV_LENGTHOF(att)); } static void @@ -4842,12 +3504,12 @@ TestJ4960(void) UColAttributeValue attVals2[] = { UCOL_ON }; /* Test whether we correctly ignore primary ignorables on case level when */ /* we have only primary & case level */ - genericLocaleStarterWithOptionsAndResult("root", tests, sizeof(tests)/sizeof(tests[0]), att, attVals, sizeof(att)/sizeof(att[0]), UCOL_EQUAL); + genericLocaleStarterWithOptionsAndResult("root", tests, UPRV_LENGTHOF(tests), att, attVals, UPRV_LENGTHOF(att), UCOL_EQUAL); /* Test whether ICU4J will make case level for sortkeys that have primary strength */ /* and case level */ - genericLocaleStarterWithOptions("root", tests2, sizeof(tests2)/sizeof(tests2[0]), att, attVals, sizeof(att)/sizeof(att[0])); + genericLocaleStarterWithOptions("root", tests2, UPRV_LENGTHOF(tests2), att, attVals, UPRV_LENGTHOF(att)); /* Test whether completely ignorable letters have case level info (they shouldn't) */ - genericRulesStarterWithOptionsAndResult(rule, tests2, sizeof(tests2)/sizeof(tests2[0]), att2, attVals2, sizeof(att2)/sizeof(att2[0]), UCOL_EQUAL); + genericRulesStarterWithOptionsAndResult(rule, tests2, UPRV_LENGTHOF(tests2), att2, attVals2, UPRV_LENGTHOF(att2), UCOL_EQUAL); } static void @@ -4911,7 +3573,7 @@ TestJ5232(void) "\\u0e40\\u0e01\\u0e47\\u0e1a\\u0e40\\u0e25\\u0e48\\u0e21" }; - genericLocaleStarter("th", test, sizeof(test)/sizeof(test[0])); + genericLocaleStarter("th", test, UPRV_LENGTHOF(test)); } static void @@ -4919,7 +3581,7 @@ TestJ5367(void) { const static char *test[] = { "a", "y" }; const char* rules = "&Ny << Y &[first secondary ignorable] <<< a"; - genericRulesStarter(rules, test, sizeof(test)/sizeof(test[0])); + genericRulesStarter(rules, test, UPRV_LENGTHOF(test)); } static void @@ -4930,9 +3592,20 @@ TestVI5913(void) UCollator *coll =NULL; uint8_t resColl[100], expColl[100]; int32_t rLen, tLen, ruleLen, sLen, kLen; - UChar rule[256]={0x26, 0x62, 0x3c, 0x1FF3, 0}; /* &a<0x1FF3-omega with Ypogegrammeni*/ + UChar rule[256]={0x26, 0x62, 0x3c, 0x1FF3, 0}; /* &b<0x1FF3-omega with Ypogegrammeni*/ UChar rule2[256]={0x26, 0x7a, 0x3c, 0x0161, 0}; /* &z %s\n", u_errorName(status)); + log_info(" offset=%d \"%s\" | \"%s\"\n", + parseError.offset, aescstrdup(parseError.preContext, -1), aescstrdup(parseError.postContext, -1)); return; } tLen = u_strlen(tData2[0]); rLen = ucol_getSortKey(coll, tData2[0], tLen, resColl, 100); - if (rLen != LEN(lastSecondaryIgnCE) || uprv_memcmp(resColl, lastSecondaryIgnCE, rLen) != 0) { + if (rLen != UPRV_LENGTHOF(lastSecondaryIgnCE) || uprv_memcmp(resColl, lastSecondaryIgnCE, rLen) != 0) { log_err("Bad result for &[lsi]<<