2012-10-01 23:48 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* harbour/src/pp/ppcore.c
    ! fixed possible GPF when some broken expressions are used as
      part of extended expression match marker

  * harbour/src/rtl/padr.c
  * harbour/src/rtl/padc.c
  * harbour/src/rtl/padl.c
    ! fixed PADR(), PADL() and PADC() to accept pad mulibyte characters
      when CPs with such encoding is used, i.e. CP950 or UTF8EX

  * harbour/contrib/xhb/xhb.hbx
    * updated to follow recent modifications
This commit is contained in:
Przemyslaw Czerpak
2012-10-01 21:48:26 +00:00
parent 450a2e891e
commit e853a90f08
6 changed files with 136 additions and 27 deletions

View File

@@ -16,6 +16,20 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-10-01 23:48 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/src/pp/ppcore.c
! fixed possible GPF when some broken expressions are used as
part of extended expression match marker
* harbour/src/rtl/padr.c
* harbour/src/rtl/padc.c
* harbour/src/rtl/padl.c
! fixed PADR(), PADL() and PADC() to accept pad mulibyte characters
when CPs with such encoding is used, i.e. CP950 or UTF8EX
* harbour/contrib/xhb/xhb.hbx
* updated to follow recent modifications
2012-10-01 22:23 UTC+0200 Viktor Szakats (harbour syenar.net)
* include/box.ch
* include/button.ch

View File

@@ -112,7 +112,7 @@ DYNAMIC HB_BACKGROUNDRESET
DYNAMIC HB_BACKGROUNDRUN
DYNAMIC HB_BACKGROUNDRUNFORCED
DYNAMIC HB_BACKGROUNDTIME
DYNAMIC HB_BITTEST
DYNAMIC HB_BITISSET
DYNAMIC HB_BLDLOGMSG
DYNAMIC HB_BUILDINFO
DYNAMIC HB_CHECKSUM

View File

