2007-11-03 11:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/rtl/cdpapi.c
    * some minor speed improvement

  * harbour/source/rdd/dbfntx/dbfntx1.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
    * use hb_cdpSelect() instead of direct accessing hb_cdp_page variable
This commit is contained in:
Przemyslaw Czerpak
2007-11-03 10:06:02 +00:00
parent 0f48d95dc6
commit c944fb87e4
4 changed files with 56 additions and 54 deletions

View File

@@ -8,6 +8,14 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-11-03 11:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/rtl/cdpapi.c
* some minor speed improvement
* harbour/source/rdd/dbfntx/dbfntx1.c
* harbour/source/rdd/dbfcdx/dbfcdx1.c
* use hb_cdpSelect() instead of direct accessing hb_cdp_page variable
2007-11-02 22:09 UTC-0600 Teo Fonrouge (teo/at/windtelsoft/dot/com)
* contrib/directx/makefile.vc
* contrib/hbzlib/makefile.vc

View File

@@ -731,9 +731,7 @@ static LPCDXKEY hb_cdxKeyEval( LPCDXKEY pKey, LPCDXTAG pTag )
CDXAREAP pArea = pTag->pIndex->pArea;
PHB_ITEM pItem;
#ifndef HB_CDP_SUPPORT_OFF
/* TODO: this hack is not thread safe, hb_cdp_page has to be thread specific */
PHB_CODEPAGE cdpTmp = hb_cdp_page;
hb_cdp_page = pArea->cdPage;
PHB_CODEPAGE cdpTmp = hb_cdpSelect( pArea->cdPage );
#endif
if ( pTag->nField )
@@ -760,7 +758,7 @@ static LPCDXKEY hb_cdxKeyEval( LPCDXKEY pKey, LPCDXTAG pTag )
}
#ifndef HB_CDP_SUPPORT_OFF
hb_cdp_page = cdpTmp;
hb_cdpSelect( cdpTmp );
#endif
return pKey;
@@ -5409,7 +5407,7 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward,
PHB_ITEM pWildItm )
{
BOOL fFound = FALSE, fFirst = TRUE;
char *szPattern = hb_itemGetCPtr( pWildItm );
char *szPattern, *szFree = NULL;
int iFixed = 0, iStop;
HB_TRACE(HB_TR_DEBUG, ("hb_cdxDBOISkipWild(%p, %p, %i, %p)", pArea, pTag, fForward, pWildItm));
@@ -5417,6 +5415,8 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward,
if ( FAST_GOCOLD( ( AREAP ) pArea ) == FAILURE )
return FALSE;
szPattern = hb_itemGetCPtr( pWildItm );
if ( ! pTag || pTag->uiType != 'C' || !szPattern || !*szPattern )
{
if ( SELF_SKIP( ( AREAP ) pArea, fForward ? 1 : -1 ) == FAILURE )
@@ -5427,7 +5427,7 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward,
#ifndef HB_CDP_SUPPORT_OFF
if( pArea->cdPage != hb_cdp_page )
{
szPattern = hb_strdup( szPattern );
szPattern = szFree = hb_strdup( szPattern );
hb_cdpTranslate( szPattern, hb_cdp_page, pArea->cdPage );
}
#endif
@@ -5544,12 +5544,8 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward,
else
pArea->fEof = FALSE;
#ifndef HB_CDP_SUPPORT_OFF
if( pArea->cdPage != hb_cdp_page )
{
hb_xfree( szPattern );
}
#endif
if( szFree )
hb_xfree( szFree );
return fFound;
}
@@ -5562,7 +5558,7 @@ static BOOL hb_cdxRegexMatch( CDXAREAP pArea, PHB_REGEX pRegEx, LPCDXKEY pKey )
if( pArea->cdPage != hb_cdp_page )
{
hb_strncpy( szBuff, szKey, pKey->len );
memcpy( szBuff, szKey, pKey->len + 1 );
hb_cdpnTranslate( szBuff, pArea->cdPage, hb_cdp_page, pKey->len );
szKey = szBuff;
}
@@ -9224,9 +9220,7 @@ static void hb_cdxTagDoIndex( LPCDXTAG pTag, BOOL fReindex )
ULONG ulRecCount, ulRecNo = pArea->ulRecNo;
LONG lStep = 0;
#ifndef HB_CDP_SUPPORT_OFF
/* TODO: this hack is not thread safe, hb_cdp_page has to be thread specific */
PHB_CODEPAGE cdpTmp = hb_cdp_page;
hb_cdp_page = pArea->cdPage;
PHB_CODEPAGE cdpTmp = hb_cdpSelect( pArea->cdPage );
#endif
if ( pArea->lpdbOrdCondInfo )
@@ -9496,7 +9490,7 @@ static void hb_cdxTagDoIndex( LPCDXTAG pTag, BOOL fReindex )
pArea->pSort = NULL;
#ifndef HB_CDP_SUPPORT_OFF
hb_cdp_page = cdpTmp;
hb_cdpSelect( cdpTmp );
#endif
}

