8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 00:03:03 +01:00

GCC emits warning when struct in non-anonymous namespace references struct from the anonymous namespace. Use void* and cast appropriatelly, because multiple declaration of struct using the same name

is not good and caused problem during V2.0 development.
This commit is contained in:
asfernandes 2008-07-12 19:37:03 +00:00
parent de3f61e208
commit cce6f50920
12 changed files with 256 additions and 216 deletions

View File

@ -35,13 +35,16 @@ ULONG CVBIG5_big5_to_unicode(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(src_ptr != NULL || p_dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVBIG5_big5_to_unicode);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = src_len;
*err_code = 0;
@ -85,8 +88,8 @@ ULONG CVBIG5_big5_to_unicode(csconvert* obj,
}
/* Convert from BIG5 to UNICODE */
const USHORT ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)[(USHORT) wide / 256] + (wide % 256)];
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT) wide / 256] + (wide % 256)];
if ((ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;
@ -113,13 +116,16 @@ ULONG CVBIG5_unicode_to_big5(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(p_unicode_str != NULL || big5_str == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVBIG5_unicode_to_big5);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = unicode_len;
*err_code = 0;
@ -136,8 +142,8 @@ ULONG CVBIG5_unicode_to_big5(csconvert* obj,
/* Convert from UNICODE to BIG5 code */
const USHORT wide = *unicode_str++;
const USHORT big5_ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)[(USHORT)wide / 256] + (wide % 256)];
const USHORT big5_ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT)wide / 256] + (wide % 256)];
if ((big5_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;
break;

View File

@ -35,13 +35,16 @@ ULONG CVGB_gb2312_to_unicode(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(src_ptr != NULL || p_dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVGB_gb2312_to_unicode);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = src_len;
*err_code = 0;
@ -85,8 +88,8 @@ ULONG CVGB_gb2312_to_unicode(csconvert* obj,
}
/* Convert from GB2312 to UNICODE */
const USHORT ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)[(USHORT) wide / 256]
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT) wide / 256]
+ (wide % 256)];
if ((ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
@ -114,13 +117,16 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(p_unicode_str != NULL || gb_str == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVGB_unicode_to_gb2312);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = unicode_len;
*err_code = 0;
@ -137,8 +143,8 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
/* Convert from UNICODE to GB2312 code */
const USHORT wide = *unicode_str++;
const USHORT gb_ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)
const USHORT gb_ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[(USHORT)wide / 256]
+ (wide % 256)];
if ((gb_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {

View File

@ -42,7 +42,8 @@ namespace
static UConverter* create_converter(csconvert* cv, UErrorCode* status)
{
UConverter* conv = ucnv_open(cv->csconvert_impl->cs->charset_name, status);
UConverter* conv = ucnv_open(
static_cast<CsConvertImpl*>(cv->csconvert_impl)->cs->charset_name, status);
const void* oldContext;
UConverterFromUCallback oldFromAction;
@ -71,7 +72,7 @@ static UConverter* create_converter(csconvert* cv, UErrorCode* status)
static void convert_destroy(csconvert* cv)
{
delete cv->csconvert_impl;
delete static_cast<CsConvertImpl*>(cv->csconvert_impl);
}
@ -87,7 +88,10 @@ static ULONG unicode_to_icu(csconvert* cv,
*errPosition = 0;
if (dst == NULL)
return srcLen / sizeof(UChar) * cv->csconvert_impl->cs->charset_max_bytes_per_char;
{
return srcLen / sizeof(UChar) *
static_cast<CsConvertImpl*>(cv->csconvert_impl)->cs->charset_max_bytes_per_char;
}
UErrorCode status = U_ZERO_ERROR;
UConverter* conv = create_converter(cv, &status);
@ -131,7 +135,10 @@ static ULONG icu_to_unicode(csconvert* cv,
*errPosition = 0;
if (dst == NULL)
return srcLen / cv->csconvert_impl->cs->charset_min_bytes_per_char * sizeof(UChar);
{
return srcLen / static_cast<CsConvertImpl*>(cv->csconvert_impl)->cs->charset_min_bytes_per_char *
sizeof(UChar);
}
UErrorCode status = U_ZERO_ERROR;
UConverter* conv = create_converter(cv, &status);
@ -169,12 +176,12 @@ void CVICU_convert_init(charset* cs)
cs->charset_to_unicode.csconvert_fn_convert = icu_to_unicode;
cs->charset_to_unicode.csconvert_fn_destroy = convert_destroy;
cs->charset_to_unicode.csconvert_impl = new CsConvertImpl();
cs->charset_to_unicode.csconvert_impl->cs = cs;
static_cast<CsConvertImpl*>(cs->charset_to_unicode.csconvert_impl)->cs = cs;
cs->charset_from_unicode.csconvert_version = CSCONVERT_VERSION_1;
cs->charset_from_unicode.csconvert_name = "UNICODE->ICU";
cs->charset_from_unicode.csconvert_fn_convert = unicode_to_icu;
cs->charset_from_unicode.csconvert_fn_destroy = convert_destroy;
cs->charset_from_unicode.csconvert_impl = new CsConvertImpl();
cs->charset_from_unicode.csconvert_impl->cs = cs;
static_cast<CsConvertImpl*>(cs->charset_from_unicode.csconvert_impl)->cs = cs;
}

View File

@ -37,13 +37,16 @@ ULONG CVJIS_eucj_to_unicode(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(src_ptr != NULL || p_dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVJIS_eucj_to_unicode);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = src_len;
*err_code = 0;
@ -82,8 +85,8 @@ ULONG CVJIS_eucj_to_unicode(csconvert* obj,
this_len = 2;
/* Step 2: Convert from JIS to UNICODE */
ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)
ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[(USHORT)wide / 256]
+ (wide % 256)];
}
@ -135,13 +138,16 @@ ULONG CVJIS_sjis_to_unicode(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(sjis_str != NULL || p_dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVJIS_sjis_to_unicode);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = sjis_len;
*err_code = 0;
@ -202,8 +208,8 @@ ULONG CVJIS_sjis_to_unicode(csconvert* obj,
/* Step 2: Convert from JIS code (in wide) to UNICODE */
USHORT ch;
if (table == 1)
ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)
ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[(USHORT)wide / 256]
+ (wide % 256)];
else {
@ -393,13 +399,16 @@ ULONG CVJIS_unicode_to_sjis(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(p_unicode_str != NULL || sjis_str == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVJIS_unicode_to_sjis);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = unicode_len;
*err_code = 0;
@ -416,8 +425,8 @@ ULONG CVJIS_unicode_to_sjis(csconvert* obj,
/* Step 1: Convert from UNICODE to JIS code */
const USHORT wide = *unicode_str++;
USHORT jis_ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)[(USHORT)wide / 256] + (wide % 256)];
USHORT jis_ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT)wide / 256] + (wide % 256)];
if ((jis_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
@ -471,13 +480,16 @@ ULONG CVJIS_unicode_to_eucj(csconvert* obj, ULONG unicode_len, const UCHAR* p_un
ULONG eucj_len, UCHAR* eucj_str,
USHORT* err_code, ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(p_unicode_str != NULL || eucj_str == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVJIS_unicode_to_eucj);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = unicode_len;
*err_code = 0;
@ -499,8 +511,8 @@ ULONG CVJIS_unicode_to_eucj(csconvert* obj, ULONG unicode_len, const UCHAR* p_un
if (wide <= 0x007F)
jis_ch = wide;
else
jis_ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)
jis_ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[(USHORT)wide / 256]
+ (wide % 256)];
if ((jis_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {

View File

@ -41,13 +41,16 @@ ULONG CVKSC_ksc_to_unicode(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(ksc_str != NULL || p_dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVKSC_ksc_to_unicode);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = ksc_len;
*err_code = 0;
@ -88,8 +91,8 @@ ULONG CVKSC_ksc_to_unicode(csconvert* obj,
this_len = 1;
}
const USHORT ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)[(USHORT) wide / 256] +
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)[(USHORT) wide / 256] +
(wide % 256)];
if ((ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
@ -116,13 +119,16 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(p_unicode_str != NULL || ksc_str == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CVKSC_unicode_to_ksc);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = unicode_len;
*err_code = 0;
@ -137,8 +143,8 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
while (ksc_len && unicode_len > 1) {
const USHORT wide = *unicode_str++;
const USHORT ksc_ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)
[((const USHORT*) obj->csconvert_impl->csconvert_misc)
const USHORT ksc_ch = ((const USHORT*) impl->csconvert_datatable)
[((const USHORT*) impl->csconvert_misc)
[wide / 256] + (wide % 256)];
if ((ksc_ch == CS_CANT_MAP) && !(wide == CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;

View File

@ -39,8 +39,8 @@ void CV_convert_init(csconvert* csptr,
csptr->csconvert_fn_convert = cvt_fn;
csptr->csconvert_fn_destroy = CV_convert_destroy;
csptr->csconvert_impl = new CsConvertImpl();
csptr->csconvert_impl->csconvert_datatable = (const BYTE*) datatable;
csptr->csconvert_impl->csconvert_misc = (const BYTE*) datatable2;
static_cast<CsConvertImpl*>(csptr->csconvert_impl)->csconvert_datatable = (const BYTE*) datatable;
static_cast<CsConvertImpl*>(csptr->csconvert_impl)->csconvert_misc = (const BYTE*) datatable2;
}
@ -52,13 +52,16 @@ ULONG CV_unicode_to_nc(csconvert* obj,
USHORT *err_code,
ULONG *err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(src_ptr != NULL || dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CV_unicode_to_nc);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = src_len;
*err_code = 0;
@ -70,10 +73,8 @@ ULONG CV_unicode_to_nc(csconvert* obj,
const BYTE* const start = dest_ptr;
while ((src_len > 1) && dest_len) {
const UNICODE uni = *((const UNICODE*) src_ptr);
const UCHAR ch = obj->csconvert_impl->csconvert_datatable[
((const USHORT*) obj->csconvert_impl->
csconvert_misc)[(USHORT) uni / 256]
+ (uni % 256)];
const UCHAR ch = impl->csconvert_datatable[
((const USHORT*) impl->csconvert_misc)[(USHORT) uni / 256] + (uni % 256)];
if ((ch == CS_CANT_MAP) && !(uni == CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;
break;
@ -102,13 +103,16 @@ ULONG CV_wc_to_wc(csconvert* obj,
USHORT *err_code,
ULONG *err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(p_src_ptr != NULL || p_dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CV_wc_to_wc);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(obj->csconvert_impl->csconvert_misc != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_misc != NULL);
const ULONG src_start = src_len;
*err_code = 0;
@ -125,9 +129,8 @@ ULONG CV_wc_to_wc(csconvert* obj,
const USHORT* const start = dest_ptr;
while ((src_len > 1) && (dest_len > 1)) {
const UNICODE uni = *((const UNICODE*) src_ptr);
const USHORT ch = ((const USHORT*) obj->csconvert_impl->csconvert_datatable)[
((const USHORT*) obj->csconvert_impl->csconvert_misc)[
(USHORT) uni / 256] + (uni % 256)];
const USHORT ch = ((const USHORT*) impl->csconvert_datatable)[
((const USHORT*) impl->csconvert_misc)[(USHORT) uni / 256] + (uni % 256)];
if ((ch == CS_CANT_MAP) && !(uni == CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;
break;
@ -156,12 +159,15 @@ ULONG CV_nc_to_unicode(csconvert* obj,
USHORT* err_code,
ULONG* err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(src_ptr != NULL || dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CV_nc_to_unicode);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_datatable != NULL);
fb_assert(sizeof(UNICODE) == 2);
const ULONG src_start = src_len;
@ -173,7 +179,7 @@ ULONG CV_nc_to_unicode(csconvert* obj,
const BYTE* const start = dest_ptr;
while (src_len && (dest_len > 1)) {
const UNICODE ch = ((const UNICODE*) (obj->csconvert_impl->csconvert_datatable))[*src_ptr];
const UNICODE ch = ((const UNICODE*) (impl->csconvert_datatable))[*src_ptr];
/* No need to check for CS_CONVERT_ERROR, all charsets
* must convert to unicode.
*/
@ -239,12 +245,15 @@ ULONG eight_bit_convert(csconvert* obj,
USHORT *err_code,
ULONG *err_position)
{
fb_assert(obj != NULL);
CsConvertImpl* impl = static_cast<CsConvertImpl*>(obj->csconvert_impl);
fb_assert(src_ptr != NULL || dest_ptr == NULL);
fb_assert(err_code != NULL);
fb_assert(err_position != NULL);
fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == eight_bit_convert);
fb_assert(obj->csconvert_impl->csconvert_datatable != NULL);
fb_assert(impl->csconvert_datatable != NULL);
const ULONG src_start = src_len;
*err_code = 0;
@ -255,7 +264,7 @@ ULONG eight_bit_convert(csconvert* obj,
const BYTE* const start = dest_ptr;
while (src_len && dest_len) {
const UCHAR ch = obj->csconvert_impl->csconvert_datatable[*src_ptr];
const UCHAR ch = impl->csconvert_datatable[*src_ptr];
if ((ch == CS_CANT_MAP) && (*src_ptr != CS_CANT_MAP)) {
*err_code = CS_CONVERT_ERROR;
break;

View File

@ -48,7 +48,7 @@ struct TextTypeImpl
static void famasc_destroy(texttype* obj)
{
TextTypeImpl* impl = obj->texttype_impl;
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
if (impl)
{
@ -65,8 +65,9 @@ static ULONG famasc_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, UL
{
try
{
return Firebird::IntlUtil::toLower(obj->texttype_impl->charSet, iLen, pStr, iOutLen, pOutStr,
obj->texttype_impl->lower_exceptions);
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
return Firebird::IntlUtil::toLower(impl->charSet, iLen, pStr, iOutLen, pOutStr,
impl->lower_exceptions);
}
catch (const Firebird::Exception&)
{
@ -79,8 +80,9 @@ static ULONG famasc_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, UL
{
try
{
return Firebird::IntlUtil::toUpper(obj->texttype_impl->charSet, iLen, pStr, iOutLen, pOutStr,
obj->texttype_impl->upper_exceptions);
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
return Firebird::IntlUtil::toUpper(impl->charSet, iLen, pStr, iOutLen, pOutStr,
impl->upper_exceptions);
}
catch (const Firebird::Exception&)
{

View File

@ -44,6 +44,8 @@ static inline bool FAMILY1(texttype* cache,
if ((attributes & ~TEXTTYPE_ATTR_PAD_SPACE) || specific_attributes_length)
return false;
TextTypeImpl* impl = new TextTypeImpl;
cache->texttype_version = TEXTTYPE_VERSION_1;
cache->texttype_name = POSIX;
cache->texttype_country = country;
@ -54,13 +56,13 @@ static inline bool FAMILY1(texttype* cache,
cache->texttype_fn_str_to_upper = fam1_str_to_upper;
cache->texttype_fn_str_to_lower = fam1_str_to_lower;
cache->texttype_fn_destroy = LC_NARROW_destroy;
cache->texttype_impl = new TextTypeImpl;
cache->texttype_impl->texttype_collation_table = (const BYTE*) NoCaseOrderTbl;
cache->texttype_impl->texttype_toupper_table = ToUpperConversionTbl;
cache->texttype_impl->texttype_tolower_table = ToLowerConversionTbl;
cache->texttype_impl->texttype_compress_table = (const BYTE*) CompressTbl;
cache->texttype_impl->texttype_expand_table = (const BYTE*) ExpansionTbl;
cache->texttype_impl->texttype_flags = ((flags) & REVERSE) ? (TEXTTYPE_reverse_secondary | TEXTTYPE_ignore_specials) : 0;
cache->texttype_impl = impl;
impl->texttype_collation_table = (const BYTE*) NoCaseOrderTbl;
impl->texttype_toupper_table = ToUpperConversionTbl;
impl->texttype_tolower_table = ToLowerConversionTbl;
impl->texttype_compress_table = (const BYTE*) CompressTbl;
impl->texttype_expand_table = (const BYTE*) ExpansionTbl;
impl->texttype_flags = ((flags) & REVERSE) ? (TEXTTYPE_reverse_secondary | TEXTTYPE_ignore_specials) : 0;
return true;
}
@ -529,9 +531,10 @@ TEXTTYPE_ENTRY(CYRL_c2_init)
*/
#define LOCALE_UPPER(ch) (obj->texttype_impl->texttype_toupper_table [(unsigned)(ch)])
#define LOCALE_LOWER(ch) (obj->texttype_impl->texttype_tolower_table [(unsigned)(ch)])
#define LOCALE_UPPER(ch) \
(static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_toupper_table[(unsigned)(ch)])
#define LOCALE_LOWER(ch) \
(static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_tolower_table[(unsigned)(ch)])

View File

@ -100,8 +100,10 @@ USHORT LC_NARROW_key_length(texttype* obj, USHORT inLen)
{
/* fb_assert (inLen <= LANGFAM2_MAX_KEY); *//* almost certainly an error */
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
// is it the first time key_length is called?
if (obj->texttype_impl->texttype_bytes_per_key == 0)
if (impl->texttype_bytes_per_key == 0)
{
BYTE bytesPerChar = 3;
@ -112,7 +114,7 @@ USHORT LC_NARROW_key_length(texttype* obj, USHORT inLen)
for (int ch = 0; ch <= 255 && !(useSecondary && useTertiary); ++ch)
{
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)obj->texttype_impl->texttype_collation_table)[ch];
&((const SortOrderTblEntry*) impl->texttype_collation_table)[ch];
if (coll->Secondary != NULL_SECONDARY)
useSecondary = true;
@ -127,24 +129,24 @@ USHORT LC_NARROW_key_length(texttype* obj, USHORT inLen)
if (!useTertiary)
--bytesPerChar;
if (obj->texttype_impl->texttype_flags & TEXTTYPE_non_multi_level)
if (impl->texttype_flags & TEXTTYPE_non_multi_level)
{
if (useSecondary && (obj->texttype_impl->texttype_flags & TEXTTYPE_secondary_insensitive))
if (useSecondary && (impl->texttype_flags & TEXTTYPE_secondary_insensitive))
--bytesPerChar;
if (useTertiary && (obj->texttype_impl->texttype_flags & TEXTTYPE_tertiary_insensitive))
if (useTertiary && (impl->texttype_flags & TEXTTYPE_tertiary_insensitive))
--bytesPerChar;
}
obj->texttype_impl->texttype_bytes_per_key = bytesPerChar;
impl->texttype_bytes_per_key = bytesPerChar;
}
USHORT len = obj->texttype_impl->texttype_bytes_per_key * MAX(inLen, 2);
USHORT len = impl->texttype_bytes_per_key * MAX(inLen, 2);
if (obj->texttype_impl->texttype_expand_table &&
((const ExpandChar*) obj->texttype_impl->texttype_expand_table)[0].Ch)
if (impl->texttype_expand_table &&
((const ExpandChar*) impl->texttype_expand_table)[0].Ch)
{
len += (USHORT) log10(inLen + 1.0) * 4 * obj->texttype_impl->texttype_bytes_per_key;
len += (USHORT) log10(inLen + 1.0) * 4 * impl->texttype_bytes_per_key;
}
return (MIN(len, LANGFAM2_MAX_KEY));
@ -173,6 +175,8 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
fb_assert(iOutLen <= LANGFAM2_MAX_KEY);
fb_assert(iOutLen >= LC_NARROW_key_length(obj, iInLen));
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
#ifdef DEBUG
/* Dump out the input string */
if (do_debug) {
@ -212,16 +216,15 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
fb_assert(lspecial < sizeof(special));
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*) obj->texttype_impl->
texttype_collation_table)[*pInChar];
&((const SortOrderTblEntry*) impl->texttype_collation_table)[*pInChar];
if (coll->IsExpand && coll->IsCompress) {
/* Both flags set indicate a special value */
if (obj->texttype_impl->texttype_flags & TEXTTYPE_specials_first)
if (impl->texttype_flags & TEXTTYPE_specials_first)
{
if (coll->Primary != NULL_WEIGHT && lprimary < iOutLen)
outbuff[lprimary++] = coll->Primary + obj->texttype_impl->ignore_sum;
outbuff[lprimary++] = coll->Primary + impl->ignore_sum;
if (coll->Secondary != NULL_SECONDARY && lsecondary < sizeof(secondary))
secondary[lsecondary++] = coll->Secondary;
if (coll->Tertiary != NULL_TERTIARY && ltertiary < sizeof(tertiary))
@ -230,7 +233,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
else
{
if ((coll->Primary != NULL_WEIGHT) &&
!(obj->texttype_impl->texttype_flags & TEXTTYPE_ignore_specials) &&
!(impl->texttype_flags & TEXTTYPE_ignore_specials) &&
lspecial + 1u < sizeof(special))
{
special[lspecial++] = (i + 1); /* position */
@ -238,28 +241,28 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
}
}
}
else if (!((coll->IsExpand && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(coll->IsCompress && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))))
else if (!((coll->IsExpand && !(impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(coll->IsCompress && !(impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
if (coll->Primary != NULL_WEIGHT && lprimary < iOutLen)
outbuff[lprimary++] = coll->Primary + obj->texttype_impl->primary_sum;
outbuff[lprimary++] = coll->Primary + impl->primary_sum;
if (coll->Secondary != NULL_SECONDARY && lsecondary < sizeof(secondary))
secondary[lsecondary++] = coll->Secondary;
if (coll->Tertiary != NULL_TERTIARY && ltertiary < sizeof(tertiary))
tertiary[ltertiary++] = coll->Tertiary;
}
else if (coll->IsExpand) {
const ExpandChar* exp = &((const ExpandChar*) obj->texttype_impl->texttype_expand_table)[0];
const ExpandChar* exp = &((const ExpandChar*) impl->texttype_expand_table)[0];
while (exp->Ch && exp->Ch != *pInChar)
exp++;
fb_assert(exp->Ch == *pInChar);
for (int j = 0; j < 2; j++) {
if (j)
coll =
&((const SortOrderTblEntry*) obj->texttype_impl->
&((const SortOrderTblEntry*) impl->
texttype_collation_table)[exp->ExpCh2];
if (coll->Primary != NULL_WEIGHT && lprimary < iOutLen)
outbuff[lprimary++] = coll->Primary + obj->texttype_impl->primary_sum;
outbuff[lprimary++] = coll->Primary + impl->primary_sum;
if (coll->Secondary != NULL_SECONDARY && lsecondary < sizeof(secondary))
secondary[lsecondary++] = coll->Secondary;
if (coll->Tertiary != NULL_TERTIARY && ltertiary < sizeof(tertiary))
@ -270,9 +273,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
const bool complete = (USHORT) (i + 1) < iInLen;
if (complete) {
const CompressPair* cmp =
&((const CompressPair*) obj->texttype_impl->
texttype_compress_table)[0];
const CompressPair* cmp = &((const CompressPair*) impl->texttype_compress_table)[0];
while (cmp->CharPair[0]) {
if ((cmp->CharPair[0] == *pInChar) &&
(cmp->CharPair[1] == *(pInChar + 1)))
@ -293,7 +294,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
if (key_type != INTL_KEY_PARTIAL || complete)
{
if (coll->Primary != NULL_WEIGHT && lprimary < iOutLen)
outbuff[lprimary++] = coll->Primary + obj->texttype_impl->primary_sum;
outbuff[lprimary++] = coll->Primary + impl->primary_sum;
if (coll->Secondary != NULL_SECONDARY && lsecondary < sizeof(secondary))
secondary[lsecondary++] = coll->Secondary;
if (coll->Tertiary != NULL_TERTIARY && ltertiary < sizeof(tertiary))
@ -313,9 +314,9 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
return (outbuff - pOutChar);
}
bool useLevel = !(obj->texttype_impl->texttype_flags & TEXTTYPE_secondary_insensitive);
bool useLevel = !(impl->texttype_flags & TEXTTYPE_secondary_insensitive);
if (!(obj->texttype_impl->texttype_flags & TEXTTYPE_non_multi_level)) // multi-level
if (!(impl->texttype_flags & TEXTTYPE_non_multi_level)) // multi-level
{
if (key_type == INTL_KEY_SORT)
useLevel = true;
@ -324,7 +325,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
if (useLevel)
{
/* put secondary keys into output key */
if (obj->texttype_impl->texttype_flags & TEXTTYPE_reverse_secondary) {
if (impl->texttype_flags & TEXTTYPE_reverse_secondary) {
for (i = 0; i < lsecondary && iOutLen; i++) {
*outbuff++ = secondary[lsecondary - i - 1];
iOutLen--;
@ -338,9 +339,9 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
}
}
useLevel = !(obj->texttype_impl->texttype_flags & TEXTTYPE_tertiary_insensitive);
useLevel = !(impl->texttype_flags & TEXTTYPE_tertiary_insensitive);
if (!(obj->texttype_impl->texttype_flags & TEXTTYPE_non_multi_level)) // multi-level
if (!(impl->texttype_flags & TEXTTYPE_non_multi_level)) // multi-level
{
if (key_type == INTL_KEY_SORT)
useLevel = true;
@ -356,8 +357,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
}
/* put special keys into output key */
if ((lspecial && iOutLen) &&
!(obj->texttype_impl->texttype_flags & TEXTTYPE_ignore_specials))
if ((lspecial && iOutLen) && !(impl->texttype_flags & TEXTTYPE_ignore_specials))
{
/* Insert the marker-byte */
*outbuff++ = 0;
@ -407,13 +407,13 @@ static SSHORT special_scan(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, co
ULONG index1 = 0;
ULONG index2 = 0;
const bool noSpecialsFirst = !(obj->texttype_impl->texttype_flags & TEXTTYPE_specials_first);
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
const bool noSpecialsFirst = !(impl->texttype_flags & TEXTTYPE_specials_first);
while (true) {
/* Scan to find ignore char from l1 */
while (l1) {
col1 =
&((const SortOrderTblEntry*) obj->texttype_impl->
texttype_collation_table)[*s1];
col1 = &((const SortOrderTblEntry*) impl->texttype_collation_table)[*s1];
if (col1->IsExpand && col1->IsCompress && noSpecialsFirst)
{
@ -427,9 +427,7 @@ static SSHORT special_scan(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, co
/* Scan to find ignore char from l2 */
while (l2) {
col2 =
&((const SortOrderTblEntry*) obj->texttype_impl->
texttype_collation_table)[*s2];
col2 = &((const SortOrderTblEntry*) impl->texttype_collation_table)[*s2];
if (col2->IsExpand && col2->IsCompress && noSpecialsFirst)
{
break;
@ -464,7 +462,9 @@ static SSHORT special_scan(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, co
static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
ULONG* l, coltab_status* stat, int* sum)
{
*sum = obj->texttype_impl->primary_sum;
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
*sum = impl->primary_sum;
if (stat->stat_flags & LC_HAVE_WAITING) {
--*l;
@ -477,14 +477,13 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
stat->stat_waiting = NULL;
while (*l) {
const SortOrderTblEntry* col =
&((const SortOrderTblEntry*) obj->texttype_impl->
texttype_collation_table)[**p];
&((const SortOrderTblEntry*) impl->texttype_collation_table)[**p];
if (col->IsExpand && col->IsCompress)
{
if (obj->texttype_impl->texttype_flags & TEXTTYPE_specials_first)
if (impl->texttype_flags & TEXTTYPE_specials_first)
{
*sum = obj->texttype_impl->ignore_sum;
*sum = impl->ignore_sum;
/* Have col */
--*l;
@ -500,8 +499,8 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
continue;
}
if (!((col->IsExpand && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(col->IsCompress && !(obj->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))))
if (!((col->IsExpand && !(impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(col->IsCompress && !(impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
/* Have col */
--*l;
@ -510,25 +509,21 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
}
if (col->IsExpand) {
const ExpandChar* exp = &((const ExpandChar*) obj->texttype_impl->texttype_expand_table)[0];
const ExpandChar* exp = &((const ExpandChar*) impl->texttype_expand_table)[0];
while (exp->Ch && exp->Ch != **p)
exp++;
fb_assert(exp->Ch == **p);
/* Have coll1 */
/* Have waiting */
stat->stat_waiting =
&((const SortOrderTblEntry*) obj->texttype_impl->
texttype_collation_table)[exp->ExpCh2];
stat->stat_waiting = &((const SortOrderTblEntry*) impl->texttype_collation_table)[exp->ExpCh2];
stat->stat_flags |= LC_HAVE_WAITING;
return col;
}
/* (col->IsCompress) */
if (*l > 1) {
const CompressPair* cmp =
&((const CompressPair*) obj->texttype_impl->
texttype_compress_table)[0];
const CompressPair* cmp = &((const CompressPair*) impl->texttype_compress_table)[0];
while (cmp->CharPair[0]) {
if ((cmp->CharPair[0] == **p) &&
(cmp->CharPair[1] == *(*p + 1)))
@ -562,6 +557,8 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
fb_assert(s2 != NULL);
fb_assert(error_flag != NULL);
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
*error_flag = false;
if (obj->texttype_pad_option)
@ -603,16 +600,16 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
break;
if (col1->Primary + sum1 != col2->Primary + sum2)
return ((col1->Primary + sum1) - (col2->Primary + sum2));
if ((obj->texttype_impl->texttype_flags & TEXTTYPE_secondary_insensitive) == 0 &&
if ((impl->texttype_flags & TEXTTYPE_secondary_insensitive) == 0 &&
col1->Secondary != col2->Secondary)
{
if ((obj->texttype_impl->texttype_flags & TEXTTYPE_reverse_secondary) ||
if ((impl->texttype_flags & TEXTTYPE_reverse_secondary) ||
!save_secondary)
{
save_secondary = (col1->Secondary - col2->Secondary);
}
}
else if ((obj->texttype_impl->texttype_flags & TEXTTYPE_tertiary_insensitive) == 0 &&
else if ((impl->texttype_flags & TEXTTYPE_tertiary_insensitive) == 0 &&
col1->Tertiary != col2->Tertiary)
{
if (!save_tertiary)
@ -621,7 +618,7 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
else if (((stat1.stat_flags & LC_HAVE_WAITING) XOR
(stat2.stat_flags & LC_HAVE_WAITING)) && !save_quandary)
{
if (obj->texttype_impl->texttype_flags & TEXTTYPE_expand_before)
if (impl->texttype_flags & TEXTTYPE_expand_before)
save_quandary = (stat1.stat_flags & LC_HAVE_WAITING) ? -1 : 1;
else
save_quandary = (stat1.stat_flags & LC_HAVE_WAITING) ? 1 : -1;
@ -645,11 +642,10 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
return save_tertiary;
if (save_quandary)
return save_quandary;
if (
((stat1.stat_flags & LC_HAVE_SPECIAL)
|| (stat2.stat_flags & LC_HAVE_SPECIAL))
&& !(obj->texttype_impl->texttype_flags & TEXTTYPE_ignore_specials)
&& !(obj->texttype_impl->texttype_flags & TEXTTYPE_specials_first))
if (((stat1.stat_flags & LC_HAVE_SPECIAL) ||
(stat2.stat_flags & LC_HAVE_SPECIAL)) &&
!(impl->texttype_flags & TEXTTYPE_ignore_specials) &&
!(impl->texttype_flags & TEXTTYPE_specials_first))
{
return special_scan(obj, save_l1, save_s1, save_l2, save_s2);
}
@ -737,29 +733,30 @@ ULONG LC_NARROW_canonical(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG d
fb_assert(src != NULL);
fb_assert(dstLen >= obj->texttype_canonical_width * srcLen);
TextTypeImpl* impl = static_cast<TextTypeImpl*>(obj->texttype_impl);
const BYTE* const inbuff = src;
for (ULONG i = 0; i < srcLen; i++, src++)
{
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)obj->texttype_impl->texttype_collation_table)[*src];
&((const SortOrderTblEntry*) impl->texttype_collation_table)[*src];
USHORT primary = coll->Primary;
if (coll->IsExpand && coll->IsCompress)
primary += obj->texttype_impl->ignore_sum_canonic;
primary += impl->ignore_sum_canonic;
else
primary += obj->texttype_impl->primary_sum_canonic;
primary += impl->primary_sum_canonic;
if ((obj->texttype_impl->texttype_flags & (TEXTTYPE_secondary_insensitive | TEXTTYPE_tertiary_insensitive)) == 0)
if ((impl->texttype_flags & (TEXTTYPE_secondary_insensitive | TEXTTYPE_tertiary_insensitive)) == 0)
{
put(dst, (USHORT) ((primary << 8) | (coll->Secondary << 4) | coll->Tertiary));
}
else if ((obj->texttype_impl->texttype_flags & TEXTTYPE_secondary_insensitive) == 0)
else if ((impl->texttype_flags & TEXTTYPE_secondary_insensitive) == 0)
{
put(dst, (USHORT) ((primary << 8) | coll->Secondary));
}
else if ((obj->texttype_impl->texttype_flags & TEXTTYPE_tertiary_insensitive) == 0)
else if ((impl->texttype_flags & TEXTTYPE_tertiary_insensitive) == 0)
{
put(dst, (USHORT) ((primary << 8) | coll->Tertiary));
}
@ -773,7 +770,7 @@ ULONG LC_NARROW_canonical(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG d
void LC_NARROW_destroy(texttype* obj)
{
delete obj->texttype_impl;
delete static_cast<TextTypeImpl*>(obj->texttype_impl);
}
@ -796,6 +793,8 @@ bool LC_NARROW_family2(
if (attributes & ~TEXTTYPE_ATTR_PAD_SPACE)
return false;
TextTypeImpl* impl = FB_NEW(*getDefaultMemoryPool()) TextTypeImpl;
tt->texttype_version = TEXTTYPE_VERSION_1;
tt->texttype_name = name;
tt->texttype_country = country;
@ -806,14 +805,15 @@ bool LC_NARROW_family2(
tt->texttype_fn_str_to_upper = fam2_str_to_upper;
tt->texttype_fn_str_to_lower = fam2_str_to_lower;
tt->texttype_fn_destroy = LC_NARROW_destroy;
tt->texttype_impl = FB_NEW(*getDefaultMemoryPool()) TextTypeImpl;
tt->texttype_impl->texttype_collation_table = (const BYTE*) noCaseOrderTbl;
tt->texttype_impl->texttype_toupper_table = toUpperConversionTbl;
tt->texttype_impl->texttype_tolower_table = toLowerConversionTbl;
tt->texttype_impl->texttype_compress_table = (const BYTE*) compressTbl;
tt->texttype_impl->texttype_expand_table = (const BYTE*) expansionTbl;
tt->texttype_impl->texttype_flags = ((flags) & REVERSE) ? TEXTTYPE_reverse_secondary : 0;
tt->texttype_impl->texttype_bytes_per_key = 0;
tt->texttype_impl = impl;
impl->texttype_collation_table = (const BYTE*) noCaseOrderTbl;
impl->texttype_toupper_table = toUpperConversionTbl;
impl->texttype_tolower_table = toLowerConversionTbl;
impl->texttype_compress_table = (const BYTE*) compressTbl;
impl->texttype_expand_table = (const BYTE*) expansionTbl;
impl->texttype_flags = ((flags) & REVERSE) ? TEXTTYPE_reverse_secondary : 0;
impl->texttype_bytes_per_key = 0;
IntlUtil::SpecificAttributesMap map;
Jrd::CharSet* charSet = NULL;
@ -843,21 +843,21 @@ bool LC_NARROW_family2(
{
++validAttributeCount;
if (value == "1")
tt->texttype_impl->texttype_flags |= TEXTTYPE_disable_compressions;
impl->texttype_flags |= TEXTTYPE_disable_compressions;
}
if (map.get("DISABLE-EXPANSIONS", value) && (value == "0" || value == "1"))
{
++validAttributeCount;
if (value == "1")
tt->texttype_impl->texttype_flags |= TEXTTYPE_disable_expansions;
impl->texttype_flags |= TEXTTYPE_disable_expansions;
}
int minPrimary = INT_MAX;
int maxIgnore = 0;
int maxPrimary = 0;
if (!(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))
if (!(impl->texttype_flags & TEXTTYPE_disable_compressions))
{
while (compressTbl->CharPair[0])
{
@ -874,15 +874,15 @@ bool LC_NARROW_family2(
for (int ch = 0; ch <= 255; ++ch)
{
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)tt->texttype_impl->texttype_collation_table)[ch];
&((const SortOrderTblEntry*) impl->texttype_collation_table)[ch];
if (coll->IsExpand && coll->IsCompress)
{
if (coll->Primary > maxIgnore)
maxIgnore = coll->Primary;
}
else if (!((coll->IsExpand && !(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(coll->IsCompress && !(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))))
else if (!((coll->IsExpand && !(impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(coll->IsCompress && !(impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
if (coll->Primary > maxPrimary)
maxPrimary = coll->Primary;
@ -900,17 +900,17 @@ bool LC_NARROW_family2(
if (value == "1")
{
tt->texttype_impl->texttype_flags |= TEXTTYPE_specials_first;
tt->texttype_impl->ignore_sum = minPrimary - 1;
tt->texttype_impl->primary_sum = maxIgnore - 1;
impl->texttype_flags |= TEXTTYPE_specials_first;
impl->ignore_sum = minPrimary - 1;
impl->primary_sum = maxIgnore - 1;
}
}
}
if (maxIgnore > 0 && maxPrimary + maxIgnore - 1 <= 255)
{
tt->texttype_impl->ignore_sum_canonic = minPrimary - 1;
tt->texttype_impl->primary_sum_canonic = maxIgnore - 1;
impl->ignore_sum_canonic = minPrimary - 1;
impl->primary_sum_canonic = maxIgnore - 1;
}
if (map.count() - validAttributeCount != 0)
@ -981,12 +981,14 @@ bool LC_NARROW_family3(
attributes & ~(TEXTTYPE_ATTR_CASE_INSENSITIVE | TEXTTYPE_ATTR_ACCENT_INSENSITIVE),
specificAttributes, specificAttributesLength))
{
TextTypeImpl* impl = static_cast<TextTypeImpl*>(tt->texttype_impl);
if (!multiLevel)
tt->texttype_impl->texttype_flags |= TEXTTYPE_non_multi_level;
impl->texttype_flags |= TEXTTYPE_non_multi_level;
if (attributes & (TEXTTYPE_ATTR_CASE_INSENSITIVE | TEXTTYPE_ATTR_ACCENT_INSENSITIVE))
{
tt->texttype_impl->texttype_flags |= TEXTTYPE_ignore_specials;
impl->texttype_flags |= TEXTTYPE_ignore_specials;
if (multiLevel)
{
@ -1010,10 +1012,10 @@ bool LC_NARROW_family3(
tt->texttype_fn_canonical = LC_NARROW_canonical;
if (attributes & TEXTTYPE_ATTR_ACCENT_INSENSITIVE)
tt->texttype_impl->texttype_flags |= TEXTTYPE_secondary_insensitive;
impl->texttype_flags |= TEXTTYPE_secondary_insensitive;
if (attributes & TEXTTYPE_ATTR_CASE_INSENSITIVE)
tt->texttype_impl->texttype_flags |= TEXTTYPE_tertiary_insensitive;
impl->texttype_flags |= TEXTTYPE_tertiary_insensitive;
}
return true;
@ -1033,7 +1035,7 @@ static ULONG fam2_str_to_upper(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
*pOutStr++ = (obj->texttype_impl->texttype_toupper_table[(unsigned) *pStr]);
*pOutStr++ = static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_toupper_table[(unsigned) *pStr];
pStr++;
iLen--;
iOutLen--;
@ -1054,7 +1056,7 @@ static ULONG fam2_str_to_lower(texttype* obj, ULONG iLen, const BYTE* pStr, ULON
fb_assert(iOutLen >= iLen);
const BYTE* const p = pOutStr;
while (iLen && iOutLen) {
*pOutStr++ = (obj->texttype_impl->texttype_tolower_table[(unsigned) *pStr]);
*pOutStr++ = static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_tolower_table[(unsigned) *pStr];
pStr++;
iLen--;
iOutLen--;

View File

@ -649,14 +649,14 @@ bool IntlUtil::readAttributeChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR*
static void unicodeDestroy(texttype* tt)
{
delete [] const_cast<ASCII*>(tt->texttype_name);
delete tt->texttype_impl;
delete static_cast<TextTypeImpl*>(tt->texttype_impl);
}
static USHORT unicodeKeyLength(texttype* tt, USHORT len)
{
return tt->texttype_impl->collation->keyLength(
len / tt->texttype_impl->cs->charset_max_bytes_per_char * 4);
return static_cast<TextTypeImpl*>(tt->texttype_impl)->collation->keyLength(
len / static_cast<TextTypeImpl*>(tt->texttype_impl)->cs->charset_max_bytes_per_char * 4);
}
@ -665,7 +665,7 @@ static USHORT unicodeStrToKey(texttype* tt, USHORT srcLen, const UCHAR* src,
{
try
{
charset* cs = tt->texttype_impl->cs;
charset* cs = static_cast<TextTypeImpl*>(tt->texttype_impl)->cs;
HalfStaticArray<UCHAR, BUFFER_SMALL> utf16Str;
USHORT errorCode;
@ -690,7 +690,7 @@ static USHORT unicodeStrToKey(texttype* tt, USHORT srcLen, const UCHAR* src,
&errorCode,
&offendingPos);
return tt->texttype_impl->collation->stringToKey(
return static_cast<TextTypeImpl*>(tt->texttype_impl)->collation->stringToKey(
utf16Len, (USHORT*)utf16Str.begin(), dstLen, dst, keyType);
}
catch (BadAlloc)
@ -708,7 +708,7 @@ static SSHORT unicodeCompare(texttype* tt, ULONG len1, const UCHAR* str1,
{
*errorFlag = false;
charset* cs = tt->texttype_impl->cs;
charset* cs = static_cast<TextTypeImpl*>(tt->texttype_impl)->cs;
HalfStaticArray<UCHAR, BUFFER_SMALL> utf16Str1;
HalfStaticArray<UCHAR, BUFFER_SMALL> utf16Str2;
@ -753,7 +753,7 @@ static SSHORT unicodeCompare(texttype* tt, ULONG len1, const UCHAR* str1,
&errorCode,
&offendingPos);
return tt->texttype_impl->collation->compare(
return static_cast<TextTypeImpl*>(tt->texttype_impl)->collation->compare(
utf16Len1, (USHORT*)utf16Str1.begin(),
utf16Len2, (USHORT*)utf16Str2.begin(), errorFlag);
}
@ -769,7 +769,7 @@ static ULONG unicodeCanonical(texttype* tt, ULONG srcLen, const UCHAR* src, ULON
{
try
{
charset* cs = tt->texttype_impl->cs;
charset* cs = static_cast<TextTypeImpl*>(tt->texttype_impl)->cs;
HalfStaticArray<UCHAR, BUFFER_SMALL> utf16Str;
USHORT errorCode;
@ -794,7 +794,7 @@ static ULONG unicodeCanonical(texttype* tt, ULONG srcLen, const UCHAR* src, ULON
&errorCode,
&offendingPos);
return tt->texttype_impl->collation->canonical(
return static_cast<TextTypeImpl*>(tt->texttype_impl)->collation->canonical(
utf16Len, Firebird::Aligner<USHORT>(utf16Str.begin(), utf16Len),
dstLen, Firebird::OutAligner<ULONG>(dst, dstLen), NULL);
}

View File

@ -59,7 +59,7 @@ static inline bool FAMILY_INTERNAL(texttype* tt,
tt->texttype_fn_str_to_lower = internal_str_to_lower;
tt->texttype_fn_destroy = internal_destroy;
tt->texttype_impl = new TextTypeImpl;
tt->texttype_impl->texttype_pad_char = ' ';
static_cast<TextTypeImpl*>(tt->texttype_impl)->texttype_pad_char = ' ';
return true;
}
@ -471,7 +471,7 @@ static USHORT internal_string_to_key(
*
**************************************/
const UCHAR* const pStart = dest;
const UCHAR pad_char = obj->texttype_impl->texttype_pad_char;
const UCHAR pad_char = static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_pad_char;
while (inLen-- && outLen--)
*dest++ = *src++;
@ -502,7 +502,7 @@ static SSHORT internal_compare(
* Functional description
*
**************************************/
const UCHAR pad = obj->texttype_impl->texttype_pad_char;
const UCHAR pad = static_cast<TextTypeImpl*>(obj->texttype_impl)->texttype_pad_char;
SLONG fill = length1 - length2;
if (length1 >= length2) {
if (length2)
@ -606,7 +606,7 @@ static void internal_destroy(texttype* obj)
* Functional description
*
**************************************/
delete obj->texttype_impl;
delete static_cast<TextTypeImpl*>(obj->texttype_impl);
}
@ -1017,7 +1017,7 @@ static INTL_BOOL ttype_binary_init(texttype* tt, const ASCII* texttype_name, con
{
tt->texttype_fn_str_to_upper = internal_str_copy;
tt->texttype_fn_str_to_lower = internal_str_copy;
tt->texttype_impl->texttype_pad_char = '\0';
static_cast<TextTypeImpl*>(tt->texttype_impl)->texttype_pad_char = '\0';
return true;
}

View File

@ -45,19 +45,6 @@ typedef SCHAR ASCII;
typedef USHORT INTL_BOOL;
#ifdef __cplusplus
namespace {
#endif
/* Forward declarations to be implemented in collation driver */
struct TextTypeImpl;
struct CharSetImpl;
struct CsConvertImpl;
#ifdef __cplusplus
}
#endif
struct texttype; /* forward decl for the fc signatures before the struct itself. */
struct csconvert;
struct charset;
@ -150,7 +137,7 @@ typedef void (*pfn_INTL_tt_destroy) (
struct texttype {
/* Data which needs to be initialized by collation driver */
USHORT texttype_version; /* version ID of object */
TextTypeImpl* texttype_impl; /* collation object implemented in driver */
void* texttype_impl; /* collation object implemented in driver */
/* Used only for debugging purposes. Should contain string in form
<charset>.<collation>. For example "WIN1251.PXW_CYRL"
@ -225,7 +212,7 @@ typedef void (*pfn_INTL_cv_destroy) (
struct csconvert {
USHORT csconvert_version;
CsConvertImpl* csconvert_impl;
void* csconvert_impl;
/* Used only for debugging purposes. Should contain string in form
<source_charset>-><destination_charset>. For example "WIN1251->DOS866"
@ -298,7 +285,7 @@ typedef void (*pfn_INTL_cs_destroy) (
struct charset
{
USHORT charset_version;
CharSetImpl* charset_impl;
void* charset_impl;
const ASCII* charset_name;
BYTE charset_min_bytes_per_char;
BYTE charset_max_bytes_per_char;