ICU-4497 hardcode uprops.icu data rather than loading it

X-SVN-Rev: 17531
This commit is contained in:
Markus Scherer 2005-04-30 03:06:58 +00:00
parent d5a7851861
commit cad9e84aba
2 changed files with 2109 additions and 7 deletions

View File

@ -35,6 +35,15 @@
/* dynamically loaded Unicode character properties -------------------------- */
#define UCHAR_HARDCODE_DATA 1
#if UCHAR_HARDCODE_DATA
/* uchar_props_data.c is machine-generated by genprops --csource */
#include "uchar_props_data.c"
#else
/*
* loaded uprops.dat -
* for a description of the file format, see icu/source/tools/genprops/store.c
@ -93,6 +102,7 @@ static UBool U_CALLCONV uchar_cleanup(void)
pData32=NULL;
propsVectors=NULL;
countPropsVectors=0;
uprv_memset(dataVersion, 0, U_MAX_VERSION_LENGTH);
dataErrorCode=U_ZERO_ERROR;
havePropsData=0;
@ -142,8 +152,13 @@ _openProps(UCharProps *ucp, UErrorCode *pErrorCode) {
}
}
#endif
U_CFUNC int8_t
uprv_loadPropsData(UErrorCode *pErrorCode) {
#if UCHAR_HARDCODE_DATA
return TRUE;
#else
/* load Unicode character properties data from file if necessary */
/*
@ -198,8 +213,10 @@ uprv_loadPropsData(UErrorCode *pErrorCode) {
}
return havePropsData;
#endif
}
#if !UCHAR_HARDCODE_DATA
static int8_t
loadPropsData(void) {
@ -208,6 +225,7 @@ loadPropsData(void) {
return retVal;
}
#endif
/* Unicode properties data swapping ----------------------------------------- */
@ -343,6 +361,12 @@ uprops_swap(const UDataSwapper *ds,
/* constants and macros for access to the data ------------------------------ */
/* getting a uint32_t properties word from the data */
#if UCHAR_HARDCODE_DATA
#define GET_PROPS(c, result) UTRIE_GET16(&propsTrie, c, result);
#else
#define HAVE_DATA (havePropsData>0 || loadPropsData()>0)
#define GET_PROPS_UNSAFE(c, result) \
UTRIE_GET16(&propsTrie, c, result);
@ -353,11 +377,14 @@ uprops_swap(const UDataSwapper *ds,
(result)=0; \
}
#endif
U_CFUNC UBool
uprv_haveProperties(UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return FALSE;
}
#if !UCHAR_HARDCODE_DATA
if(havePropsData==0) {
uprv_loadPropsData(pErrorCode);
}
@ -365,6 +392,7 @@ uprv_haveProperties(UErrorCode *pErrorCode) {
*pErrorCode=dataErrorCode;
return FALSE;
}
#endif
return TRUE;
}
@ -401,7 +429,11 @@ U_CAPI void U_EXPORT2
u_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context) {
struct _EnumTypeCallback callback;
if(enumRange==NULL || !HAVE_DATA) {
if(enumRange==NULL
#if !UCHAR_HARDCODE_DATA
|| !HAVE_DATA
#endif
) {
return;
}
@ -765,11 +797,7 @@ u_forDigit(int32_t digit, int8_t radix) {
U_CAPI void U_EXPORT2
u_getUnicodeVersion(UVersionInfo versionArray) {
if(versionArray!=NULL) {
if(HAVE_DATA) {
uprv_memcpy(versionArray, dataVersion, U_MAX_VERSION_LENGTH);
} else {
uprv_memset(versionArray, 0, U_MAX_VERSION_LENGTH);
}
uprv_memcpy(versionArray, dataVersion, U_MAX_VERSION_LENGTH);
}
}
@ -781,7 +809,10 @@ u_getUnicodeProperties(UChar32 c, int32_t column) {
uint32_t props;
GET_PROPS(c, props);
return props;
} else if( !HAVE_DATA || countPropsVectors==0 ||
} else if(
#if !UCHAR_HARDCODE_DATA
!HAVE_DATA || countPropsVectors==0 ||
#endif
column<0 || column>=propsVectorsColumns
) {
return 0;
@ -793,7 +824,9 @@ u_getUnicodeProperties(UChar32 c, int32_t column) {
U_CFUNC int32_t
uprv_getMaxValues(int32_t column) {
#if !UCHAR_HARDCODE_DATA
if(HAVE_DATA) {
#endif
switch(column) {
case 0:
return indexes[UPROPS_MAX_VALUES_INDEX];
@ -802,9 +835,11 @@ uprv_getMaxValues(int32_t column) {
default:
return 0;
}
#if !UCHAR_HARDCODE_DATA
} else {
return 0;
}
#endif
}
/*
@ -884,10 +919,12 @@ uhst_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) {
return;
}
#if !UCHAR_HARDCODE_DATA
if(!HAVE_DATA) {
*pErrorCode=dataErrorCode;
return;
}
#endif
/* add code points with hardcoded properties, plus the ones following them */
@ -953,10 +990,12 @@ uchar_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) {
return;
}
#if !UCHAR_HARDCODE_DATA
if(!HAVE_DATA) {
*pErrorCode=dataErrorCode;
return;
}
#endif
/* add the start code point of each same-value range of the main trie */
utrie_enum(&propsTrie, NULL, _enumPropertyStartsRange, sa);
@ -1016,10 +1055,12 @@ upropsvec_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) {
return;
}
#if !UCHAR_HARDCODE_DATA
if(!HAVE_DATA) {
*pErrorCode=dataErrorCode;
return;
}
#endif
/* add the start code point of each same-value range of the properties vectors trie */
if(propsVectorsColumns>0) {

File diff suppressed because it is too large Load Diff