View File

@@ -594,9 +594,7 @@ static LPKEYINFO hb_ntxEvalKey( LPKEYINFO pKey, LPTAGINFO pTag )
NTXAREAP pArea = pTag->Owner->Owner;
PHB_ITEM pItem;
#ifndef HB_CDP_SUPPORT_OFF
/* TODO%: this hack is not thread safe, hb_cdp_page has to be thread specific */
PHB_CODEPAGE cdpTmp = hb_cdp_page;
hb_cdp_page = pArea->cdPage;
PHB_CODEPAGE cdpTmp = hb_cdpSelect( pArea->cdPage );
#endif
if( pTag->nField )
@@ -623,7 +621,7 @@ static LPKEYINFO hb_ntxEvalKey( LPKEYINFO pKey, LPTAGINFO pTag )
}
#ifndef HB_CDP_SUPPORT_OFF
hb_cdp_page = cdpTmp;
hb_cdpSelect( cdpTmp );
#endif
return pKey;
@@ -4154,12 +4152,14 @@ static BOOL hb_ntxOrdSkipEval( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pEval )
static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm )
{
NTXAREAP pArea = pTag->Owner->Owner;
char *szPattern = hb_itemGetCPtr( pWildItm );
char *szPattern, *szFree = NULL;
BOOL fFound = FALSE;
int iFixed = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_ntxOrdSkipWild(%p, %d, %p)", pTag, fForward, pWildItm));
szPattern = hb_itemGetCPtr( pWildItm );
if( pTag->KeyType != 'C' || !szPattern || !*szPattern )
{
if( SELF_SKIP( ( AREAP ) pArea, fForward ? 1 : -1 ) != SUCCESS )
@@ -4170,7 +4170,7 @@ static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm
#ifndef HB_CDP_SUPPORT_OFF
if( pArea->cdPage != hb_cdp_page )
{
szPattern = hb_strdup( szPattern );
szPattern = szFree = hb_strdup( szPattern );
hb_cdpTranslate( szPattern, hb_cdp_page, pArea->cdPage );
}
#endif
@@ -4266,12 +4266,8 @@ static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm
else
pArea->fEof = FALSE;
#ifndef HB_CDP_SUPPORT_OFF
if( pArea->cdPage != hb_cdp_page )
{
if( szFree )
hb_xfree( szPattern );
}
#endif
return fFound;
}
@@ -4283,7 +4279,7 @@ static BOOL hb_ntxRegexMatch( LPTAGINFO pTag, PHB_REGEX pRegEx, char * szKey )
if( pTag->Owner->Owner->cdPage != hb_cdp_page )
{
hb_strncpy( szBuff, pTag->CurKeyInfo->key, pTag->KeyLength );
memcpy( szBuff, pTag->CurKeyInfo->key, pTag->KeyLength + 1 );
hb_cdpnTranslate( szBuff, pTag->Owner->Owner->cdPage, hb_cdp_page, pTag->KeyLength );
szKey = szBuff;
}
@@ -5263,9 +5259,7 @@ static ERRCODE hb_ntxTagCreate( LPTAGINFO pTag, BOOL fReindex )
char szBuffer[ NTX_MAX_KEY ];
int iRecBuff = 0, iRecBufSize, iRec;
#ifndef HB_CDP_SUPPORT_OFF
/* TODO%: this hack is not thread safe, hb_cdp_page has to be thread specific */
PHB_CODEPAGE cdpTmp = hb_cdp_page;
hb_cdp_page = pArea->cdPage;
PHB_CODEPAGE cdpTmp = hb_cdpSelect( pArea->cdPage );
#endif
pForItem = pTag->pForItem;
@@ -5465,7 +5459,7 @@ static ERRCODE hb_ntxTagCreate( LPTAGINFO pTag, BOOL fReindex )
pArea->lpCurTag = pSaveTag;
#ifndef HB_CDP_SUPPORT_OFF
hb_cdp_page = cdpTmp;
hb_cdpSelect( cdpTmp );
#endif
}