@@ -3664,8 +3664,8 @@ static HB_BOOL hb_pp_tokenSkipExp( PHB_PP_TOKEN * pTokenPtr, PHB_PP_TOKEN pStop,
pToken = pPrev;
}
if( HB_PP_TOKEN_ISEOC( pToken ) &&
( mode != HB_PP_CMP_ADDR || pToken == pStop ) )
if( mode == HB_PP_CMP_ADDR ? pToken == pStop :
HB_PP_TOKEN_ISEOC( pToken ) )
{
if( pfStop )
* pfStop = HB_TRUE;
@@ -3679,12 +3679,6 @@ static HB_BOOL hb_pp_tokenSkipExp( PHB_PP_TOKEN * pTokenPtr, PHB_PP_TOKEN pStop,
else if( curtype == rbrtype )
--iBraces;
}
else if( mode == HB_PP_CMP_ADDR && pToken == pStop )
{
if( pfStop )
* pfStop = HB_TRUE;
break;
}
else if( curtype == HB_PP_TOKEN_COMMA )
{
if( pfStop )

View File

@@ -63,6 +63,22 @@ static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem )
hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen;
}
static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad )
{
const char * szPad = hb_parc( 3 );
*pnPad = 1;
if( szPad == NULL )
szPad = " ";
else if( HB_CDP_ISCHARIDX( cdp ) )
{
*pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 );
if( *pnPad == 0 )
szPad = "";
}
return szPad;
}
/* centre-pads a date, number, or string with spaces or supplied character */
HB_FUNC( PADC )
{
@@ -95,15 +111,37 @@ HB_FUNC( PADC )
if( ( HB_SIZE ) nLen > nSize )
{
char * szResult = ( char * ) hb_xgrab( nLen + 1 );
char cPad;
HB_ISIZ nPad = ( ( HB_SIZE ) nLen - nSize ) >> 1;
HB_SIZE nPad = 0;
const char * szPad = s_hb_padGet( cdp, &nPad );
char * szResult;
cPad = ( HB_ISCHAR( 3 ) ? *( hb_parc( 3 ) ) : ' ' );
hb_xmemset( szResult, cPad, nPad );
hb_xmemcpy( szResult + nPad, szText, nSize );
hb_xmemset( szResult + nPad + nSize, cPad,
( HB_SIZE ) nLen - nSize - nPad );
if( nPad > 1 )
{
HB_SIZE nRep = ( ( HB_SIZE ) nLen - nSize ) >> 1, nPos = 0;
nLen += ( nLen - nSize ) * ( nPad - 1 );
szResult = ( char * ) hb_xgrab( nLen + 1 );
while( nRep-- )
{
hb_xmemcpy( szResult + nPos, szPad, nPad );
nPos += nPad;
}
hb_xmemcpy( szResult + nPos, szText, nSize );
nSize += nPos;
while( nSize < ( HB_SIZE ) nLen )
{
hb_xmemcpy( szResult + nSize, szPad, nPad );
nSize += nPad;
}
}
else
{
szResult = ( char * ) hb_xgrab( nLen + 1 );
nPad = ( ( HB_SIZE ) nLen - nSize ) >> 1;
hb_xmemset( szResult, szPad[ 0 ], nPad );
hb_xmemcpy( szResult + nPad, szText, nSize );
hb_xmemset( szResult + nPad + nSize, szPad[ 0 ],
( HB_SIZE ) nLen - nSize - nPad );
}
hb_retclen_buffer( szResult, ( HB_SIZE ) nLen );
if( bFreeReq )

View File

@@ -63,6 +63,22 @@ static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem )
hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen;
}
static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad )
{
const char * szPad = hb_parc( 3 );
*pnPad = 1;
if( szPad == NULL )
szPad = " ";
else if( HB_CDP_ISCHARIDX( cdp ) )
{
*pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 );
if( *pnPad == 0 )
szPad = "";
}
return szPad;
}
/* left-pads a date, number, or string with spaces or supplied character */
HB_FUNC( PADL )
{
@@ -95,12 +111,28 @@ HB_FUNC( PADL )
if( ( HB_SIZE ) nLen > nSize )
{
char * szResult = ( char * ) hb_xgrab( nLen + 1 );
char cPad;
HB_SIZE nPad = 0;
const char * szPad = s_hb_padGet( cdp, &nPad );
char * szResult;
cPad = ( HB_ISCHAR( 3 ) ? *( hb_parc( 3 ) ) : ' ' );
hb_xmemset( szResult, cPad, ( HB_SIZE ) nLen - nSize );
hb_xmemcpy( szResult + ( HB_SIZE ) nLen - nSize, szText, nSize );
if( nPad > 1 )
{
HB_SIZE nRep = ( ( HB_SIZE ) nLen - nSize ), nPos = 0;
nLen += nRep * ( nPad - 1 );
szResult = ( char * ) hb_xgrab( nLen + 1 );
while( nRep-- )
{
hb_xmemcpy( szResult + nPos, szPad, nPad );
nPos += nPad;
}
hb_xmemcpy( szResult + nPos, szText, nSize );
}
else
{
szResult = ( char * ) hb_xgrab( nLen + 1 );
hb_xmemset( szResult, szPad[ 0 ], ( HB_SIZE ) nLen - nSize );
hb_xmemcpy( szResult + ( HB_SIZE ) nLen - nSize, szText, nSize );
}
hb_retclen_buffer( szResult, ( HB_SIZE ) nLen );
if( bFreeReq )

View File

@@ -63,6 +63,22 @@ static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem )
hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen;
}
static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad )
{
const char * szPad = hb_parc( 3 );
*pnPad = 1;
if( szPad == NULL )
szPad = " ";
else if( HB_CDP_ISCHARIDX( cdp ) )
{
*pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 );
if( *pnPad == 0 )
szPad = "";
}
return szPad;
}
/* right-pads a date, number, or string with spaces or supplied character */
HB_FUNC( PADR )
{
@@ -95,12 +111,27 @@ HB_FUNC( PADR )
if( ( HB_SIZE ) nLen > nSize )
{
char * szResult = ( char * ) hb_xgrab( nLen + 1 );
char cPad;
HB_SIZE nPad = 0;
const char * szPad = s_hb_padGet( cdp, &nPad );
char * szResult;
cPad = ( HB_ISCHAR( 3 ) ? *( hb_parc( 3 ) ) : ' ' );
hb_xmemcpy( szResult, szText, nSize );
hb_xmemset( szResult + nSize, cPad, ( HB_SIZE ) nLen - nSize );
if( nPad > 1 )
{
nLen += ( nLen - nSize ) * ( nPad - 1 );
szResult = ( char * ) hb_xgrab( nLen + 1 );
hb_xmemcpy( szResult, szText, nSize );
while( nSize < ( HB_SIZE ) nLen )
{
hb_xmemcpy( szResult + nSize, szPad, nPad );
nSize += nPad;
}
}
else
{
szResult = ( char * ) hb_xgrab( nLen + 1 );
hb_xmemcpy( szResult, szText, nSize );
hb_xmemset( szResult + nSize, szPad[ 0 ], ( HB_SIZE ) nLen - nSize );
}
hb_retclen_buffer( szResult, ( HB_SIZE ) nLen );
if( bFreeReq )