From 5f6a55b505836984459d5a70e126296bb367c101 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 25 Apr 2012 09:41:47 +0000 Subject: [PATCH] 2012-04-25 11:41 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/include/harbour.hbx * harbour/src/rtl/chruni.c + added HB_ULEFT(), HB_BLEFT(), HB_URIGHT(), HB_BRIGHT() --- harbour/ChangeLog | 5 + harbour/include/harbour.hbx | 4 + harbour/src/rtl/chruni.c | 190 +++++++++++++++++++++++++++--------- 3 files changed, 152 insertions(+), 47 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a39f4dfd4d..7685d976d0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2012-04-25 11:41 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/include/harbour.hbx + * harbour/src/rtl/chruni.c + + added HB_ULEFT(), HB_BLEFT(), HB_URIGHT(), HB_BRIGHT() + 2012-04-25 02:20 UTC+0200 Viktor Szakats (harbour syenar.net) * include/harbour.hbx * src/rtl/inkey.c diff --git a/harbour/include/harbour.hbx b/harbour/include/harbour.hbx index 465d66a857..0ff81cb57a 100644 --- a/harbour/include/harbour.hbx +++ b/harbour/include/harbour.hbx @@ -320,12 +320,14 @@ DYNAMIC hb_bitSet DYNAMIC hb_bitShift DYNAMIC hb_bitTest DYNAMIC hb_bitXor +DYNAMIC hb_BLeft() DYNAMIC hb_BLen DYNAMIC hb_blowfishDecrypt DYNAMIC hb_blowfishEncrypt DYNAMIC hb_blowfishKey DYNAMIC hb_BPeek DYNAMIC hb_BPoke +DYNAMIC hb_BRight() DYNAMIC hb_BSubStr DYNAMIC hb_BuildDate DYNAMIC hb_ByteSwapI @@ -831,9 +833,11 @@ DYNAMIC hb_TToN DYNAMIC hb_TToS DYNAMIC hb_UChar DYNAMIC hb_UCode +DYNAMIC hb_ULeft() DYNAMIC hb_ULen DYNAMIC hb_UPeek DYNAMIC hb_UPoke +DYNAMIC hb_URight() DYNAMIC hb_UserLang DYNAMIC hb_UserName DYNAMIC hb_USubStr diff --git a/harbour/src/rtl/chruni.c b/harbour/src/rtl/chruni.c index d5951e076b..7544c0e193 100644 --- a/harbour/src/rtl/chruni.c +++ b/harbour/src/rtl/chruni.c @@ -266,53 +266,6 @@ HB_FUNC( HB_BPOKE ) hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } -/* HB_BSUBSTR( , , ) -> - */ -HB_FUNC( HB_BSUBSTR ) -{ - PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); - int iPCount = hb_pcount(); - - if( pText && HB_ISNUM( 2 ) && ( iPCount < 3 || HB_ISNUM( 3 ) ) ) - { - const char * pszText = hb_itemGetCPtr( pText ); - HB_ISIZ nSize = hb_itemGetCLen( pText ); - HB_ISIZ nFrom = hb_parns( 2 ); - HB_ISIZ nCount = iPCount < 3 ? nSize : hb_parns( 3 ); - - if( nFrom > 0 ) - { - if( --nFrom > nSize ) - nCount = 0; - } - if( nCount > 0 ) - { - if( nFrom < 0 ) - nFrom += nSize; - if( nFrom > 0 ) - { - pszText += nFrom; - nSize -= nFrom; - } - if( nCount > nSize ) - nCount = nSize; - } - - if( nCount > 0 ) - { - if( nFrom <= 0 && nCount == nSize ) - hb_itemReturn( pText ); - else - hb_retclen( pszText, nCount ); - } - else - hb_retc_null(); - } - else - hb_errRT_BASE_SubstR( EG_ARG, 1110, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); - -} - /* HB_USUBSTR( , , ) -> */ HB_FUNC( HB_USUBSTR ) @@ -360,3 +313,146 @@ HB_FUNC( HB_USUBSTR ) else hb_errRT_BASE_SubstR( EG_ARG, 1110, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } + +/* HB_BSUBSTR( , , ) -> + */ +HB_FUNC( HB_BSUBSTR ) +{ + PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); + int iPCount = hb_pcount(); + + if( pText && HB_ISNUM( 2 ) && ( iPCount < 3 || HB_ISNUM( 3 ) ) ) + { + const char * pszText = hb_itemGetCPtr( pText ); + HB_ISIZ nSize = hb_itemGetCLen( pText ); + HB_ISIZ nFrom = hb_parns( 2 ); + HB_ISIZ nCount = iPCount < 3 ? nSize : hb_parns( 3 ); + + if( nFrom > 0 ) + { + if( --nFrom > nSize ) + nCount = 0; + } + if( nCount > 0 ) + { + if( nFrom < 0 ) + nFrom += nSize; + if( nFrom > 0 ) + { + pszText += nFrom; + nSize -= nFrom; + } + if( nCount > nSize ) + nCount = nSize; + } + + if( nCount > 0 ) + { + if( nFrom <= 0 && nCount == nSize ) + hb_itemReturn( pText ); + else + hb_retclen( pszText, nCount ); + } + else + hb_retc_null(); + } + else + hb_errRT_BASE_SubstR( EG_ARG, 1110, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* HB_ULEFT( , ) -> + */ +HB_FUNC( HB_ULEFT ) +{ + PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); + + if( pText && HB_ISNUM( 2 ) ) + { + HB_ISIZ nLen = hb_parns( 2 ); + if( nLen <= 0 ) + hb_retc_null(); + else + { + HB_SIZE nText = hb_itemGetCLen( pText ); + if( ( HB_SIZE ) nLen < nText ) + nLen = hb_cdpTextPos( hb_vmCDP(), hb_itemGetCPtr( pText ), nText, nLen ); + if( ( HB_SIZE ) nLen >= nText ) + hb_itemReturn( pText ); + else + hb_retclen( hb_itemGetCPtr( pText ), nLen ); + } + } + else + hb_errRT_BASE_SubstR( EG_ARG, 1124, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* HB_BLEFT( , ) -> + */ +HB_FUNC( HB_BLEFT ) +{ + PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); + + if( pText && HB_ISNUM( 2 ) ) + { + HB_ISIZ nLen = hb_parns( 2 ); + if( nLen <= 0 ) + hb_retc_null(); + else + { + HB_SIZE nText = hb_itemGetCLen( pText ); + if( ( HB_SIZE ) nLen >= nText ) + hb_itemReturn( pText ); + else + hb_retclen( hb_itemGetCPtr( pText ), nLen ); + } + } + else + hb_errRT_BASE_SubstR( EG_ARG, 1124, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* HB_URIGHT( , ) -> + */ +HB_FUNC( HB_URIGHT ) +{ + PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); + HB_SIZE nText = hb_itemGetCLen( pText ); + HB_ISIZ nLen = hb_parns( 2 ); + + if( nLen > 0 && nText > 0 ) + { + if( ( HB_SIZE ) nLen < nText ) + { + PHB_CODEPAGE cdp = hb_vmCDP(); + HB_SIZE nChars = hb_cdpTextLen( cdp, hb_itemGetCPtr( pText ), nText ); + if( nChars > ( HB_SIZE ) nLen ) + nLen = nText - hb_cdpTextPos( cdp, hb_itemGetCPtr( pText ), nText, nChars - nLen ); + else + nLen = nText; + } + if( ( HB_SIZE ) nLen >= nText ) + hb_itemReturn( pText ); + else + hb_retclen( hb_itemGetCPtr( pText ) + nText - nLen, nLen ); + } + else + hb_retc_null(); +} + +/* HB_BRIGHT( , ) -> + */ +HB_FUNC( HB_BRIGHT ) +{ + PHB_ITEM pText = hb_param( 1, HB_IT_STRING ); + HB_SIZE nText = hb_itemGetCLen( pText ); + HB_ISIZ nLen = hb_parns( 2 ); + + if( nLen > 0 && nText > 0 ) + { + if( ( HB_SIZE ) nLen >= nText ) + hb_itemReturn( pText ); + else + hb_retclen( hb_itemGetCPtr( pText ) + nText - nLen, nLen ); + } + else + hb_retc_null(); +}