/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2011, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
}
U16_APPEND(supplementary, stringOffset, 2, unassigned, isError);
+ (void)isError; /* Suppress set but not used warning. */
ucol_setText(iter, supplementary, 2, &status);
sorder = ucol_previous(iter, &status);
return result;
}
+static const UChar IMPORT[] = { 0x5B, 0x69, 0x6D, 0x70, 0x6F, 0x72, 0x74, 0 }; /* "[import" */
+
static void TestCEValidity()
{
/* testing UCA collation elements */
UColTokenParser src;
uint32_t strength = 0;
uint16_t specs = 0;
+
+ (void)specs; /* Suppress set but not used warnings. */
+ (void)strength;
+ (void)prefixLen;
+ (void)prefixOffset;
+ (void)exLen;
+ (void)exOffset;
+
if(getTestOption(QUICK_OPTION)) {
loc = locale[count];
} else {
continue;
}
}
+ status = U_ZERO_ERROR; // clear status from previous loop iteration
uprv_memset(&src, 0, sizeof(UColTokenParser));
coll = ucol_open(loc, &status);
if (U_FAILURE(status)) {
- log_err("%s collator creation failed\n", loc);
+ log_err("%s collator creation failed with status %s\n", loc, u_errorName(status));
return;
}
src.opts = &opts;
rules = ucol_getRules(coll, &ruleLen);
- if (ruleLen > 0) {
+ /*
+ * We have not set up the UColTokenParser with a callback function
+ * to fetch [import] sub-rules,
+ * so skip testing tailorings that import others.
+ * TODO: Ticket #8047: Change TestCEValidity to use ucol_getTailoredSet()
+ * rather than the internal collation rule parser
+ */
+ if (ruleLen > 0 && u_strstr(rules, IMPORT) == NULL) {
rulesCopy = (UChar *)uprv_malloc((ruleLen +
UCOL_TOK_EXTRA_RULE_SPACE_SIZE) * sizeof(UChar));
uprv_memcpy(rulesCopy, rules, ruleLen * sizeof(UChar));
/* 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) {
+ while ((current = ucol_tok_parseNextToken(&src, startOfRules, &parseError,&status)) != NULL && U_SUCCESS(status)) {
strength = src.parsedToken.strength;
chOffset = src.parsedToken.charsOffset;
chLen = src.parsedToken.charsLen;
codepoints[chLen] = 0;
checkCEValidity(coll, codepoints, chLen);
}
+ if (U_FAILURE(status)) {
+ log_err("%s collator, ucol_tok_parseNextToken failed with status %s\n", loc, u_errorName(status));
+ }
uprv_free(src.source);
+ uprv_free(src.reorderCodes);
}
ucol_close(coll);
UColTokenParser src;
uint32_t strength = 0;
uint16_t specs = 0;
+ status = U_ZERO_ERROR; // clear status from previous loop iteration
+
+ (void)specs;
+ (void)strength;
+ (void)prefixLen;
+ (void)prefixOffset;
+ (void)exLen;
+ (void)exOffset;
uprv_memset(&src, 0, sizeof(UColTokenParser));
coll = ucol_open(locale[count], &status);
if (U_FAILURE(status)) {
- log_err("%s collator creation failed\n", locale[count]);
+ log_err("%s collator creation failed with status %s\n", locale[count], u_errorName(status));
return;
}
src.opts = &opts;
rules = ucol_getRules(coll, &ruleLen);
- if (ruleLen > 0) {
+ /*
+ * We have not set up the UColTokenParser with a callback function
+ * to fetch [import] sub-rules,
+ * so skip testing tailorings that import others.
+ * TODO: Ticket #8047: Change TestSortKeyValidity to use ucol_getTailoredSet()
+ * rather than the internal collation rule parser
+ */
+ if (ruleLen > 0 && u_strstr(rules, IMPORT) == NULL) {
rulesCopy = (UChar *)uprv_malloc((ruleLen +
UCOL_TOK_EXTRA_RULE_SPACE_SIZE) * sizeof(UChar));
uprv_memcpy(rulesCopy, rules, ruleLen * sizeof(UChar));
/* 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) {
+ while ((current = ucol_tok_parseNextToken(&src, startOfRules,&parseError, &status)) != NULL && U_SUCCESS(status)) {
strength = src.parsedToken.strength;
chOffset = src.parsedToken.charsOffset;
chLen = src.parsedToken.charsLen;
}
checkSortKeyValidity(coll, codepoints, chLen);
}
+ if (U_FAILURE(status)) {
+ log_err("%s collator, ucol_tok_parseNextToken failed with status %s\n", locale[count], u_errorName(status));
+ }
uprv_free(src.source);
+ uprv_free(src.reorderCodes);
}
ucol_close(coll);
}
ucol_close(ucol);
} else {
- log_err("error, locale %s, ucol_open failed: %s\n", tsceItemPtr->locale, u_errorName(status) );
+ log_data_err("error, locale %s, ucol_open failed: %s\n", tsceItemPtr->locale, u_errorName(status) );
}
}
}