2017-09-07 08:38 UTC Viktor Szakats (vszakats users.noreply.github.com)
* contrib/hbct/charsprd.c
* contrib/hbct/dattime3.c
* contrib/hbct/expand.c
* contrib/hbct/misc2.c
* contrib/hbct/screen2.c
* contrib/hbcurl/core.c
* contrib/hbfship/strpeek.c
* contrib/hbnetio/netiocli.c
* contrib/hbwin/olecore.c
* contrib/rddads/adsx.c
* contrib/rddads/rddads.h
* contrib/rddsql/sqlmix.c
* contrib/sddmy/core.c
* contrib/sddpg/core.c
* contrib/xhb/hbcompat.h
* contrib/xhb/hbxml.c
* contrib/xhb/xhb.h
* src/common/hbstr.c
* src/compiler/harbour.y
* src/compiler/harbour.yyc
* src/compiler/hbcmplib.c
* src/macro/macrolex.c
* src/rdd/dbffpt/dbffpt1.c
* src/rdd/hbsix/sxcompr.c
* src/rdd/hbsix/sxcrypt.c
* src/rdd/hbsix/sxtable.c
* src/rdd/hsx/hsx.c
* src/rtl/cdpapi.c
* src/rtl/gtcrs/gtcrs.c
* src/rtl/gtxwc/gtxwc.c
* src/rtl/hbtoken.c
* src/rtl/net.c
* src/rtl/netusr.c
* src/vm/hvm.c
* update HB_SIZE variable name prefixes to use `n` instead of `ul`
% adjust some variables
% sync variables scopes and some other minor things with 3.4 fork
This commit is contained in:
380
src/rtl/cdpapi.c
380
src/rtl/cdpapi.c
@@ -295,10 +295,10 @@ static int hb_cdpStd_cmp( PHB_CODEPAGE cdp,
|
||||
HB_BOOL fExact )
|
||||
{
|
||||
int iRet = 0, iAcc = 0, n1, n2;
|
||||
HB_SIZE ul, nLen;
|
||||
HB_SIZE nPos, nLen;
|
||||
|
||||
nLen = nLenFirst < nLenSecond ? nLenFirst : nLenSecond;
|
||||
for( ul = 0; ul < nLen; ++szFirst, ++szSecond, ++ul )
|
||||
for( nPos = 0; nPos < nLen; ++szFirst, ++szSecond, ++nPos )
|
||||
{
|
||||
if( *szFirst != *szSecond )
|
||||
{
|
||||
@@ -338,19 +338,19 @@ static int hb_cdpStd_cmpi( PHB_CODEPAGE cdp,
|
||||
const char * szSecond, HB_SIZE nLenSecond,
|
||||
HB_BOOL fExact )
|
||||
{
|
||||
int iRet = 0, iAcc = 0, n1, n2, u1, u2;
|
||||
HB_SIZE ul, nLen;
|
||||
int iRet = 0, iAcc = 0;
|
||||
HB_SIZE nPos, nLen;
|
||||
|
||||
nLen = nLenFirst < nLenSecond ? nLenFirst : nLenSecond;
|
||||
for( ul = 0; ul < nLen; ++szFirst, ++szSecond, ++ul )
|
||||
for( nPos = 0; nPos < nLen; ++szFirst, ++szSecond, ++nPos )
|
||||
{
|
||||
u1 = cdp->upper[ ( HB_UCHAR ) *szFirst ];
|
||||
u2 = cdp->upper[ ( HB_UCHAR ) *szSecond ];
|
||||
int u1 = cdp->upper[ ( HB_UCHAR ) *szFirst ];
|
||||
int u2 = cdp->upper[ ( HB_UCHAR ) *szSecond ];
|
||||
|
||||
if( u1 != u2 )
|
||||
{
|
||||
n1 = ( HB_UCHAR ) cdp->sort[ u1 ];
|
||||
n2 = ( HB_UCHAR ) cdp->sort[ u2 ];
|
||||
int n1 = ( HB_UCHAR ) cdp->sort[ u1 ];
|
||||
int n2 = ( HB_UCHAR ) cdp->sort[ u2 ];
|
||||
if( n1 != n2 )
|
||||
{
|
||||
iRet = ( n1 < n2 ) ? -1 : 1;
|
||||
@@ -524,10 +524,11 @@ static HB_BOOL hb_cdpMulti_put( PHB_CODEPAGE cdp,
|
||||
|
||||
static int hb_cdpMulti_len( PHB_CODEPAGE cdp, HB_WCHAR wc )
|
||||
{
|
||||
int i, n = 1;
|
||||
int n = 1;
|
||||
|
||||
if( wc )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < cdp->nMulti; ++i )
|
||||
{
|
||||
if( wc == cdp->multi[ i ].wcUp ||
|
||||
@@ -566,18 +567,20 @@ static int hb_cdpMulti_cmp( PHB_CODEPAGE cdp,
|
||||
const char * szSecond, HB_SIZE nLenSecond,
|
||||
HB_BOOL fExact )
|
||||
{
|
||||
int iRet = 0, iAcc = 0, n, n1, n2;
|
||||
HB_SIZE ul, nLen;
|
||||
int iRet = 0, iAcc = 0, n;
|
||||
HB_SIZE nPos, nLen;
|
||||
|
||||
nLen = nLenFirst < nLenSecond ? nLenFirst : nLenSecond;
|
||||
for( ul = 0; ul < nLen; ++szFirst, ++szSecond, ++ul )
|
||||
for( nPos = 0; nPos < nLen; ++szFirst, ++szSecond, ++nPos )
|
||||
{
|
||||
int n1, n2;
|
||||
|
||||
HB_UCHAR u1 = ( HB_UCHAR ) *szFirst;
|
||||
HB_UCHAR u2 = ( HB_UCHAR ) *szSecond;
|
||||
|
||||
n1 = cdp->sort[ u1 ];
|
||||
if( ( cdp->flags[ u1 ] & HB_CDP_MULTI1 ) != 0 &&
|
||||
( ul < nLenFirst - 1 ) &&
|
||||
( nPos < nLenFirst - 1 ) &&
|
||||
( cdp->flags[ ( HB_UCHAR ) szFirst[ 1 ] ] & HB_CDP_MULTI2 ) != 0 )
|
||||
{
|
||||
n = hb_cdpMulti_weight( cdp, szFirst );
|
||||
@@ -591,7 +594,7 @@ static int hb_cdpMulti_cmp( PHB_CODEPAGE cdp,
|
||||
}
|
||||
n2 = cdp->sort[ u2 ];
|
||||
if( ( cdp->flags[ u2 ] & HB_CDP_MULTI1 ) != 0 &&
|
||||
( ul < nLenSecond - 1 ) &&
|
||||
( nPos < nLenSecond - 1 ) &&
|
||||
( cdp->flags[ ( HB_UCHAR ) szSecond[ 1 ] ] & HB_CDP_MULTI2 ) != 0 )
|
||||
{
|
||||
n = hb_cdpMulti_weight( cdp, szSecond );
|
||||
@@ -666,17 +669,19 @@ static int hb_cdpMulti_cmpi( PHB_CODEPAGE cdp,
|
||||
const char * szSecond, HB_SIZE nLenSecond,
|
||||
HB_BOOL fExact )
|
||||
{
|
||||
int iRet = 0, iAcc = 0, n, n1, n2, u1, u2;
|
||||
HB_SIZE ul, nLen;
|
||||
int iRet = 0, iAcc = 0;
|
||||
HB_SIZE nPos, nLen;
|
||||
|
||||
nLen = nLenFirst < nLenSecond ? nLenFirst : nLenSecond;
|
||||
for( ul = 0; ul < nLen; ++szFirst, ++szSecond, ++ul )
|
||||
for( nPos = 0; nPos < nLen; ++szFirst, ++szSecond, ++nPos )
|
||||
{
|
||||
int n, u1, u2, n1, n2;
|
||||
|
||||
u1 = cdp->upper[ ( HB_UCHAR ) *szFirst ];
|
||||
u2 = cdp->upper[ ( HB_UCHAR ) *szSecond ];
|
||||
|
||||
if( ( cdp->flags[ u1 ] & HB_CDP_MULTI1 ) != 0 &&
|
||||
( ul < nLenFirst - 1 ) &&
|
||||
( nPos < nLenFirst - 1 ) &&
|
||||
( cdp->flags[ ( HB_UCHAR ) szFirst[ 1 ] ] & HB_CDP_MULTI2 ) != 0 )
|
||||
{
|
||||
n = hb_cdpMulti_weightI( cdp, szFirst );
|
||||
@@ -694,7 +699,7 @@ static int hb_cdpMulti_cmpi( PHB_CODEPAGE cdp,
|
||||
n1 = cdp->sort[ u1 ];
|
||||
|
||||
if( ( cdp->flags[ u2 ] & HB_CDP_MULTI1 ) != 0 &&
|
||||
( ul < nLenSecond - 1 ) &&
|
||||
( nPos < nLenSecond - 1 ) &&
|
||||
( cdp->flags[ ( HB_UCHAR ) szSecond[ 1 ] ] & HB_CDP_MULTI2 ) != 0 )
|
||||
{
|
||||
n = hb_cdpMulti_weightI( cdp, szSecond );
|
||||
@@ -1014,7 +1019,7 @@ int hb_cdpicmp( const char * szFirst, HB_SIZE nLenFirst,
|
||||
}
|
||||
|
||||
/*
|
||||
* UTF8 conversions
|
||||
* UTF-8 conversions
|
||||
*/
|
||||
int hb_cdpUTF8CharSize( HB_WCHAR wc )
|
||||
{
|
||||
@@ -1106,14 +1111,14 @@ HB_BOOL hb_cdpUTF8ToU16NextChar( HB_UCHAR ucChar, int * n, HB_WCHAR * pwc )
|
||||
|
||||
HB_SIZE hb_cdpUTF8StringLength( const char * pSrc, HB_SIZE nLen )
|
||||
{
|
||||
HB_SIZE ul, nDst;
|
||||
HB_SIZE nPos, nDst;
|
||||
HB_WCHAR wc;
|
||||
int n = 0;
|
||||
|
||||
for( ul = nDst = 0; ul < nLen; )
|
||||
for( nPos = nDst = 0; nPos < nLen; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ul ], &n, &wc ) )
|
||||
++ul;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPos ], &n, &wc ) )
|
||||
++nPos;
|
||||
if( n == 0 )
|
||||
++nDst;
|
||||
}
|
||||
@@ -1203,29 +1208,29 @@ HB_WCHAR hb_cdpUTF8StringPeek( const char * pSrc, HB_SIZE nLen, HB_SIZE nPos )
|
||||
{
|
||||
if( nLen )
|
||||
{
|
||||
HB_SIZE ul;
|
||||
HB_SIZE nPos2;
|
||||
HB_WCHAR wc = 0;
|
||||
int n = 0;
|
||||
|
||||
for( ul = 0; ul < nLen && nPos; )
|
||||
for( nPos2 = 0; nPos2 < nLen && nPos; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ul ], &n, &wc ) )
|
||||
++ul;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPos2 ], &n, &wc ) )
|
||||
++nPos2;
|
||||
if( n == 0 )
|
||||
--nPos;
|
||||
}
|
||||
|
||||
if( ul < nLen )
|
||||
if( nPos2 < nLen )
|
||||
{
|
||||
n = 0;
|
||||
do
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ul ], &n, &wc ) )
|
||||
++ul;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPos2 ], &n, &wc ) )
|
||||
++nPos2;
|
||||
if( n == 0 )
|
||||
return wc;
|
||||
}
|
||||
while( ul < nLen );
|
||||
while( nPos2 < nLen );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,37 +1241,39 @@ HB_WCHAR hb_cdpUTF8StringPeek( const char * pSrc, HB_SIZE nLen, HB_SIZE nPos )
|
||||
char * hb_cdpUTF8StringSubstr( const char * pSrc, HB_SIZE nLen,
|
||||
HB_SIZE nFrom, HB_SIZE nCount, HB_SIZE * pulDest )
|
||||
{
|
||||
HB_SIZE ul, nCnt, nDst = 0;
|
||||
HB_SIZE nDst = 0;
|
||||
HB_WCHAR wc;
|
||||
int n;
|
||||
char * pDst = NULL;
|
||||
|
||||
if( nCount && nLen )
|
||||
{
|
||||
HB_SIZE nPos;
|
||||
n = 0;
|
||||
for( ul = 0; ul < nLen && nFrom; )
|
||||
for( nPos = 0; nPos < nLen && nFrom; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( pSrc[ ul ], &n, &wc ) )
|
||||
++ul;
|
||||
if( hb_cdpUTF8ToU16NextChar( pSrc[ nPos ], &n, &wc ) )
|
||||
++nPos;
|
||||
if( n == 0 )
|
||||
--nFrom;
|
||||
}
|
||||
|
||||
if( ul < nLen )
|
||||
if( nPos < nLen )
|
||||
{
|
||||
nFrom = ul;
|
||||
HB_SIZE nCnt;
|
||||
nFrom = nPos;
|
||||
nCnt = nCount;
|
||||
n = 0;
|
||||
do
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( pSrc[ ul ], &n, &wc ) )
|
||||
++ul;
|
||||
if( hb_cdpUTF8ToU16NextChar( pSrc[ nPos ], &n, &wc ) )
|
||||
++nPos;
|
||||
if( n == 0 )
|
||||
--nCnt;
|
||||
}
|
||||
while( ul < nLen && nCnt );
|
||||
while( nPos < nLen && nCnt );
|
||||
|
||||
nDst = ul - nFrom;
|
||||
nDst = nPos - nFrom;
|
||||
pDst = ( char * ) hb_xgrab( nDst + 1 );
|
||||
memcpy( pDst, &pSrc[ nFrom ], nDst );
|
||||
pDst[ nDst ] = '\0';
|
||||
@@ -1290,10 +1297,10 @@ HB_BOOL hb_cdpGetFromUTF8( PHB_CODEPAGE cdp, HB_UCHAR ch,
|
||||
{
|
||||
if( HB_CDPCHAR_LEN( cdp, *pwc ) == 1 )
|
||||
{
|
||||
HB_SIZE nS = 0;
|
||||
HB_SIZE nSize = 0;
|
||||
char c;
|
||||
|
||||
if( HB_CDPCHAR_PUT( cdp, &c, 1, &nS, *pwc ) )
|
||||
if( HB_CDPCHAR_PUT( cdp, &c, 1, &nSize, *pwc ) )
|
||||
*pwc = ( HB_UCHAR ) c;
|
||||
}
|
||||
}
|
||||
@@ -1319,7 +1326,7 @@ HB_SIZE hb_cdpStrAsUTF8Len( PHB_CODEPAGE cdp,
|
||||
const char * pSrc, HB_SIZE nSrc,
|
||||
HB_SIZE nMax )
|
||||
{
|
||||
HB_SIZE ulS, ulD;
|
||||
HB_SIZE nPosS, nPosD;
|
||||
int i, n;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
@@ -1327,40 +1334,40 @@ HB_SIZE hb_cdpStrAsUTF8Len( PHB_CODEPAGE cdp,
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
HB_WCHAR wc;
|
||||
ulS = ulD = 0;
|
||||
while( HB_CDPCHAR_GET( cdp, pSrc, nSrc, &ulS, &wc ) )
|
||||
nPosS = nPosD = 0;
|
||||
while( HB_CDPCHAR_GET( cdp, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
i = hb_cdpUTF8CharSize( wc );
|
||||
if( nMax && ulD + i > nMax )
|
||||
if( nMax && nPosD + i > nMax )
|
||||
break;
|
||||
ulD += i;
|
||||
nPosD += i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const HB_WCHAR * uniCodes = cdp->uniTable->uniCodes;
|
||||
for( ulS = ulD = 0; ulS < nSrc; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; ++nPosS )
|
||||
{
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ ulS ];
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ nPosS ];
|
||||
HB_WCHAR wc = uniCodes[ uc ];
|
||||
|
||||
if( wc == 0 )
|
||||
wc = uc;
|
||||
n = hb_cdpUTF8CharSize( wc );
|
||||
if( nMax && ulD + n > nMax )
|
||||
if( nMax && nPosD + n > nMax )
|
||||
break;
|
||||
ulD += n;
|
||||
nPosD += n;
|
||||
}
|
||||
}
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpStrToUTF8( PHB_CODEPAGE cdp,
|
||||
const char * pSrc, HB_SIZE nSrc,
|
||||
char * pDst, HB_SIZE nDst )
|
||||
{
|
||||
HB_SIZE ulS, ulD, u;
|
||||
HB_SIZE nPosS, nPosD, u;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
{
|
||||
@@ -1374,14 +1381,14 @@ HB_SIZE hb_cdpStrToUTF8( PHB_CODEPAGE cdp,
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
HB_WCHAR wc;
|
||||
ulS = ulD = 0;
|
||||
while( ulD < nDst && HB_CDPCHAR_GET( cdp, pSrc, nSrc, &ulS, &wc ) )
|
||||
nPosS = nPosD = 0;
|
||||
while( nPosD < nDst && HB_CDPCHAR_GET( cdp, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
u = hb_cdpUTF8CharSize( wc );
|
||||
if( ulD + u <= nDst )
|
||||
if( nPosD + u <= nDst )
|
||||
{
|
||||
hb_cdpU16CharToUTF8( &pDst[ ulD ], wc );
|
||||
ulD += u;
|
||||
hb_cdpU16CharToUTF8( &pDst[ nPosD ], wc );
|
||||
nPosD += u;
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -1390,35 +1397,35 @@ HB_SIZE hb_cdpStrToUTF8( PHB_CODEPAGE cdp,
|
||||
else
|
||||
{
|
||||
const HB_WCHAR * uniCodes = cdp->uniTable->uniCodes;
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; ++nPosS )
|
||||
{
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ ulS ];
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ nPosS ];
|
||||
HB_WCHAR wc = uniCodes[ uc ];
|
||||
|
||||
if( wc == 0 )
|
||||
wc = uc;
|
||||
u = hb_cdpUTF8CharSize( wc );
|
||||
if( ulD + u <= nDst )
|
||||
if( nPosD + u <= nDst )
|
||||
{
|
||||
hb_cdpU16CharToUTF8( &pDst[ ulD ], wc );
|
||||
ulD += u;
|
||||
hb_cdpU16CharToUTF8( &pDst[ nPosD ], wc );
|
||||
nPosD += u;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( ulD < nDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
if( nPosD < nDst )
|
||||
pDst[ nPosD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpStrToUTF8Disp( PHB_CODEPAGE cdp,
|
||||
const char * pSrc, HB_SIZE nSrc,
|
||||
char * pDst, HB_SIZE nDst )
|
||||
{
|
||||
HB_SIZE ulS, ulD, u;
|
||||
HB_SIZE nPosS, nPosD, u;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
{
|
||||
@@ -1432,16 +1439,16 @@ HB_SIZE hb_cdpStrToUTF8Disp( PHB_CODEPAGE cdp,
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
HB_WCHAR wc;
|
||||
ulS = ulD = 0;
|
||||
while( ulD < nDst && HB_CDPCHAR_GET( cdp, pSrc, nSrc, &ulS, &wc ) )
|
||||
nPosS = nPosD = 0;
|
||||
while( nPosD < nDst && HB_CDPCHAR_GET( cdp, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
if( wc < 32 )
|
||||
wc = s_uniCtrls[ wc ];
|
||||
u = hb_cdpUTF8CharSize( wc );
|
||||
if( ulD + u <= nDst )
|
||||
if( nPosD + u <= nDst )
|
||||
{
|
||||
hb_cdpU16CharToUTF8( &pDst[ ulD ], wc );
|
||||
ulD += u;
|
||||
hb_cdpU16CharToUTF8( &pDst[ nPosD ], wc );
|
||||
nPosD += u;
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -1450,73 +1457,73 @@ HB_SIZE hb_cdpStrToUTF8Disp( PHB_CODEPAGE cdp,
|
||||
else
|
||||
{
|
||||
const HB_WCHAR * uniCodes = cdp->uniTable->uniCodes;
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; ++nPosS )
|
||||
{
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ ulS ];
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ nPosS ];
|
||||
HB_WCHAR wc = uniCodes[ uc ];
|
||||
|
||||
if( wc == 0 )
|
||||
wc = uc < 32 ? s_uniCtrls[ uc ] : s_uniCodes[ uc ];
|
||||
|
||||
u = hb_cdpUTF8CharSize( wc );
|
||||
if( ulD + u <= nDst )
|
||||
if( nPosD + u <= nDst )
|
||||
{
|
||||
hb_cdpU16CharToUTF8( &pDst[ ulD ], wc );
|
||||
ulD += u;
|
||||
hb_cdpU16CharToUTF8( &pDst[ nPosD ], wc );
|
||||
nPosD += u;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( ulD < nDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
if( nPosD < nDst )
|
||||
pDst[ nPosD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpUTF8AsStrLen( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc,
|
||||
HB_SIZE nMax )
|
||||
{
|
||||
HB_WCHAR wc = 0;
|
||||
HB_SIZE ulS, ulD;
|
||||
HB_SIZE nPosS, nPosD;
|
||||
int n = 0, i;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
return ( nMax && nSrc > nMax ) ? nMax : nSrc;
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc; )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ulS ], &n, &wc ) )
|
||||
++ulS;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPosS ], &n, &wc ) )
|
||||
++nPosS;
|
||||
|
||||
if( n == 0 )
|
||||
{
|
||||
i = HB_CDPCHAR_LEN( cdp, wc );
|
||||
if( nMax && ulD + i > nMax )
|
||||
if( nMax && nPosD + i > nMax )
|
||||
break;
|
||||
ulD += i;
|
||||
nPosD += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc; )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ulS ], &n, &wc ) )
|
||||
++ulS;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPosS ], &n, &wc ) )
|
||||
++nPosS;
|
||||
|
||||
if( n == 0 )
|
||||
{
|
||||
++ulD;
|
||||
if( nMax && ulD >= nMax )
|
||||
++nPosD;
|
||||
if( nMax && nPosD >= nMax )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpUTF8ToStr( PHB_CODEPAGE cdp,
|
||||
@@ -1525,7 +1532,7 @@ HB_SIZE hb_cdpUTF8ToStr( PHB_CODEPAGE cdp,
|
||||
{
|
||||
HB_UCHAR * uniTrans;
|
||||
HB_WCHAR wcMax, wc = 0;
|
||||
HB_SIZE ulS, ulD;
|
||||
HB_SIZE nPosS, nPosD;
|
||||
int n = 0;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
@@ -1539,14 +1546,14 @@ HB_SIZE hb_cdpUTF8ToStr( PHB_CODEPAGE cdp,
|
||||
}
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ulS ], &n, &wc ) )
|
||||
++ulS;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPosS ], &n, &wc ) )
|
||||
++nPosS;
|
||||
|
||||
if( n == 0 )
|
||||
{
|
||||
if( ! HB_CDPCHAR_PUT( cdp, pDst, nDst, &ulD, wc ) )
|
||||
if( ! HB_CDPCHAR_PUT( cdp, pDst, nDst, &nPosD, wc ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1558,25 +1565,25 @@ HB_SIZE hb_cdpUTF8ToStr( PHB_CODEPAGE cdp,
|
||||
uniTrans = cdp->uniTable->uniTrans;
|
||||
wcMax = cdp->uniTable->wcMax;
|
||||
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ulS ], &n, &wc ) )
|
||||
++ulS;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPosS ], &n, &wc ) )
|
||||
++nPosS;
|
||||
|
||||
if( n == 0 )
|
||||
{
|
||||
if( wc <= wcMax && uniTrans[ wc ] )
|
||||
pDst[ ulD++ ] = uniTrans[ wc ];
|
||||
pDst[ nPosD++ ] = uniTrans[ wc ];
|
||||
else
|
||||
pDst[ ulD++ ] = wc >= 0x100 ? '?' : ( HB_UCHAR ) wc;
|
||||
pDst[ nPosD++ ] = wc >= 0x100 ? '?' : ( HB_UCHAR ) wc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ulD < nDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
if( nPosD < nDst )
|
||||
pDst[ nPosD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1724,8 +1731,6 @@ HB_SIZE hb_cdpStrAsU16Len( PHB_CODEPAGE cdp,
|
||||
const char * pSrc, HB_SIZE nSrc,
|
||||
HB_SIZE nMax )
|
||||
{
|
||||
HB_SIZE ulS, ulD;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
{
|
||||
nSrc = hb_cdpUTF8StringLength( pSrc, nSrc );
|
||||
@@ -1733,14 +1738,15 @@ HB_SIZE hb_cdpStrAsU16Len( PHB_CODEPAGE cdp,
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
HB_WCHAR wc;
|
||||
ulS = ulD = 0;
|
||||
while( HB_CDPCHAR_GET( cdp, pSrc, nSrc, &ulS, &wc ) )
|
||||
HB_SIZE nPosS, nPosD;
|
||||
nPosS = nPosD = 0;
|
||||
while( HB_CDPCHAR_GET( cdp, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
++ulD;
|
||||
if( nMax && ulD >= nMax )
|
||||
++nPosD;
|
||||
if( nMax && nPosD >= nMax )
|
||||
break;
|
||||
}
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
return ( nMax && nSrc > nMax ) ? nMax : nSrc;
|
||||
@@ -1758,32 +1764,32 @@ HB_SIZE hb_cdpStrToU16( PHB_CODEPAGE cdp, int iEndian,
|
||||
HB_WCHAR * pDst, HB_SIZE nDst )
|
||||
{
|
||||
const HB_WCHAR * uniCodes;
|
||||
HB_SIZE ulS, ulD;
|
||||
HB_SIZE nPosS, nPosD;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
{
|
||||
HB_WCHAR wc = 0;
|
||||
int n = 0;
|
||||
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; )
|
||||
{
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ ulS ], &n, &wc ) )
|
||||
++ulS;
|
||||
if( hb_cdpUTF8ToU16NextChar( ( HB_UCHAR ) pSrc[ nPosS ], &n, &wc ) )
|
||||
++nPosS;
|
||||
|
||||
if( n == 0 )
|
||||
{
|
||||
#if defined( HB_CDP_ENDIAN_SWAP )
|
||||
if( iEndian == HB_CDP_ENDIAN_SWAP )
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
pDst[ ulD++ ] = wc;
|
||||
pDst[ nPosD++ ] = wc;
|
||||
#else
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
HB_PUT_LE_UINT16( &pDst[ ulD ], wc );
|
||||
HB_PUT_LE_UINT16( &pDst[ nPosD ], wc );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
HB_PUT_BE_UINT16( &pDst[ ulD ], wc );
|
||||
HB_PUT_BE_UINT16( &pDst[ nPosD ], wc );
|
||||
else
|
||||
pDst[ ulD ] = wc;
|
||||
++ulD;
|
||||
pDst[ nPosD ] = wc;
|
||||
++nPosD;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1791,30 +1797,30 @@ HB_SIZE hb_cdpStrToU16( PHB_CODEPAGE cdp, int iEndian,
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
HB_WCHAR wc;
|
||||
ulS = ulD = 0;
|
||||
while( ulD < nDst && HB_CDPCHAR_GET( cdp, pSrc, nSrc, &ulS, &wc ) )
|
||||
nPosS = nPosD = 0;
|
||||
while( nPosD < nDst && HB_CDPCHAR_GET( cdp, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
#if defined( HB_CDP_ENDIAN_SWAP )
|
||||
if( iEndian == HB_CDP_ENDIAN_SWAP )
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
pDst[ ulD++ ] = wc;
|
||||
pDst[ nPosD++ ] = wc;
|
||||
#else
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
HB_PUT_LE_UINT16( &pDst[ ulD ], wc );
|
||||
HB_PUT_LE_UINT16( &pDst[ nPosD ], wc );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
HB_PUT_BE_UINT16( &pDst[ ulD ], wc );
|
||||
HB_PUT_BE_UINT16( &pDst[ nPosD ], wc );
|
||||
else
|
||||
pDst[ ulD ] = wc;
|
||||
++ulD;
|
||||
pDst[ nPosD ] = wc;
|
||||
++nPosD;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uniCodes = cdp->uniTable->uniCodes;
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; ++nPosS )
|
||||
{
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ ulS ];
|
||||
HB_UCHAR uc = ( HB_UCHAR ) pSrc[ nPosS ];
|
||||
HB_WCHAR wc = uniCodes[ uc ];
|
||||
|
||||
if( wc == 0 )
|
||||
@@ -1822,23 +1828,23 @@ HB_SIZE hb_cdpStrToU16( PHB_CODEPAGE cdp, int iEndian,
|
||||
#if defined( HB_CDP_ENDIAN_SWAP )
|
||||
if( iEndian == HB_CDP_ENDIAN_SWAP )
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
pDst[ ulD++ ] = wc;
|
||||
pDst[ nPosD++ ] = wc;
|
||||
#else
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
HB_PUT_LE_UINT16( &pDst[ ulD ], wc );
|
||||
HB_PUT_LE_UINT16( &pDst[ nPosD ], wc );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
HB_PUT_BE_UINT16( &pDst[ ulD ], wc );
|
||||
HB_PUT_BE_UINT16( &pDst[ nPosD ], wc );
|
||||
else
|
||||
pDst[ ulD ] = wc;
|
||||
++ulD;
|
||||
pDst[ nPosD ] = wc;
|
||||
++nPosD;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if( ulD < nDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
if( nPosD < nDst )
|
||||
pDst[ nPosD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
HB_WCHAR * hb_cdpnStrDupU16( PHB_CODEPAGE cdp, int iEndian,
|
||||
@@ -1868,33 +1874,33 @@ HB_SIZE hb_cdpU16AsStrLen( PHB_CODEPAGE cdp,
|
||||
const HB_WCHAR * pSrc, HB_SIZE nSrc,
|
||||
HB_SIZE nMax )
|
||||
{
|
||||
HB_SIZE ulS, ulD;
|
||||
HB_SIZE nPosS, nPosD;
|
||||
int i;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; ++nPosS )
|
||||
{
|
||||
i = hb_cdpUTF8CharSize( pSrc[ ulS ] );
|
||||
if( nMax && ulD + i > nMax )
|
||||
i = hb_cdpUTF8CharSize( pSrc[ nPosS ] );
|
||||
if( nMax && nPosD + i > nMax )
|
||||
break;
|
||||
ulD += i;
|
||||
nPosD += i;
|
||||
}
|
||||
}
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; ++nPosS )
|
||||
{
|
||||
i = HB_CDPCHAR_LEN( cdp, pSrc[ ulS ] );
|
||||
if( nMax && ulD + i > nMax )
|
||||
i = HB_CDPCHAR_LEN( cdp, pSrc[ nPosS ] );
|
||||
if( nMax && nPosD + i > nMax )
|
||||
break;
|
||||
ulD += i;
|
||||
nPosD += i;
|
||||
}
|
||||
}
|
||||
else
|
||||
ulD = ( nMax && nSrc > nMax ) ? nMax : nSrc;
|
||||
nPosD = ( nMax && nSrc > nMax ) ? nMax : nSrc;
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian,
|
||||
@@ -1903,30 +1909,30 @@ HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian,
|
||||
{
|
||||
HB_UCHAR * uniTrans;
|
||||
HB_WCHAR wcMax, wc;
|
||||
HB_SIZE ulS, ulD;
|
||||
int i;
|
||||
HB_SIZE nPosS, nPosD;
|
||||
|
||||
if( HB_CDP_ISUTF8( cdp ) )
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; ++nPosS )
|
||||
{
|
||||
int i;
|
||||
#if defined( HB_CDP_ENDIAN_SWAP )
|
||||
wc = pSrc[ ulS ];
|
||||
wc = pSrc[ nPosS ];
|
||||
if( iEndian == HB_CDP_ENDIAN_SWAP )
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
#else
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ ulS ] );
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ nPosS ] );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ ulS ] );
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ nPosS ] );
|
||||
else
|
||||
wc = pSrc[ ulS ];
|
||||
wc = pSrc[ nPosS ];
|
||||
#endif
|
||||
i = hb_cdpUTF8CharSize( wc );
|
||||
if( ulD + i <= nDst )
|
||||
if( nPosD + i <= nDst )
|
||||
{
|
||||
hb_cdpU16CharToUTF8( &pDst[ ulD ], wc );
|
||||
ulD += i;
|
||||
hb_cdpU16CharToUTF8( &pDst[ nPosD ], wc );
|
||||
nPosD += i;
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -1934,21 +1940,21 @@ HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian,
|
||||
}
|
||||
else if( HB_CDP_ISCUSTOM( cdp ) )
|
||||
{
|
||||
for( ulS = ulD = 0; ulS < nSrc; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc; ++nPosS )
|
||||
{
|
||||
#if defined( HB_CDP_ENDIAN_SWAP )
|
||||
wc = pSrc[ ulS ];
|
||||
wc = pSrc[ nPosS ];
|
||||
if( iEndian == HB_CDP_ENDIAN_SWAP )
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
#else
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ ulS ] );
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ nPosS ] );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ ulS ] );
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ nPosS ] );
|
||||
else
|
||||
wc = pSrc[ ulS ];
|
||||
wc = pSrc[ nPosS ];
|
||||
#endif
|
||||
if( ! HB_CDPCHAR_PUT( cdp, pDst, nDst, &ulD, wc ) )
|
||||
if( ! HB_CDPCHAR_PUT( cdp, pDst, nDst, &nPosD, wc ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1959,31 +1965,31 @@ HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian,
|
||||
uniTrans = cdp->uniTable->uniTrans;
|
||||
wcMax = cdp->uniTable->wcMax;
|
||||
|
||||
for( ulS = ulD = 0; ulS < nSrc && ulD < nDst; ++ulS )
|
||||
for( nPosS = nPosD = 0; nPosS < nSrc && nPosD < nDst; ++nPosS )
|
||||
{
|
||||
#if defined( HB_CDP_ENDIAN_SWAP )
|
||||
wc = pSrc[ ulS ];
|
||||
wc = pSrc[ nPosS ];
|
||||
if( iEndian == HB_CDP_ENDIAN_SWAP )
|
||||
wc = HB_SWAP_UINT16( wc );
|
||||
#else
|
||||
if( iEndian == HB_CDP_ENDIAN_LITTLE )
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ ulS ] );
|
||||
wc = HB_GET_LE_UINT16( &pSrc[ nPosS ] );
|
||||
else if( iEndian == HB_CDP_ENDIAN_BIG )
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ ulS ] );
|
||||
wc = HB_GET_BE_UINT16( &pSrc[ nPosS ] );
|
||||
else
|
||||
wc = pSrc[ ulS ];
|
||||
wc = pSrc[ nPosS ];
|
||||
#endif
|
||||
if( wc <= wcMax && uniTrans[ wc ] )
|
||||
pDst[ ulD++ ] = uniTrans[ wc ];
|
||||
pDst[ nPosD++ ] = uniTrans[ wc ];
|
||||
else
|
||||
pDst[ ulD++ ] = wc >= 0x100 ? '?' : ( HB_UCHAR ) wc;
|
||||
pDst[ nPosD++ ] = wc >= 0x100 ? '?' : ( HB_UCHAR ) wc;
|
||||
}
|
||||
}
|
||||
|
||||
if( ulD < nDst )
|
||||
pDst[ ulD ] = '\0';
|
||||
if( nPosD < nDst )
|
||||
pDst[ nPosD ] = '\0';
|
||||
|
||||
return ulD;
|
||||
return nPosD;
|
||||
}
|
||||
|
||||
|
||||
@@ -2005,11 +2011,11 @@ HB_SIZE hb_cdpTransLen( const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax,
|
||||
return hb_cdpStrAsUTF8Len( cdpIn, pSrc, nSrc, nMax );
|
||||
else if( HB_CDP_ISCUSTOM( cdpIn ) || HB_CDP_ISCUSTOM( cdpOut ) )
|
||||
{
|
||||
HB_SIZE ulS;
|
||||
HB_SIZE nPosS;
|
||||
HB_WCHAR wc;
|
||||
|
||||
ulS = nSize = 0;
|
||||
while( HB_CDPCHAR_GET( cdpIn, pSrc, nSrc, &ulS, &wc ) )
|
||||
nPosS = nSize = 0;
|
||||
while( HB_CDPCHAR_GET( cdpIn, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
int i = HB_CDPCHAR_LEN( cdpOut, wc );
|
||||
if( nMax && nSize + i > nMax )
|
||||
@@ -2042,11 +2048,11 @@ HB_SIZE hb_cdpTransTo( const char * pSrc, HB_SIZE nSrc,
|
||||
return hb_cdpStrToUTF8( cdpIn, pSrc, nSrc, pDst, nDst );
|
||||
else if( HB_CDP_ISCUSTOM( cdpIn ) || HB_CDP_ISCUSTOM( cdpOut ) )
|
||||
{
|
||||
HB_SIZE ulS;
|
||||
HB_SIZE nPosS;
|
||||
HB_WCHAR wc;
|
||||
|
||||
ulS = nSize = 0;
|
||||
while( nSize < nDst && HB_CDPCHAR_GET( cdpIn, pSrc, nSrc, &ulS, &wc ) )
|
||||
nPosS = nSize = 0;
|
||||
while( nSize < nDst && HB_CDPCHAR_GET( cdpIn, pSrc, nSrc, &nPosS, &wc ) )
|
||||
{
|
||||
if( ! HB_CDPCHAR_PUT( cdpOut, pDst, nDst, &nSize, wc ) )
|
||||
break;
|
||||
@@ -3142,7 +3148,7 @@ HB_BOOL hb_cdpRegisterRaw( PHB_CODEPAGE cdp )
|
||||
{
|
||||
PHB_CODEPAGE * cdp_ptr;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_cdpRegisterRaw(%p)", cdp ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_cdpRegisterRaw(%p)", ( void * ) cdp ) );
|
||||
|
||||
cdp_ptr = hb_cdpFindPos( cdp->id );
|
||||
if( *cdp_ptr == NULL )
|
||||
@@ -3238,7 +3244,7 @@ PHB_CODEPAGE hb_cdpFindExt( const char * id )
|
||||
|
||||
HB_BOOL hb_cdpIsUTF8( PHB_CODEPAGE cdp )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_cdpIsUTF8(%p)", cdp ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_cdpIsUTF8(%p)", ( void * ) cdp ) );
|
||||
|
||||
if( cdp == NULL )
|
||||
cdp = hb_vmCDP();
|
||||
@@ -3250,7 +3256,7 @@ PHB_CODEPAGE hb_cdpSelect( PHB_CODEPAGE cdp )
|
||||
{
|
||||
PHB_CODEPAGE cdpOld;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_cdpSelect(%p)", cdp ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_cdpSelect(%p)", ( void * ) cdp ) );
|
||||
|
||||
cdpOld = hb_vmCDP();
|
||||
if( cdp )
|
||||
|
||||
@@ -2456,35 +2456,35 @@ static const char * hb_gt_crs_Version( PHB_GT pGT, int iType )
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_crs_OutStd( PHB_GT pGT, const char * szStr, HB_SIZE ulLen )
|
||||
static void hb_gt_crs_OutStd( PHB_GT pGT, const char * szStr, HB_SIZE nLen )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_OutStd(%p,%s,%lu)", pGT, szStr, ulLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_OutStd(%p,%s,%lu)", ( void * ) pGT, szStr, nLen ) );
|
||||
|
||||
if( s_ioBase )
|
||||
{
|
||||
if( s_ioBase->stdoutfd == -1 )
|
||||
HB_GTSELF_WRITECON( pGT, szStr, ulLen );
|
||||
HB_GTSELF_WRITECON( pGT, szStr, nLen );
|
||||
else
|
||||
gt_outstd( s_ioBase, szStr, ulLen );
|
||||
gt_outstd( s_ioBase, szStr, nLen );
|
||||
}
|
||||
else
|
||||
HB_GTSUPER_OUTSTD( pGT, szStr, ulLen );
|
||||
HB_GTSUPER_OUTSTD( pGT, szStr, nLen );
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_crs_OutErr( PHB_GT pGT, const char * szStr, HB_SIZE ulLen )
|
||||
static void hb_gt_crs_OutErr( PHB_GT pGT, const char * szStr, HB_SIZE nLen )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_OutErr(%p,%s,%lu)", pGT, szStr, ulLen ) );
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_OutErr(%p,%s,%lu)", ( void * ) pGT, szStr, nLen ) );
|
||||
if( s_ioBase )
|
||||
{
|
||||
if( s_ioBase->stderrfd == -1 )
|
||||
HB_GTSELF_WRITECON( pGT, szStr, ulLen );
|
||||
HB_GTSELF_WRITECON( pGT, szStr, nLen );
|
||||
else
|
||||
gt_outerr( s_ioBase, szStr, ulLen );
|
||||
gt_outerr( s_ioBase, szStr, nLen );
|
||||
}
|
||||
else
|
||||
HB_GTSUPER_OUTERR( pGT, szStr, ulLen );
|
||||
HB_GTSUPER_OUTERR( pGT, szStr, nLen );
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
@@ -309,7 +309,7 @@ typedef struct
|
||||
static void hb_gt_xwc_ProcessMessages( PXWND_DEF wnd, HB_BOOL fSync );
|
||||
static void hb_gt_xwc_InvalidatePts( PXWND_DEF wnd, int left, int top, int right, int bottom );
|
||||
static void hb_gt_xwc_InvalidateChar( PXWND_DEF wnd, int left, int top, int right, int bottom );
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE ulSize, HB_BOOL fCopy );
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE nSize, HB_BOOL fCopy );
|
||||
|
||||
/************************ globals ********************************/
|
||||
|
||||
@@ -3379,14 +3379,14 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent * evt )
|
||||
|
||||
if( cdpin && cdpin != wnd->utf8CDP )
|
||||
{
|
||||
HB_SIZE ulLen = wnd->ClipboardSize;
|
||||
HB_SIZE nLen = wnd->ClipboardSize;
|
||||
unsigned char * pBuffer = ( unsigned char * )
|
||||
hb_cdpnDup( ( const char * ) wnd->ClipboardData, &ulLen,
|
||||
hb_cdpnDup( ( const char * ) wnd->ClipboardData, &nLen,
|
||||
wnd->utf8CDP, cdpin );
|
||||
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomString, 8, PropModeReplace,
|
||||
pBuffer, ulLen );
|
||||
pBuffer, nLen );
|
||||
hb_xfree( pBuffer );
|
||||
}
|
||||
else
|
||||
@@ -4384,11 +4384,11 @@ static void hb_gt_xwc_ClearSelection( PXWND_DEF wnd )
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE ulSize, HB_BOOL fCopy )
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE nSize, HB_BOOL fCopy )
|
||||
{
|
||||
HB_XWC_XLIB_LOCK( wnd->dpy );
|
||||
|
||||
if( ulSize == 0 )
|
||||
if( nSize == 0 )
|
||||
hb_gt_xwc_ClearSelection( wnd );
|
||||
|
||||
if( wnd->ClipboardData != NULL )
|
||||
@@ -4397,17 +4397,17 @@ static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, const char * szData, HB_SIZE
|
||||
wnd->ClipboardData = NULL;
|
||||
}
|
||||
|
||||
wnd->ClipboardSize = ulSize;
|
||||
wnd->ClipboardSize = nSize;
|
||||
wnd->ClipboardTime = wnd->lastEventTime;
|
||||
wnd->ClipboardOwner = HB_FALSE;
|
||||
|
||||
if( ulSize > 0 )
|
||||
if( nSize > 0 )
|
||||
{
|
||||
if( fCopy )
|
||||
{
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( ulSize + 1 );
|
||||
memcpy( wnd->ClipboardData, szData, ulSize );
|
||||
wnd->ClipboardData[ ulSize ] = '\0';
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( nSize + 1 );
|
||||
memcpy( wnd->ClipboardData, szData, nSize );
|
||||
wnd->ClipboardData[ nSize ] = '\0';
|
||||
}
|
||||
else
|
||||
wnd->ClipboardData = ( unsigned char * ) HB_UNCONST( szData );
|
||||
|
||||
@@ -60,12 +60,12 @@ static HB_SIZE hb_tokenCount( const char * szLine, HB_SIZE nLen,
|
||||
const char * szDelim, HB_SIZE nDelim,
|
||||
int iFlags )
|
||||
{
|
||||
HB_SIZE ul = 0, nTokens = 1;
|
||||
HB_SIZE nPos = 0, nTokens = 1;
|
||||
char cQuote = 0;
|
||||
|
||||
while( ul < nLen )
|
||||
while( nPos < nLen )
|
||||
{
|
||||
char ch = szLine[ ul ];
|
||||
char ch = szLine[ nPos ];
|
||||
|
||||
if( cQuote )
|
||||
{
|
||||
@@ -81,21 +81,21 @@ static HB_SIZE hb_tokenCount( const char * szLine, HB_SIZE nLen,
|
||||
( ch == '\n' || ch == '\r' ) )
|
||||
{
|
||||
++nTokens;
|
||||
if( ul + 1 < nLen && szLine[ ul + 1 ] == ( ch == '\n' ? '\r' : '\n' ) )
|
||||
++ul;
|
||||
if( nPos + 1 < nLen && szLine[ nPos + 1 ] == ( ch == '\n' ? '\r' : '\n' ) )
|
||||
++nPos;
|
||||
}
|
||||
else if( nDelim && ch == szDelim[ 0 ] &&
|
||||
( nDelim == 1 || ! memcmp( szLine + ul, szDelim, nDelim ) ) )
|
||||
( nDelim == 1 || ! memcmp( szLine + nPos, szDelim, nDelim ) ) )
|
||||
{
|
||||
++nTokens;
|
||||
if( ( iFlags & _HB_TOK_ISDELIM ) == 0 )
|
||||
{
|
||||
while( ul + 1 < nLen && szLine[ ul + 1 ] == szDelim[ 0 ] )
|
||||
++ul;
|
||||
while( nPos + 1 < nLen && szLine[ nPos + 1 ] == szDelim[ 0 ] )
|
||||
++nPos;
|
||||
}
|
||||
ul += nDelim - 1;
|
||||
nPos += nDelim - 1;
|
||||
}
|
||||
++ul;
|
||||
++nPos;
|
||||
}
|
||||
|
||||
return nTokens;
|
||||
@@ -105,12 +105,12 @@ static const char * hb_tokenGet( const char * szLine, HB_SIZE nLen,
|
||||
const char * szDelim, HB_SIZE * pnDelim,
|
||||
int iFlags, HB_SIZE nToken, HB_SIZE * pnLen )
|
||||
{
|
||||
HB_SIZE ul, nStart, nDelim = *pnDelim;
|
||||
HB_SIZE nPos, nStart, nDelim = *pnDelim;
|
||||
char cQuote = 0;
|
||||
|
||||
for( ul = nStart = 0; ul < nLen; ++ul )
|
||||
for( nPos = nStart = 0; nPos < nLen; ++nPos )
|
||||
{
|
||||
char ch = szLine[ ul ];
|
||||
char ch = szLine[ nPos ];
|
||||
|
||||
if( cQuote )
|
||||
{
|
||||
@@ -125,37 +125,37 @@ static const char * hb_tokenGet( const char * szLine, HB_SIZE nLen,
|
||||
else if( ( iFlags & _HB_TOK_EOL_DELIM ) != 0 &&
|
||||
( ch == '\n' || ch == '\r' ) )
|
||||
{
|
||||
HB_SIZE nL = ( ul + 1 < nLen &&
|
||||
szLine[ ul + 1 ] == ( ch == '\n' ? '\r' : '\n' ) ) ? 1 : 0;
|
||||
HB_SIZE nL = ( nPos + 1 < nLen &&
|
||||
szLine[ nPos + 1 ] == ( ch == '\n' ? '\r' : '\n' ) ) ? 1 : 0;
|
||||
if( --nToken == 0 )
|
||||
{
|
||||
*pnDelim = nL + 1;
|
||||
*pnLen = ul - nStart;
|
||||
*pnLen = nPos - nStart;
|
||||
return szLine + nStart;
|
||||
}
|
||||
ul += nL;
|
||||
nStart = ul + 1;
|
||||
nPos += nL;
|
||||
nStart = nPos + 1;
|
||||
}
|
||||
else if( nDelim && ch == szDelim[ 0 ] &&
|
||||
( nDelim == 1 || ! memcmp( szLine + ul, szDelim, nDelim ) ) )
|
||||
( nDelim == 1 || ! memcmp( szLine + nPos, szDelim, nDelim ) ) )
|
||||
{
|
||||
if( --nToken == 0 )
|
||||
{
|
||||
*pnLen = ul - nStart;
|
||||
*pnLen = nPos - nStart;
|
||||
return szLine + nStart;
|
||||
}
|
||||
if( ( iFlags & _HB_TOK_ISDELIM ) == 0 )
|
||||
{
|
||||
while( ul + 1 < nLen && szLine[ ul + 1 ] == szDelim[ 0 ] )
|
||||
++ul;
|
||||
while( nPos + 1 < nLen && szLine[ nPos + 1 ] == szDelim[ 0 ] )
|
||||
++nPos;
|
||||
}
|
||||
ul += nDelim - 1;
|
||||
nStart = ul + 1;
|
||||
nPos += nDelim - 1;
|
||||
nStart = nPos + 1;
|
||||
}
|
||||
}
|
||||
if( --nToken == 0 )
|
||||
{
|
||||
*pnLen = ul - nStart;
|
||||
*pnLen = nPos - nStart;
|
||||
return szLine + nStart;
|
||||
}
|
||||
*pnLen = 0;
|
||||
@@ -171,12 +171,12 @@ static PHB_ITEM hb_tokenArray( const char * szLine, HB_SIZE nLen,
|
||||
|
||||
if( nTokens )
|
||||
{
|
||||
HB_SIZE ul, nStart, nToken;
|
||||
HB_SIZE nPos, nStart, nToken;
|
||||
char cQuote = 0;
|
||||
|
||||
for( ul = nStart = nToken = 0; ul < nLen; ++ul )
|
||||
for( nPos = nStart = nToken = 0; nPos < nLen; ++nPos )
|
||||
{
|
||||
char ch = szLine[ ul ];
|
||||
char ch = szLine[ nPos ];
|
||||
|
||||
if( cQuote )
|
||||
{
|
||||
@@ -191,25 +191,25 @@ static PHB_ITEM hb_tokenArray( const char * szLine, HB_SIZE nLen,
|
||||
else if( ( iFlags & _HB_TOK_EOL_DELIM ) != 0 &&
|
||||
( ch == '\n' || ch == '\r' ) )
|
||||
{
|
||||
hb_arraySetCL( pArray, ++nToken, szLine + nStart, ul - nStart );
|
||||
if( ul + 1 < nLen && szLine[ ul + 1 ] == ( ch == '\n' ? '\r' : '\n' ) )
|
||||
++ul;
|
||||
nStart = ul + 1;
|
||||
hb_arraySetCL( pArray, ++nToken, szLine + nStart, nPos - nStart );
|
||||
if( nPos + 1 < nLen && szLine[ nPos + 1 ] == ( ch == '\n' ? '\r' : '\n' ) )
|
||||
++nPos;
|
||||
nStart = nPos + 1;
|
||||
}
|
||||
else if( nDelim && ch == szDelim[ 0 ] &&
|
||||
( nDelim == 1 || ! memcmp( szLine + ul, szDelim, nDelim ) ) )
|
||||
( nDelim == 1 || ! memcmp( szLine + nPos, szDelim, nDelim ) ) )
|
||||
{
|
||||
hb_arraySetCL( pArray, ++nToken, szLine + nStart, ul - nStart );
|
||||
hb_arraySetCL( pArray, ++nToken, szLine + nStart, nPos - nStart );
|
||||
if( ( iFlags & _HB_TOK_ISDELIM ) == 0 )
|
||||
{
|
||||
while( ul + 1 < nLen && szLine[ ul + 1 ] == szDelim[ 0 ] )
|
||||
++ul;
|
||||
while( nPos + 1 < nLen && szLine[ nPos + 1 ] == szDelim[ 0 ] )
|
||||
++nPos;
|
||||
}
|
||||
ul += nDelim - 1;
|
||||
nStart = ul + 1;
|
||||
nPos += nDelim - 1;
|
||||
nStart = nPos + 1;
|
||||
}
|
||||
}
|
||||
hb_arraySetCL( pArray, ++nToken, szLine + nStart, ul - nStart );
|
||||
hb_arraySetCL( pArray, ++nToken, szLine + nStart, nPos - nStart );
|
||||
}
|
||||
|
||||
return pArray;
|
||||
|
||||
@@ -109,11 +109,11 @@ char * hb_netname( void )
|
||||
{
|
||||
#if defined( HB_OS_WIN )
|
||||
|
||||
DWORD ulLen = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
DWORD dwLen = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
TCHAR lpValue[ MAX_COMPUTERNAME_LENGTH + 1 ];
|
||||
|
||||
lpValue[ 0 ] = TEXT( '\0' );
|
||||
GetComputerName( lpValue, &ulLen );
|
||||
GetComputerName( lpValue, &dwLen );
|
||||
lpValue[ MAX_COMPUTERNAME_LENGTH ] = TEXT( '\0' );
|
||||
|
||||
if( lpValue[ 0 ] )
|
||||
|
||||
@@ -92,11 +92,11 @@ char * hb_username( void )
|
||||
{
|
||||
#if defined( HB_OS_WIN )
|
||||
|
||||
DWORD ulLen = 256;
|
||||
DWORD dwLen = 256;
|
||||
TCHAR lpValue[ 256 ];
|
||||
|
||||
lpValue[ 0 ] = TEXT( '\0' );
|
||||
GetUserName( lpValue, &ulLen );
|
||||
GetUserName( lpValue, &dwLen );
|
||||
lpValue[ 255 ] = TEXT( '\0' );
|
||||
|
||||
if( lpValue[ 0 ] )
|
||||
|
||||
Reference in New Issue
Block a user