#define INCLUDED_FROM_UCASE_CPP
#include "ucase_props_data.h"
-/* UCaseProps singleton ----------------------------------------------------- */
-
-U_CAPI const UCaseProps * U_EXPORT2
-ucase_getSingleton() {
- return &ucase_props_singleton;
-}
-
/* set of property starts for UnicodeSet ------------------------------------ */
static UBool U_CALLCONV
}
U_CFUNC void U_EXPORT2
-ucase_addPropertyStarts(const UCaseProps * /* unused csp */, const USetAdder *sa, UErrorCode *pErrorCode) {
+ucase_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return;
}
/* simple case mappings ----------------------------------------------------- */
U_CAPI UChar32 U_EXPORT2
-ucase_tolower(const UCaseProps * /* unused csp */, UChar32 c) {
+ucase_tolower(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
if(!PROPS_HAS_EXCEPTION(props)) {
if(UCASE_GET_TYPE(props)>=UCASE_UPPER) {
}
U_CAPI UChar32 U_EXPORT2
-ucase_toupper(const UCaseProps * /* unused csp */, UChar32 c) {
+ucase_toupper(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
if(!PROPS_HAS_EXCEPTION(props)) {
if(UCASE_GET_TYPE(props)==UCASE_LOWER) {
}
U_CAPI UChar32 U_EXPORT2
-ucase_totitle(const UCaseProps * /* unused csp */, UChar32 c) {
+ucase_totitle(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
if(!PROPS_HAS_EXCEPTION(props)) {
if(UCASE_GET_TYPE(props)==UCASE_LOWER) {
U_CFUNC void U_EXPORT2
-ucase_addCaseClosure(const UCaseProps * /* unused csp */, UChar32 c, const USetAdder *sa) {
+ucase_addCaseClosure(UChar32 c, const USetAdder *sa) {
uint16_t props;
/*
}
U_CFUNC UBool U_EXPORT2
-ucase_addStringCaseClosure(const UCaseProps * /* unused csp */, const UChar *s, int32_t length, const USetAdder *sa) {
+ucase_addStringCaseClosure(const UChar *s, int32_t length, const USetAdder *sa) {
int32_t i, start, limit, result, unfoldRows, unfoldRowWidth, unfoldStringWidth;
if(ucase_props_singleton.unfold==NULL || s==NULL) {
for(i=unfoldStringWidth; i<unfoldRowWidth && p[i]!=0;) {
U16_NEXT_UNSAFE(p, i, c);
sa->add(sa->set, c);
- ucase_addCaseClosure(&ucase_props_singleton, c, sa);
+ ucase_addCaseClosure(c, sa);
}
return TRUE;
} else if(result<0) {
/** @return UCASE_NONE, UCASE_LOWER, UCASE_UPPER, UCASE_TITLE */
U_CAPI int32_t U_EXPORT2
-ucase_getType(const UCaseProps * /* unused csp */, UChar32 c) {
+ucase_getType(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
return UCASE_GET_TYPE(props);
}
/** @return same as ucase_getType() and set bit 2 if c is case-ignorable */
U_CAPI int32_t U_EXPORT2
-ucase_getTypeOrIgnorable(const UCaseProps * /* unused csp */, UChar32 c) {
+ucase_getTypeOrIgnorable(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
return UCASE_GET_TYPE_AND_IGNORABLE(props);
}
/** @return UCASE_NO_DOT, UCASE_SOFT_DOTTED, UCASE_ABOVE, UCASE_OTHER_ACCENT */
static inline int32_t
-getDotType(const UCaseProps * /* unused csp */, UChar32 c) {
+getDotType(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
if(!PROPS_HAS_EXCEPTION(props)) {
return props&UCASE_DOT_MASK;
}
U_CAPI UBool U_EXPORT2
-ucase_isSoftDotted(const UCaseProps * /* unused csp */, UChar32 c) {
- return (UBool)(getDotType(&ucase_props_singleton, c)==UCASE_SOFT_DOTTED);
+ucase_isSoftDotted(UChar32 c) {
+ return (UBool)(getDotType(c)==UCASE_SOFT_DOTTED);
}
U_CAPI UBool U_EXPORT2
-ucase_isCaseSensitive(const UCaseProps * /* unused csp */, UChar32 c) {
+ucase_isCaseSensitive(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
return (UBool)((props&UCASE_SENSITIVE)!=0);
}
* it is also cased or not.
*/
static UBool
-isFollowedByCasedLetter(const UCaseProps * /* unused csp */, UCaseContextIterator *iter, void *context, int8_t dir) {
+isFollowedByCasedLetter(UCaseContextIterator *iter, void *context, int8_t dir) {
UChar32 c;
if(iter==NULL) {
}
for(/* dir!=0 sets direction */; (c=iter(context, dir))>=0; dir=0) {
- int32_t type=ucase_getTypeOrIgnorable(&ucase_props_singleton, c);
+ int32_t type=ucase_getTypeOrIgnorable(c);
if(type&4) {
/* case-ignorable, continue with the loop */
} else if(type!=UCASE_NONE) {
/* Is preceded by Soft_Dotted character with no intervening cc=230 ? */
static UBool
-isPrecededBySoftDotted(const UCaseProps * /* unused csp */, UCaseContextIterator *iter, void *context) {
+isPrecededBySoftDotted(UCaseContextIterator *iter, void *context) {
UChar32 c;
int32_t dotType;
int8_t dir;
}
for(dir=-1; (c=iter(context, dir))>=0; dir=0) {
- dotType=getDotType(&ucase_props_singleton, c);
+ dotType=getDotType(c);
if(dotType==UCASE_SOFT_DOTTED) {
return TRUE; /* preceded by TYPE_i */
} else if(dotType!=UCASE_OTHER_ACCENT) {
/* Is preceded by base character 'I' with no intervening cc=230 ? */
static UBool
-isPrecededBy_I(const UCaseProps * /* unused csp */, UCaseContextIterator *iter, void *context) {
+isPrecededBy_I(UCaseContextIterator *iter, void *context) {
UChar32 c;
int32_t dotType;
int8_t dir;
if(c==0x49) {
return TRUE; /* preceded by I */
}
- dotType=getDotType(&ucase_props_singleton, c);
+ dotType=getDotType(c);
if(dotType!=UCASE_OTHER_ACCENT) {
return FALSE; /* preceded by different base character (not I), or intervening cc==230 */
}
/* Is followed by one or more cc==230 ? */
static UBool
-isFollowedByMoreAbove(const UCaseProps * /* unused csp */, UCaseContextIterator *iter, void *context) {
+isFollowedByMoreAbove(UCaseContextIterator *iter, void *context) {
UChar32 c;
int32_t dotType;
int8_t dir;
}
for(dir=1; (c=iter(context, dir))>=0; dir=0) {
- dotType=getDotType(&ucase_props_singleton, c);
+ dotType=getDotType(c);
if(dotType==UCASE_ABOVE) {
return TRUE; /* at least one cc==230 following */
} else if(dotType!=UCASE_OTHER_ACCENT) {
/* Is followed by a dot above (without cc==230 in between) ? */
static UBool
-isFollowedByDotAbove(const UCaseProps * /* unused csp */, UCaseContextIterator *iter, void *context) {
+isFollowedByDotAbove(UCaseContextIterator *iter, void *context) {
UChar32 c;
int32_t dotType;
int8_t dir;
if(c==0x307) {
return TRUE;
}
- dotType=getDotType(&ucase_props_singleton, c);
+ dotType=getDotType(c);
if(dotType!=UCASE_OTHER_ACCENT) {
return FALSE; /* next base character or cc==230 in between */
}
}
U_CAPI int32_t U_EXPORT2
-ucase_toFullLower(const UCaseProps * /* unused csp */, UChar32 c,
+ucase_toFullLower(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t loc) {
if( loc==UCASE_LOC_LITHUANIAN &&
/* base characters, find accents above */
(((c==0x49 || c==0x4a || c==0x12e) &&
- isFollowedByMoreAbove(&ucase_props_singleton, iter, context)) ||
+ isFollowedByMoreAbove(iter, context)) ||
/* precomposed with accent above, no need to find one */
(c==0xcc || c==0xcd || c==0x128))
) {
0130; 0069; 0130; 0130; az # LATIN CAPITAL LETTER I WITH DOT ABOVE
*/
return 0x69;
- } else if(loc==UCASE_LOC_TURKISH && c==0x307 && isPrecededBy_I(&ucase_props_singleton, iter, context)) {
+ } else if(loc==UCASE_LOC_TURKISH && c==0x307 && isPrecededBy_I(iter, context)) {
/*
# When lowercasing, remove dot_above in the sequence I + dot_above, which will turn into i.
# This matches the behavior of the canonically equivalent I-dot_above
0307; ; 0307; 0307; az After_I; # COMBINING DOT ABOVE
*/
return 0; /* remove the dot (continue without output) */
- } else if(loc==UCASE_LOC_TURKISH && c==0x49 && !isFollowedByDotAbove(&ucase_props_singleton, iter, context)) {
+ } else if(loc==UCASE_LOC_TURKISH && c==0x49 && !isFollowedByDotAbove(iter, context)) {
/*
# When lowercasing, unless an I is before a dot_above, it turns into a dotless i.
*pString=iDot;
return 2;
} else if( c==0x3a3 &&
- !isFollowedByCasedLetter(&ucase_props_singleton, iter, context, 1) &&
- isFollowedByCasedLetter(&ucase_props_singleton, iter, context, -1) /* -1=preceded */
+ !isFollowedByCasedLetter(iter, context, 1) &&
+ isFollowedByCasedLetter(iter, context, -1) /* -1=preceded */
) {
/* greek capital sigma maps depending on surrounding cased letters (see SpecialCasing.txt) */
/*
/* internal */
static int32_t
-toUpperOrTitle(const UCaseProps * /* unused csp */, UChar32 c,
+toUpperOrTitle(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t loc,
0069; 0069; 0130; 0130; az; # LATIN SMALL LETTER I
*/
return 0x130;
- } else if(loc==UCASE_LOC_LITHUANIAN && c==0x307 && isPrecededBySoftDotted(&ucase_props_singleton, iter, context)) {
+ } else if(loc==UCASE_LOC_LITHUANIAN && c==0x307 && isPrecededBySoftDotted(iter, context)) {
/*
# Lithuanian
}
U_CAPI int32_t U_EXPORT2
-ucase_toFullUpper(const UCaseProps * /* unused csp */, UChar32 c,
+ucase_toFullUpper(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t caseLocale) {
- return toUpperOrTitle(&ucase_props_singleton, c, iter, context, pString, caseLocale, TRUE);
+ return toUpperOrTitle(c, iter, context, pString, caseLocale, TRUE);
}
U_CAPI int32_t U_EXPORT2
-ucase_toFullTitle(const UCaseProps * /* unused csp */, UChar32 c,
+ucase_toFullTitle(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t caseLocale) {
- return toUpperOrTitle(&ucase_props_singleton, c, iter, context, pString, caseLocale, FALSE);
+ return toUpperOrTitle(c, iter, context, pString, caseLocale, FALSE);
}
/* case folding ------------------------------------------------------------- */
/* return the simple case folding mapping for c */
U_CAPI UChar32 U_EXPORT2
-ucase_fold(const UCaseProps * /* unused csp */, UChar32 c, uint32_t options) {
+ucase_fold(UChar32 c, uint32_t options) {
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
if(!PROPS_HAS_EXCEPTION(props)) {
if(UCASE_GET_TYPE(props)>=UCASE_UPPER) {
*/
U_CAPI int32_t U_EXPORT2
-ucase_toFullFolding(const UCaseProps * /* unused csp */, UChar32 c,
+ucase_toFullFolding(UChar32 c,
const UChar **pString,
uint32_t options) {
// The sign of the result has meaning, input must be non-negative so that it can be returned as is.
/* case mapping properties API ---------------------------------------------- */
-#define GET_CASE_PROPS() &ucase_props_singleton
-
/* public API (see uchar.h) */
U_CAPI UBool U_EXPORT2
u_isULowercase(UChar32 c) {
- return (UBool)(UCASE_LOWER==ucase_getType(GET_CASE_PROPS(), c));
+ return (UBool)(UCASE_LOWER==ucase_getType(c));
}
U_CAPI UBool U_EXPORT2
u_isUUppercase(UChar32 c) {
- return (UBool)(UCASE_UPPER==ucase_getType(GET_CASE_PROPS(), c));
+ return (UBool)(UCASE_UPPER==ucase_getType(c));
}
/* Transforms the Unicode character to its lower case equivalent.*/
U_CAPI UChar32 U_EXPORT2
u_tolower(UChar32 c) {
- return ucase_tolower(GET_CASE_PROPS(), c);
+ return ucase_tolower(c);
}
/* Transforms the Unicode character to its upper case equivalent.*/
U_CAPI UChar32 U_EXPORT2
u_toupper(UChar32 c) {
- return ucase_toupper(GET_CASE_PROPS(), c);
+ return ucase_toupper(c);
}
/* Transforms the Unicode character to its title case equivalent.*/
U_CAPI UChar32 U_EXPORT2
u_totitle(UChar32 c) {
- return ucase_totitle(GET_CASE_PROPS(), c);
+ return ucase_totitle(c);
}
/* return the simple case folding mapping for c */
U_CAPI UChar32 U_EXPORT2
u_foldCase(UChar32 c, uint32_t options) {
- return ucase_fold(GET_CASE_PROPS(), c, options);
+ return ucase_fold(c, options);
}
U_CFUNC int32_t U_EXPORT2
const UChar *resultString;
switch(which) {
case UCHAR_LOWERCASE:
- return (UBool)(UCASE_LOWER==ucase_getType(&ucase_props_singleton, c));
+ return (UBool)(UCASE_LOWER==ucase_getType(c));
case UCHAR_UPPERCASE:
- return (UBool)(UCASE_UPPER==ucase_getType(&ucase_props_singleton, c));
+ return (UBool)(UCASE_UPPER==ucase_getType(c));
case UCHAR_SOFT_DOTTED:
- return ucase_isSoftDotted(&ucase_props_singleton, c);
+ return ucase_isSoftDotted(c);
case UCHAR_CASE_SENSITIVE:
- return ucase_isCaseSensitive(&ucase_props_singleton, c);
+ return ucase_isCaseSensitive(c);
case UCHAR_CASED:
- return (UBool)(UCASE_NONE!=ucase_getType(&ucase_props_singleton, c));
+ return (UBool)(UCASE_NONE!=ucase_getType(c));
case UCHAR_CASE_IGNORABLE:
- return (UBool)(ucase_getTypeOrIgnorable(&ucase_props_singleton, c)>>2);
+ return (UBool)(ucase_getTypeOrIgnorable(c)>>2);
/*
* Note: The following Changes_When_Xyz are defined as testing whether
* the NFD form of the input changes when Xyz-case-mapped.
* start sets for normalization and case mappings.
*/
case UCHAR_CHANGES_WHEN_LOWERCASED:
- return (UBool)(ucase_toFullLower(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
+ return (UBool)(ucase_toFullLower(c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
case UCHAR_CHANGES_WHEN_UPPERCASED:
- return (UBool)(ucase_toFullUpper(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
+ return (UBool)(ucase_toFullUpper(c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
case UCHAR_CHANGES_WHEN_TITLECASED:
- return (UBool)(ucase_toFullTitle(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
+ return (UBool)(ucase_toFullTitle(c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
/* case UCHAR_CHANGES_WHEN_CASEFOLDED: -- in uprops.c */
case UCHAR_CHANGES_WHEN_CASEMAPPED:
return (UBool)(
- ucase_toFullLower(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0 ||
- ucase_toFullUpper(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0 ||
- ucase_toFullTitle(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
+ ucase_toFullLower(c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0 ||
+ ucase_toFullUpper(c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0 ||
+ ucase_toFullTitle(c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
default:
return FALSE;
}
/* library API -------------------------------------------------------------- */
-U_CDECL_BEGIN
-
-struct UCaseProps;
-typedef struct UCaseProps UCaseProps;
-
-U_CDECL_END
-
-U_CAPI const UCaseProps * U_EXPORT2
-ucase_getSingleton(void);
-
U_CFUNC void U_EXPORT2
-ucase_addPropertyStarts(const UCaseProps *csp, const USetAdder *sa, UErrorCode *pErrorCode);
+ucase_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
/**
* Requires non-NULL locale ID but otherwise does the equivalent of
/* single-code point functions */
U_CAPI UChar32 U_EXPORT2
-ucase_tolower(const UCaseProps *csp, UChar32 c);
+ucase_tolower(UChar32 c);
U_CAPI UChar32 U_EXPORT2
-ucase_toupper(const UCaseProps *csp, UChar32 c);
+ucase_toupper(UChar32 c);
U_CAPI UChar32 U_EXPORT2
-ucase_totitle(const UCaseProps *csp, UChar32 c);
+ucase_totitle(UChar32 c);
U_CAPI UChar32 U_EXPORT2
-ucase_fold(const UCaseProps *csp, UChar32 c, uint32_t options);
+ucase_fold(UChar32 c, uint32_t options);
/**
* Adds all simple case mappings and the full case folding for c to sa,
* - for k include the Kelvin sign
*/
U_CFUNC void U_EXPORT2
-ucase_addCaseClosure(const UCaseProps *csp, UChar32 c, const USetAdder *sa);
+ucase_addCaseClosure(UChar32 c, const USetAdder *sa);
/**
* Maps the string to single code points and adds the associated case closure
* @return TRUE if the string was found
*/
U_CFUNC UBool U_EXPORT2
-ucase_addStringCaseClosure(const UCaseProps *csp, const UChar *s, int32_t length, const USetAdder *sa);
+ucase_addStringCaseClosure(const UChar *s, int32_t length, const USetAdder *sa);
#ifdef __cplusplus
U_NAMESPACE_BEGIN
/** @return UCASE_NONE, UCASE_LOWER, UCASE_UPPER, UCASE_TITLE */
U_CAPI int32_t U_EXPORT2
-ucase_getType(const UCaseProps *csp, UChar32 c);
+ucase_getType(UChar32 c);
/** @return like ucase_getType() but also sets UCASE_IGNORABLE if c is case-ignorable */
U_CAPI int32_t U_EXPORT2
-ucase_getTypeOrIgnorable(const UCaseProps *csp, UChar32 c);
+ucase_getTypeOrIgnorable(UChar32 c);
U_CAPI UBool U_EXPORT2
-ucase_isSoftDotted(const UCaseProps *csp, UChar32 c);
+ucase_isSoftDotted(UChar32 c);
U_CAPI UBool U_EXPORT2
-ucase_isCaseSensitive(const UCaseProps *csp, UChar32 c);
+ucase_isCaseSensitive(UChar32 c);
/* string case mapping functions */
* @internal
*/
U_CAPI int32_t U_EXPORT2
-ucase_toFullLower(const UCaseProps *csp, UChar32 c,
+ucase_toFullLower(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t caseLocale);
U_CAPI int32_t U_EXPORT2
-ucase_toFullUpper(const UCaseProps *csp, UChar32 c,
+ucase_toFullUpper(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t caseLocale);
U_CAPI int32_t U_EXPORT2
-ucase_toFullTitle(const UCaseProps *csp, UChar32 c,
+ucase_toFullTitle(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t caseLocale);
U_CAPI int32_t U_EXPORT2
-ucase_toFullFolding(const UCaseProps *csp, UChar32 c,
+ucase_toFullFolding(UChar32 c,
const UChar **pString,
uint32_t options);
* @internal
*/
typedef int32_t U_CALLCONV
-UCaseMapFull(const UCaseProps *csp, UChar32 c,
+UCaseMapFull(UChar32 c,
UCaseContextIterator *iter, void *context,
const UChar **pString,
int32_t caseLocale);
}
continue;
}
- c=map(NULL, c, utf8_caseContextIterator, csc, &s, caseLocale);
+ c=map(c, utf8_caseContextIterator, csc, &s, caseLocale);
if((destIndex<destCapacity) && (c<0 ? (c2=~c)<=0x7f : UCASE_MAX_STRING_LENGTH<c && (c2=c)<=0x7f)) {
/* fast path version of appendResult() for ASCII results */
dest[destIndex++]=(uint8_t)c2;
/* find and copy uncased characters [prev..titleStart[ */
titleStart=titleLimit=prev;
U8_NEXT(src, titleLimit, idx, c);
- if((options&U_TITLECASE_NO_BREAK_ADJUSTMENT)==0 && UCASE_NONE==ucase_getType(NULL, c)) {
+ if((options&U_TITLECASE_NO_BREAK_ADJUSTMENT)==0 && UCASE_NONE==ucase_getType(c)) {
/* Adjust the titlecasing index (titleStart) to the next cased character. */
for(;;) {
titleStart=titleLimit;
break;
}
U8_NEXT(src, titleLimit, idx, c);
- if(UCASE_NONE!=ucase_getType(NULL, c)) {
+ if(UCASE_NONE!=ucase_getType(c)) {
break; /* cased letter at [titleStart..titleLimit[ */
}
}
if(c>=0) {
csc.cpStart=titleStart;
csc.cpLimit=titleLimit;
- c=ucase_toFullTitle(NULL, c, utf8_caseContextIterator, &csc, &s, caseLocale);
+ c=ucase_toFullTitle(c, utf8_caseContextIterator, &csc, &s, caseLocale);
destIndex=appendResult(dest, destIndex, destCapacity, c, s);
} else {
// Malformed UTF-8.
U_NAMESPACE_BEGIN
namespace GreekUpper {
-UBool isFollowedByCasedLetter(const UCaseProps *csp, const uint8_t *s, int32_t i, int32_t length) {
+UBool isFollowedByCasedLetter(const uint8_t *s, int32_t i, int32_t length) {
while (i < length) {
UChar32 c;
U8_NEXT(s, i, length, c);
- int32_t type = ucase_getTypeOrIgnorable(csp, c);
+ int32_t type = ucase_getTypeOrIgnorable(c);
if ((type & UCASE_IGNORABLE) != 0) {
// Case-ignorable, continue with the loop.
} else if (type != UCASE_NONE) {
UChar32 c;
U8_NEXT(src, nextIndex, srcLength, c);
uint32_t nextState = 0;
- int32_t type = ucase_getTypeOrIgnorable(NULL, c);
+ int32_t type = ucase_getTypeOrIgnorable(c);
if ((type & UCASE_IGNORABLE) != 0) {
// c is case-ignorable
nextState |= (state & AFTER_CASED);
(data & HAS_ACCENT) != 0 &&
numYpogegrammeni == 0 &&
(state & AFTER_CASED) == 0 &&
- !isFollowedByCasedLetter(NULL, src, nextIndex, srcLength)) {
+ !isFollowedByCasedLetter(src, nextIndex, srcLength)) {
// Keep disjunctive "or" with (only) a tonos.
// We use the same "word boundary" conditions as for the Final_Sigma test.
if (i == nextIndex) {
} else if(c>=0) {
const UChar *s;
UChar32 c2 = 0;
- c=ucase_toFullUpper(NULL, c, NULL, NULL, &s, caseLocale);
+ c=ucase_toFullUpper(c, NULL, NULL, &s, caseLocale);
if((destIndex<destCapacity) && (c<0 ? (c2=~c)<=0x7f : UCASE_MAX_STRING_LENGTH<c && (c2=c)<=0x7f)) {
/* fast path version of appendResult() for ASCII results */
dest[destIndex++]=(uint8_t)c2;
}
continue;
}
- c=ucase_toFullFolding(NULL, c, &s, options);
+ c=ucase_toFullFolding(c, &s, options);
if((destIndex<destCapacity) && (c<0 ? (c2=~c)<=0x7f : UCASE_MAX_STRING_LENGTH<c && (c2=c)<=0x7f)) {
/* fast path version of appendResult() for ASCII results */
dest[destIndex++]=(uint8_t)c2;
return *this;
}
if (attribute & (USET_CASE_INSENSITIVE | USET_ADD_CASE_MAPPINGS)) {
- const UCaseProps *csp = ucase_getSingleton();
{
UnicodeSet foldSet(*this);
UnicodeString str;
if (attribute & USET_CASE_INSENSITIVE) {
// full case closure
for (UChar32 cp=start; cp<=end; ++cp) {
- ucase_addCaseClosure(csp, cp, &sa);
+ ucase_addCaseClosure(cp, &sa);
}
} else {
// add case mappings
// (does not add long s for regular s, or Kelvin for k, for example)
for (UChar32 cp=start; cp<=end; ++cp) {
- result = ucase_toFullLower(csp, cp, NULL, NULL, &full, UCASE_LOC_ROOT);
+ result = ucase_toFullLower(cp, NULL, NULL, &full, UCASE_LOC_ROOT);
addCaseMapping(foldSet, result, full, str);
- result = ucase_toFullTitle(csp, cp, NULL, NULL, &full, UCASE_LOC_ROOT);
+ result = ucase_toFullTitle(cp, NULL, NULL, &full, UCASE_LOC_ROOT);
addCaseMapping(foldSet, result, full, str);
- result = ucase_toFullUpper(csp, cp, NULL, NULL, &full, UCASE_LOC_ROOT);
+ result = ucase_toFullUpper(cp, NULL, NULL, &full, UCASE_LOC_ROOT);
addCaseMapping(foldSet, result, full, str);
- result = ucase_toFullFolding(csp, cp, &full, 0);
+ result = ucase_toFullFolding(cp, &full, 0);
addCaseMapping(foldSet, result, full, str);
}
}
for (int32_t j=0; j<strings->size(); ++j) {
str = *(const UnicodeString *) strings->elementAt(j);
str.foldCase();
- if(!ucase_addStringCaseClosure(csp, str.getBuffer(), str.length(), &sa)) {
+ if(!ucase_addStringCaseClosure(str.getBuffer(), str.length(), &sa)) {
foldSet.add(str); // does not map to code points: add the folded string itself
}
}
if(U_SUCCESS(status)) {
impl->addPropertyStarts(&sa, status);
}
- ucase_addPropertyStarts(ucase_getSingleton(), &sa, &status);
+ ucase_addPropertyStarts(&sa, &status);
break;
}
case UPROPS_SRC_NFC: {
}
#endif
case UPROPS_SRC_CASE:
- ucase_addPropertyStarts(ucase_getSingleton(), &sa, &status);
+ ucase_addPropertyStarts(&sa, &status);
break;
case UPROPS_SRC_BIDI:
ubidi_addPropertyStarts(ubidi_getSingleton(), &sa, &status);
uint32_t options,
UErrorCode *pErrorCode) {
const Normalizer2Impl *nfcImpl;
- const UCaseProps *csp;
/* current-level start/limit - s1/s2 as current */
const UChar *start1, *start2, *limit1, *limit2;
} else {
nfcImpl=NULL;
}
- if((options&U_COMPARE_IGNORE_CASE)!=0) {
- csp=ucase_getSingleton();
- } else {
- csp=NULL;
- }
if(U_FAILURE(*pErrorCode)) {
return 0;
}
*/
if( level1==0 && (options&U_COMPARE_IGNORE_CASE) &&
- (length=ucase_toFullFolding(csp, (UChar32)cp1, &p, options))>=0
+ (length=ucase_toFullFolding((UChar32)cp1, &p, options))>=0
) {
/* cp1 case-folds to the code point "length" or to p[length] */
if(U_IS_SURROGATE(c1)) {
}
if( level2==0 && (options&U_COMPARE_IGNORE_CASE) &&
- (length=ucase_toFullFolding(csp, (UChar32)cp2, &p, options))>=0
+ (length=ucase_toFullFolding((UChar32)cp2, &p, options))>=0
) {
/* cp2 case-folds to the code point "length" or to p[length] */
if(U_IS_SURROGATE(c2)) {
}
if(c>=0) {
/* single code point */
- const UCaseProps *csp=ucase_getSingleton();
const UChar *resultString;
- return (UBool)(ucase_toFullFolding(csp, c, &resultString, U_FOLD_CASE_DEFAULT)>=0);
+ return (UBool)(ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT)>=0);
} else {
/* guess some large but stack-friendly capacity */
UChar dest[2*UCASE_MAX_STRING_LENGTH];
// case folding and NFKC.)
// For the derivation, see Unicode's DerivedNormalizationProps.txt.
const Normalizer2 *nfkc=Normalizer2::getNFKCInstance(*pErrorCode);
- const UCaseProps *csp=ucase_getSingleton();
if(U_FAILURE(*pErrorCode)) {
return 0;
}
// first: b = NFKC(Fold(a))
UnicodeString folded1String;
const UChar *folded1;
- int32_t folded1Length=ucase_toFullFolding(csp, c, &folded1, U_FOLD_CASE_DEFAULT);
+ int32_t folded1Length=ucase_toFullFolding(c, &folded1, U_FOLD_CASE_DEFAULT);
if(folded1Length<0) {
const Normalizer2Impl *nfkcImpl=Normalizer2Factory::getImpl(nfkc);
if(nfkcImpl->getCompQuickCheck(nfkcImpl->getNorm16(c))!=UNORM_NO) {
U16_NEXT(src, srcIndex, srcLimit, c);
csc->cpLimit=srcIndex;
const UChar *s;
- c=map(NULL, c, utf16_caseContextIterator, csc, &s, caseLocale);
+ c=map(c, utf16_caseContextIterator, csc, &s, caseLocale);
destIndex = appendResult(dest, destIndex, destCapacity, c, s,
srcIndex - cpStart, options, edits);
if (destIndex < 0) {
int32_t titleLimit=prev;
UChar32 c;
U16_NEXT(src, titleLimit, index, c);
- if((options&U_TITLECASE_NO_BREAK_ADJUSTMENT)==0 && UCASE_NONE==ucase_getType(NULL, c)) {
+ if((options&U_TITLECASE_NO_BREAK_ADJUSTMENT)==0 && UCASE_NONE==ucase_getType(c)) {
/* Adjust the titlecasing index (titleStart) to the next cased character. */
for(;;) {
titleStart=titleLimit;
break;
}
U16_NEXT(src, titleLimit, index, c);
- if(UCASE_NONE!=ucase_getType(NULL, c)) {
+ if(UCASE_NONE!=ucase_getType(c)) {
break; /* cased letter at [titleStart..titleLimit[ */
}
}
csc.cpStart=titleStart;
csc.cpLimit=titleLimit;
const UChar *s;
- c=ucase_toFullTitle(NULL, c, utf16_caseContextIterator, &csc, &s, caseLocale);
+ c=ucase_toFullTitle(c, utf16_caseContextIterator, &csc, &s, caseLocale);
destIndex=appendResult(dest, destIndex, destCapacity, c, s,
titleLimit-titleStart, options, edits);
if(destIndex<0) {
}
}
-UBool isFollowedByCasedLetter(const UCaseProps *csp, const UChar *s, int32_t i, int32_t length) {
+UBool isFollowedByCasedLetter(const UChar *s, int32_t i, int32_t length) {
while (i < length) {
UChar32 c;
U16_NEXT(s, i, length, c);
- int32_t type = ucase_getTypeOrIgnorable(csp, c);
+ int32_t type = ucase_getTypeOrIgnorable(c);
if ((type & UCASE_IGNORABLE) != 0) {
// Case-ignorable, continue with the loop.
} else if (type != UCASE_NONE) {
UChar32 c;
U16_NEXT(src, nextIndex, srcLength, c);
uint32_t nextState = 0;
- int32_t type = ucase_getTypeOrIgnorable(NULL, c);
+ int32_t type = ucase_getTypeOrIgnorable(c);
if ((type & UCASE_IGNORABLE) != 0) {
// c is case-ignorable
nextState |= (state & AFTER_CASED);
(data & HAS_ACCENT) != 0 &&
numYpogegrammeni == 0 &&
(state & AFTER_CASED) == 0 &&
- !isFollowedByCasedLetter(NULL, src, nextIndex, srcLength)) {
+ !isFollowedByCasedLetter(src, nextIndex, srcLength)) {
// Keep disjunctive "or" with (only) a tonos.
// We use the same "word boundary" conditions as for the Final_Sigma test.
if (i == nextIndex) {
}
} else {
const UChar *s;
- c=ucase_toFullUpper(NULL, c, NULL, NULL, &s, UCASE_LOC_GREEK);
+ c=ucase_toFullUpper(c, NULL, NULL, &s, UCASE_LOC_GREEK);
destIndex = appendResult(dest, destIndex, destCapacity, c, s,
nextIndex - i, options, edits);
if (destIndex < 0) {
UChar32 c;
U16_NEXT(src, srcIndex, srcLength, c);
const UChar *s;
- c = ucase_toFullFolding(NULL, c, &s, options);
+ c = ucase_toFullFolding(c, &s, options);
destIndex = appendResult(dest, destIndex, destCapacity, c, s,
srcIndex - cpStart, options, edits);
if (destIndex < 0) {
UErrorCode *pErrorCode) {
int32_t cmpRes = 0;
- const UCaseProps *csp;
-
/* current-level start/limit - s1/s2 as current */
const UChar *start1, *start2, *limit1, *limit2;
* assume that at least the option U_COMPARE_IGNORE_CASE is set
* otherwise this function would have to behave exactly as uprv_strCompare()
*/
- csp=ucase_getSingleton();
if(U_FAILURE(*pErrorCode)) {
return 0;
}
*/
if( level1==0 &&
- (length=ucase_toFullFolding(csp, (UChar32)cp1, &p, options))>=0
+ (length=ucase_toFullFolding((UChar32)cp1, &p, options))>=0
) {
/* cp1 case-folds to the code point "length" or to p[length] */
if(U_IS_SURROGATE(c1)) {
}
if( level2==0 &&
- (length=ucase_toFullFolding(csp, (UChar32)cp2, &p, options))>=0
+ (length=ucase_toFullFolding((UChar32)cp2, &p, options))>=0
) {
/* cp2 case-folds to the code point "length" or to p[length] */
if(U_IS_SURROGATE(c2)) {
*/
CaseMapTransliterator::CaseMapTransliterator(const UnicodeString &id, UCaseMapFull *map) :
Transliterator(id, 0),
- fCsp(ucase_getSingleton()),
fMap(map)
{
// TODO test incremental mode with context-sensitive text (e.g. greek sigma)
*/
CaseMapTransliterator::CaseMapTransliterator(const CaseMapTransliterator& o) :
Transliterator(o),
- fCsp(o.fCsp), fMap(o.fMap)
+ fMap(o.fMap)
{
}
*/
/*CaseMapTransliterator& CaseMapTransliterator::operator=(const CaseMapTransliterator& o) {
Transliterator::operator=(o);
- fCsp = o.fCsp;
fMap = o.fMap;
return *this;
}*/
c=text.char32At(textPos);
csc.cpLimit=textPos+=U16_LENGTH(c);
- result=fMap(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
+ result=fMap(c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
if(csc.b1 && isIncremental) {
// fMap() tried to look beyond the context limit
UTransPosition& offsets,
UBool isIncremental) const;
- const UCaseProps *fCsp;
UCaseMapFull *fMap;
private:
U_NAMESPACE_BEGIN
CaseFoldingUTextIterator::CaseFoldingUTextIterator(UText &text) :
- fUText(text), fcsp(NULL), fFoldChars(NULL), fFoldLength(0) {
- fcsp = ucase_getSingleton();
+ fUText(text), fFoldChars(NULL), fFoldLength(0) {
}
CaseFoldingUTextIterator::~CaseFoldingUTextIterator() {}
if (originalC == U_SENTINEL) {
return originalC;
}
- fFoldLength = ucase_toFullFolding(fcsp, originalC, &fFoldChars, U_FOLD_CASE_DEFAULT);
+ fFoldLength = ucase_toFullFolding(originalC, &fFoldChars, U_FOLD_CASE_DEFAULT);
if (fFoldLength >= UCASE_MAX_STRING_LENGTH || fFoldLength < 0) {
// input code point folds to a single code point, possibly itself.
// See comment in ucase.h for explanation of return values from ucase_toFullFoldings.
CaseFoldingUCharIterator::CaseFoldingUCharIterator(const UChar *chars, int64_t start, int64_t limit) :
- fChars(chars), fIndex(start), fLimit(limit), fcsp(NULL), fFoldChars(NULL), fFoldLength(0) {
- fcsp = ucase_getSingleton();
+ fChars(chars), fIndex(start), fLimit(limit), fFoldChars(NULL), fFoldLength(0) {
}
}
U16_NEXT(fChars, fIndex, fLimit, originalC);
- fFoldLength = ucase_toFullFolding(fcsp, originalC, &fFoldChars, U_FOLD_CASE_DEFAULT);
+ fFoldLength = ucase_toFullFolding(originalC, &fFoldChars, U_FOLD_CASE_DEFAULT);
if (fFoldLength >= UCASE_MAX_STRING_LENGTH || fFoldLength < 0) {
// input code point folds to a single code point, possibly itself.
// See comment in ucase.h for explanation of return values from ucase_toFullFoldings.
// folding of the same code point from the orignal UText.
private:
UText &fUText;
- const UCaseProps *fcsp;
const UChar *fFoldChars;
int32_t fFoldLength;
int32_t fFoldIndex;
const UChar *fChars;
int64_t fIndex;
int64_t fLimit;
- const UCaseProps *fcsp;
const UChar *fFoldChars;
int32_t fFoldLength;
int32_t fFoldIndex;
int32_t start;
for (start = offsets.start - 1; start >= offsets.contextStart; start -= U16_LENGTH(c)) {
c = text.char32At(start);
- type=ucase_getTypeOrIgnorable(fCsp, c);
+ type=ucase_getTypeOrIgnorable(c);
if(type>0) { // cased
doTitle=FALSE;
break;
c=text.char32At(textPos);
csc.cpLimit=textPos+=U16_LENGTH(c);
- type=ucase_getTypeOrIgnorable(fCsp, c);
+ type=ucase_getTypeOrIgnorable(c);
if(type>=0) { // not case-ignorable
if(doTitle) {
- result=ucase_toFullTitle(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
+ result=ucase_toFullTitle(c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
} else {
- result=ucase_toFullLower(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
+ result=ucase_toFullLower(c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
}
doTitle = (UBool)(type==0); // doTitle=isUncased
#include "uprops.h"
#include "uset_imp.h"
#include "usc_impl.h"
-#include "udatamem.h" /* for testing ucase_openBinary() */
+#include "udatamem.h"
#include "cucdapi.h"
#include "cmemory.h"
static void TestPropertyNames(void);
static void TestPropertyValues(void);
static void TestConsistency(void);
-static void TestUCase(void);
static void TestUBiDiProps(void);
static void TestCaseFolding(void);
addTest(root, &TestPropertyNames, "tsutil/cucdtst/TestPropertyNames");
addTest(root, &TestPropertyValues, "tsutil/cucdtst/TestPropertyValues");
addTest(root, &TestConsistency, "tsutil/cucdtst/TestConsistency");
- addTest(root, &TestUCase, "tsutil/cucdtst/TestUCase");
addTest(root, &TestUBiDiProps, "tsutil/cucdtst/TestUBiDiProps");
addTest(root, &TestCaseFolding, "tsutil/cucdtst/TestCaseFolding");
}
*/
#define HARDCODED_DATA_4497 1
-/* API coverage for ucase.c */
-static void TestUCase() {
-#if !HARDCODED_DATA_4497
- UDataMemory *pData;
- UCaseProps *csp;
- const UCaseProps *ccsp;
- UErrorCode errorCode;
-
- /* coverage for ucase_openBinary() */
- errorCode=U_ZERO_ERROR;
- pData=udata_open(NULL, UCASE_DATA_TYPE, UCASE_DATA_NAME, &errorCode);
- if(U_FAILURE(errorCode)) {
- log_data_err("unable to open " UCASE_DATA_NAME "." UCASE_DATA_TYPE ": %s\n",
- u_errorName(errorCode));
- return;
- }
-
- csp=ucase_openBinary((const uint8_t *)pData->pHeader, -1, &errorCode);
- if(U_FAILURE(errorCode)) {
- log_err("ucase_openBinary() fails for the contents of " UCASE_DATA_NAME "." UCASE_DATA_TYPE ": %s\n",
- u_errorName(errorCode));
- udata_close(pData);
- return;
- }
-
- if(UCASE_LOWER!=ucase_getType(csp, 0xdf)) { /* verify islower(sharp s) */
- log_err("ucase_openBinary() does not seem to return working UCaseProps\n");
- }
-
- ucase_close(csp);
- udata_close(pData);
-
- /* coverage for ucase_getDummy() */
- errorCode=U_ZERO_ERROR;
- ccsp=ucase_getDummy(&errorCode);
- if(ucase_tolower(ccsp, 0x41)!=0x41) {
- log_err("ucase_tolower(dummy, A)!=A\n");
- }
-#endif
-}
-
/* API coverage for ubidi_props.c */
static void TestUBiDiProps() {
#if !HARDCODED_DATA_4497