View File

@@ -323,8 +323,8 @@ HB_EXPORT BOOL hb_cdpRegister( PHB_CODEPAGE cdpage )
for( i=0; i<256; i++ )
{
cdpage->s_upper[i] = toupper( (BYTE) i&255 );
cdpage->s_lower[i] = tolower( (BYTE) i&255 );
cdpage->s_upper[i] = toupper( ( UCHAR ) i );
cdpage->s_lower[i] = tolower( ( UCHAR ) i );
}
if( strpbrk(cdpage->CharsUpper, "~.") != NULL )
{
@@ -365,8 +365,8 @@ HB_EXPORT BOOL hb_cdpRegister( PHB_CODEPAGE cdpage )
cdpage->lSort = TRUE;
continue;
}
iu = ((int)*ptrUpper)&255;
il = ((int)*ptrLower)&255;
iu = ( UCHAR ) * ptrUpper;
il = ( UCHAR ) * ptrLower;
if( iu < iumax || il < ilmax )
cdpage->lSort = TRUE;
iumax = iu; ilmax = il;
@@ -388,7 +388,7 @@ HB_EXPORT BOOL hb_cdpRegister( PHB_CODEPAGE cdpage )
if( !cdpage->s_chars[i] )
cdpage->s_chars[i] = cdpage->nChars + (i-90);
}
for( i=123; i<=255; i++ )
for( i=123; i<256; i++ )
{
if( !cdpage->s_chars[i] )
cdpage->s_chars[i] = cdpage->nChars + nAddLower + (i-122);
@@ -463,16 +463,16 @@ HB_EXPORT char * hb_cdpSelectID( const char * pszID )
return pszIDOld;
}
HB_EXPORT void hb_cdpTranslate( char* psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut )
HB_EXPORT void hb_cdpTranslate( char* psz, PHB_CODEPAGE cdpIn,
PHB_CODEPAGE cdpOut )
{
int n;
if( cdpIn != cdpOut && cdpIn->nChars == cdpOut->nChars )
{
int nAddLower = (cdpIn->lLatin)? 6:0;
for( ; *psz; psz++ )
{
n = (int)cdpIn->s_chars[ ((int)*psz)&255 ];
int n = ( int ) cdpIn->s_chars[( UCHAR ) * psz];
if( n != 0 &&
( n <= cdpOut->nChars || ( n > (cdpOut->nChars+nAddLower) &&
n <= (cdpOut->nChars*2+nAddLower) ) ) )
@@ -485,17 +485,15 @@ HB_EXPORT void hb_cdpTranslate( char* psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpO
}
}
HB_EXPORT void hb_cdpnTranslate( char* psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut, ULONG nChars )
HB_EXPORT void hb_cdpnTranslate( char* psz, PHB_CODEPAGE cdpIn,
PHB_CODEPAGE cdpOut, ULONG nChars )
{
int n;
ULONG i;
if( cdpIn != cdpOut && cdpIn->nChars == cdpOut->nChars )
{
int nAddLower = (cdpIn->lLatin)? 6:0;
for( i=0; i<nChars; i++,psz++ )
for( ; nChars--; psz++ )
{
n = (int)cdpIn->s_chars[ ((int)*psz)&255 ];
int n = ( int ) cdpIn->s_chars[( UCHAR ) * psz];
if( n != 0 &&
( n <= cdpOut->nChars || ( n > (cdpOut->nChars+nAddLower) &&
n <= (cdpOut->nChars*2+nAddLower) ) ) )
@@ -644,7 +642,8 @@ HB_EXPORT ULONG hb_cdpUTF8StringLength( const BYTE * pSrc, ULONG ulLen )
return ulDst;
}
HB_EXPORT ULONG hb_cdpStringInUTF8Length( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE * pSrc, ULONG ulLen )
HB_EXPORT ULONG hb_cdpStringInUTF8Length( PHB_CODEPAGE cdp, BOOL fCtrl,
const BYTE * pSrc, ULONG ulLen )
{
ULONG ul, ulDst;
@@ -698,7 +697,8 @@ HB_EXPORT ULONG hb_cdpUTF8ToStrn( PHB_CODEPAGE cdp, BOOL fCtrl,
return ulD;
}
HB_EXPORT BOOL hb_cdpGetFromUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch, int * n, USHORT * uc )
HB_EXPORT BOOL hb_cdpGetFromUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch,
int * n, USHORT * uc )
{
if( utf8tou16nextchar( ch, n, uc ) )
{
@@ -720,7 +720,8 @@ HB_EXPORT BOOL hb_cdpGetFromUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch, int * n
return FALSE;
}
HB_EXPORT ULONG hb_cdpStrnToUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE* pSrc, ULONG ulLen, BYTE* pDst )
HB_EXPORT ULONG hb_cdpStrnToUTF8( PHB_CODEPAGE cdp, BOOL fCtrl,
const BYTE* pSrc, ULONG ulLen, BYTE* pDst )
{
USHORT u, *uniCodes, nChars;
ULONG i, n;
@@ -763,7 +764,8 @@ HB_EXPORT ULONG hb_cdpStrnToUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE* pSrc
return n;
}
HB_EXPORT ULONG hb_cdpStrnToU16( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE* pSrc, ULONG ulLen, BYTE* pDst )
HB_EXPORT ULONG hb_cdpStrnToU16( PHB_CODEPAGE cdp, BOOL fCtrl,
const BYTE* pSrc, ULONG ulLen, BYTE* pDst )
{
USHORT u, *uniCodes, nChars;
ULONG i;
@@ -840,7 +842,9 @@ static int hb_cdpMultiWeight( PHB_CODEPAGE cdpage, const char * szChar )
return 0;
}
HB_EXPORT int hb_cdpcmp( const char* szFirst, ULONG ulLenFirst, const char* szSecond, ULONG ulLenSecond, PHB_CODEPAGE cdpage, BOOL fExact )
HB_EXPORT int hb_cdpcmp( const char* szFirst, ULONG ulLenFirst,
const char* szSecond, ULONG ulLenSecond,
PHB_CODEPAGE cdpage, BOOL fExact )
{
int iRet = 0, iAcc = 0, n1 = 0, n2 = 0;
ULONG ul, ulLen;
@@ -975,7 +979,9 @@ static int hb_cdpMultiWeightI( PHB_CODEPAGE cdpage, const char * szChar )
return 0;
}
HB_EXPORT int hb_cdpicmp( const char* szFirst, ULONG ulLenFirst, const char* szSecond, ULONG ulLenSecond, PHB_CODEPAGE cdpage, BOOL fExact )
HB_EXPORT int hb_cdpicmp( const char* szFirst, ULONG ulLenFirst,
const char* szSecond, ULONG ulLenSecond,
PHB_CODEPAGE cdpage, BOOL fExact )
{
int iRet = 0, iAcc = 0, n1 = 0, n2 = 0, u1, u2;
ULONG ul, ulLen;