diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5e2aa9407a..20653b2e2d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,50 @@ The license applies to all entries newer than 2009-04-28. */ +2012-07-18 18:15 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbgt/tests/test.prg + * formatting (manual) + + * contrib/hbct/bitnum.c + * contrib/hbct/charmirr.c + * contrib/hbct/charonly.c + * contrib/hbct/charsort.c + * contrib/hbct/ctpad.c + * contrib/hbct/ctstr.c + * contrib/hbct/envparam.c + * contrib/hbct/expand.c + * contrib/hbct/files.c + * contrib/hbct/justify.c + * contrib/hbct/misc2.c + * contrib/hbct/numat.c + * contrib/hbct/pos1.c + * contrib/hbct/posdiff.c + * contrib/hbct/relation.c + * contrib/hbct/replace.c + * contrib/hbct/strswap.c + * contrib/hbct/token1.c + * contrib/hbct/token2.c + * minor whitespace formatting + + * contrib/hbgt/ascposgt.c + * contrib/hbgt/atdiff.c + * contrib/hbgt/bitflags.c + * contrib/hbgt/chareven.c + * contrib/hbgt/charmixg.c + * contrib/hbgt/charodd.c + * contrib/hbgt/chrcount.c + * contrib/hbgt/chrfirst.c + * contrib/hbgt/chrtotal.c + * contrib/hbgt/strasint.c + * contrib/hbgt/strcount.c + * contrib/hbgt/strcspn.c + * contrib/hbgt/strdiffg.c + * contrib/hbgt/strexpan.c + * contrib/hbgt/strleft.c + * contrib/hbgt/strpbrk.c + * contrib/hbgt/strright.c + * reformatted using uncrustify + 2012-07-18 16:25 UTC+0200 Viktor Szakats (harbour syenar.net) * tests/clsnv.prg * tests/cursrtst.prg diff --git a/harbour/contrib/hbct/bitnum.c b/harbour/contrib/hbct/bitnum.c index 995ed34dc5..e4fbc81fb1 100644 --- a/harbour/contrib/hbct/bitnum.c +++ b/harbour/contrib/hbct/bitnum.c @@ -58,7 +58,7 @@ HB_BOOL ct_numParam( int iParam, HB_MAXINT * plNum ) { - const char *szHex = hb_parc( iParam ); + const char * szHex = hb_parc( iParam ); if( szHex ) { diff --git a/harbour/contrib/hbct/charmirr.c b/harbour/contrib/hbct/charmirr.c index a2c4434f70..638396a084 100644 --- a/harbour/contrib/hbct/charmirr.c +++ b/harbour/contrib/hbct/charmirr.c @@ -65,9 +65,9 @@ HB_FUNC( CHARMIRR ) if( HB_ISCHAR( 1 ) ) { - const char * pcString = hb_parc( 1 ), *pc1; + const char * pcString = hb_parc( 1 ), * pc1; HB_SIZE sStrLen = hb_parclen( 1 ); - char * pcRet, *pc2; + char * pcRet, * pc2; int iDontMirrorSpaces; if( HB_ISLOG( 2 ) ) diff --git a/harbour/contrib/hbct/charonly.c b/harbour/contrib/hbct/charonly.c index f84c7123f9..6cb9e2a128 100644 --- a/harbour/contrib/hbct/charonly.c +++ b/harbour/contrib/hbct/charonly.c @@ -77,7 +77,7 @@ static void do_charonly( int iSwitch ) char * pcRet; HB_SIZE sRetStrLen = 0; int iShift, iBool; - const char * pcSub, *pc; + const char * pcSub, * pc; /* check for zero-length strings */ switch ( iSwitch ) diff --git a/harbour/contrib/hbct/charsort.c b/harbour/contrib/hbct/charsort.c index 7b1e912c2b..f7f4e5ba80 100644 --- a/harbour/contrib/hbct/charsort.c +++ b/harbour/contrib/hbct/charsort.c @@ -64,7 +64,7 @@ int extern _LNK_CONV #else static int #endif -_hb_do_sortascend( const void *p1, const void *p2 ) +_hb_do_sortascend( const void * p1, const void * p2 ) { const char * pc1 = ( const char * ) p1; const char * pc2 = ( const char * ) p2; @@ -80,7 +80,7 @@ int extern _LNK_CONV #else static int #endif -_hb_do_sortdescend( const void *p1, const void *p2 ) +_hb_do_sortdescend( const void * p1, const void * p2 ) { const char * pc1 = ( const char * ) p1; const char * pc2 = ( const char * ) p2; diff --git a/harbour/contrib/hbct/ctpad.c b/harbour/contrib/hbct/ctpad.c index a7c79651bf..d2c6fc7788 100644 --- a/harbour/contrib/hbct/ctpad.c +++ b/harbour/contrib/hbct/ctpad.c @@ -65,7 +65,7 @@ static void do_pad( int iSwitch ) { const char * pcString = hb_parc( 1 ); HB_SIZE sStrLen = hb_parclen( 1 ); - char * pcRet, *pc; + char * pcRet, * pc; HB_ISIZ nRetLen; HB_SIZE sRetLen; char cFill; diff --git a/harbour/contrib/hbct/ctstr.c b/harbour/contrib/hbct/ctstr.c index 286a805111..4f480c71f8 100644 --- a/harbour/contrib/hbct/ctstr.c +++ b/harbour/contrib/hbct/ctstr.c @@ -72,8 +72,8 @@ int ct_str_exit( void ) /* -------------------------- */ /* search for exact substring */ /* -------------------------- */ -const char *ct_at_exact_forward( const char * pcString, HB_SIZE sStrLen, - const char * pcMatch, HB_SIZE sMatchLen, HB_SIZE * psMatchStrLen ) +const char * ct_at_exact_forward( const char * pcString, HB_SIZE sStrLen, + const char * pcMatch, HB_SIZE sMatchLen, HB_SIZE * psMatchStrLen ) { HB_SIZE sPos; @@ -101,8 +101,8 @@ const char *ct_at_exact_forward( const char * pcString, HB_SIZE sStrLen, /* ------------------------------------------------ */ /* search for exact substring in backward direction */ /* ------------------------------------------------ */ -const char *ct_at_exact_backward( const char * pcString, HB_SIZE sStrLen, - const char * pcMatch, HB_SIZE sMatchLen, HB_SIZE * psMatchStrLen ) +const char * ct_at_exact_backward( const char * pcString, HB_SIZE sStrLen, + const char * pcMatch, HB_SIZE sMatchLen, HB_SIZE * psMatchStrLen ) { HB_SIZE sIndex; @@ -134,9 +134,9 @@ const char *ct_at_exact_backward( const char * pcString, HB_SIZE sStrLen, /* ----------------------------------- */ /* search for substring using wildcard */ /* ----------------------------------- */ -const char *ct_at_wildcard_forward( const char * pcString, HB_SIZE sStrLen, - const char * pcMatch, HB_SIZE sMatchLen, - char cWildCard, HB_SIZE * psMatchStrLen ) +const char * ct_at_wildcard_forward( const char * pcString, HB_SIZE sStrLen, + const char * pcMatch, HB_SIZE sMatchLen, + char cWildCard, HB_SIZE * psMatchStrLen ) { HB_SIZE sIndex; @@ -172,9 +172,9 @@ const char *ct_at_wildcard_forward( const char * pcString, HB_SIZE sStrLen, /* --------------------------------------------------------- */ /* search for substring using wildcard in backward direction */ /* --------------------------------------------------------- */ -const char *ct_at_wildcard_backward( const char * pcString, HB_SIZE sStrLen, - const char * pcMatch, HB_SIZE sMatchLen, - char cWildCard, HB_SIZE * psMatchStrLen ) +const char * ct_at_wildcard_backward( const char * pcString, HB_SIZE sStrLen, + const char * pcMatch, HB_SIZE sMatchLen, + char cWildCard, HB_SIZE * psMatchStrLen ) { HB_SIZE sIndex; @@ -210,8 +210,8 @@ const char *ct_at_wildcard_backward( const char * pcString, HB_SIZE sStrLen, /* ------------------------------- */ /* search for character from a set */ /* ------------------------------- */ -const char *ct_at_charset_forward( const char * pcString, HB_SIZE sStrLen, - const char * pcCharSet, HB_SIZE sCharSetLen, HB_SIZE * psMatchedCharPos ) +const char * ct_at_charset_forward( const char * pcString, HB_SIZE sStrLen, + const char * pcCharSet, HB_SIZE sCharSetLen, HB_SIZE * psMatchedCharPos ) { const char * pcRet, * pcSet, * pcStop1, * pcStop2; @@ -243,8 +243,8 @@ const char *ct_at_charset_forward( const char * pcString, HB_SIZE sStrLen, /* ----------------------------------------------------- */ /* search for character from a set in backward direction */ /* ----------------------------------------------------- */ -const char *ct_at_charset_backward( const char * pcString, HB_SIZE sStrLen, - const char * pcCharSet, HB_SIZE sCharSetLen, HB_SIZE * psMatchedCharPos ) +const char * ct_at_charset_backward( const char * pcString, HB_SIZE sStrLen, + const char * pcCharSet, HB_SIZE sCharSetLen, HB_SIZE * psMatchedCharPos ) { const char * pcRet, * pcSet, * pcStop; diff --git a/harbour/contrib/hbct/envparam.c b/harbour/contrib/hbct/envparam.c index 6cb4cc9273..563cc62ddb 100644 --- a/harbour/contrib/hbct/envparam.c +++ b/harbour/contrib/hbct/envparam.c @@ -59,18 +59,18 @@ # include # define environ (*_NSGetEnviron()) # elif !defined( __WATCOMC__ ) - extern char **environ; + extern char ** environ; # endif #elif defined( HB_OS_DOS ) # if defined( __DJGPP__ ) - extern char **environ; + extern char ** environ; # elif !defined( __WATCOMC__ ) # define environ _environ - extern char **_environ; + extern char ** _environ; # endif #elif defined( HB_OS_OS2 ) # if !defined( __WATCOMC__ ) - extern char **environ; + extern char ** environ; # endif #elif defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) # include "hbwinuni.h" diff --git a/harbour/contrib/hbct/expand.c b/harbour/contrib/hbct/expand.c index 942c1724c9..5e5cb8f60b 100644 --- a/harbour/contrib/hbct/expand.c +++ b/harbour/contrib/hbct/expand.c @@ -64,7 +64,7 @@ HB_FUNC( EXPAND ) hb_retclen( szText, 1 ); else { - char * szDest, *szPtr, cRepl; + char * szDest, * szPtr, cRepl; int iRepl, i; iRepl = hb_parni( 2 ); diff --git a/harbour/contrib/hbct/files.c b/harbour/contrib/hbct/files.c index dbee19e5d1..77835e88e4 100644 --- a/harbour/contrib/hbct/files.c +++ b/harbour/contrib/hbct/files.c @@ -199,7 +199,7 @@ HB_FUNC( SETFATTR ) HB_FUNC( SETFDATI ) { - const char *szFile = hb_parc( 1 ); + const char * szFile = hb_parc( 1 ); HB_BOOL fResult = HB_FALSE; if( szFile && *szFile ) diff --git a/harbour/contrib/hbct/justify.c b/harbour/contrib/hbct/justify.c index 3e64ee16a0..72a0860f91 100644 --- a/harbour/contrib/hbct/justify.c +++ b/harbour/contrib/hbct/justify.c @@ -68,12 +68,11 @@ static void do_justify( int iSwitch ) if( HB_ISCHAR( 1 ) ) { - const char * pcString = hb_parc( 1 ); HB_SIZE sStrLen = hb_parclen( 1 ); char cJustChar; const char * pc; - char * pcRet, *pcw; + char * pcRet, * pcw; HB_SIZE sJustOffset; if( sStrLen == 0 ) diff --git a/harbour/contrib/hbct/misc2.c b/harbour/contrib/hbct/misc2.c index de27ab017c..2d74918675 100644 --- a/harbour/contrib/hbct/misc2.c +++ b/harbour/contrib/hbct/misc2.c @@ -65,8 +65,8 @@ HB_FUNC( COMPLEMENT ) if( nLen > 0 ) { - const char *szSrc = hb_itemGetCPtr( pItem ); - char *szBuffer = ( char * ) hb_xgrab( nLen + 1 ); + const char * szSrc = hb_itemGetCPtr( pItem ); + char * szBuffer = ( char * ) hb_xgrab( nLen + 1 ); for( ulPos = 0; ulPos < nLen; ulPos++ ) szBuffer[ ulPos ] = ~szSrc[ ulPos ]; diff --git a/harbour/contrib/hbct/numat.c b/harbour/contrib/hbct/numat.c index ac4806a7ae..7cfb7c5609 100644 --- a/harbour/contrib/hbct/numat.c +++ b/harbour/contrib/hbct/numat.c @@ -67,7 +67,7 @@ HB_FUNC( NUMAT ) char cAtLike = ct_getatlikechar(); HB_SIZE sIgnore, sMatchStrLen = 0, sSubStrLen; HB_SIZE nCounter; - const char * pc, *pcSubStr; + const char * pc, * pcSubStr; /* eventually ignore some characters */ if( HB_ISNUM( 3 ) ) diff --git a/harbour/contrib/hbct/pos1.c b/harbour/contrib/hbct/pos1.c index 6b85e638c8..8dc6da71d3 100644 --- a/harbour/contrib/hbct/pos1.c +++ b/harbour/contrib/hbct/pos1.c @@ -72,7 +72,7 @@ static void do_pos1( int iSwitch ) HB_ISCHAR( 2 ) && /* .. string as 2nd .. */ HB_ISCHAR( 3 ) ) ) ) /* .. and 3rd param */ { - const unsigned char * pcString, *puc; + const unsigned char * pcString, * puc; HB_SIZE sStrLen; unsigned char ucChar1 = ' ', ucChar2 = ' '; int iMode; diff --git a/harbour/contrib/hbct/posdiff.c b/harbour/contrib/hbct/posdiff.c index f0804598c2..13f9ee3ba8 100644 --- a/harbour/contrib/hbct/posdiff.c +++ b/harbour/contrib/hbct/posdiff.c @@ -62,7 +62,7 @@ HB_FUNC( POSDIFF ) HB_SIZE sStrLen1 = hb_parclen( 1 ); const char * pcString2 = hb_parc( 2 ); HB_SIZE sStrLen2 = hb_parclen( 2 ); - const char * pc1, *pc2; + const char * pc1, * pc2; HB_SIZE sIgnore; if( HB_ISNUM( 3 ) ) @@ -131,7 +131,7 @@ HB_FUNC( POSEQUAL ) HB_SIZE sStrLen1 = hb_parclen( 1 ); const char * pcString2 = hb_parc( 2 ); HB_SIZE sStrLen2 = hb_parclen( 2 ); - const char * pc1, *pc2; + const char * pc1, * pc2; HB_SIZE sIgnore, sCompare, sCompareCnt, sRet = 0; if( HB_ISNUM( 4 ) ) diff --git a/harbour/contrib/hbct/relation.c b/harbour/contrib/hbct/relation.c index 9e084e7077..c2305453bf 100644 --- a/harbour/contrib/hbct/relation.c +++ b/harbour/contrib/hbct/relation.c @@ -67,7 +67,7 @@ HB_FUNC( CHARRELA ) const char * pcString2 = hb_parc( 4 ); HB_SIZE sStrLen2 = hb_parclen( 4 ); - const char * pc1, *pc2; + const char * pc1, * pc2; HB_SIZE sOffset1, sOffset2; HB_SIZE sMatchStrLen; @@ -153,7 +153,7 @@ HB_FUNC( CHARRELREP ) const char * pcReplace = hb_parc( 5 ); HB_SIZE sReplaceLen = hb_parclen( 5 ); char * pcRet; - const char * pc1, *pc2; + const char * pc1, * pc2; HB_SIZE sOffset1, sOffset2; HB_SIZE sMatchStrLen; diff --git a/harbour/contrib/hbct/replace.c b/harbour/contrib/hbct/replace.c index 0d69e55455..685d38743e 100644 --- a/harbour/contrib/hbct/replace.c +++ b/harbour/contrib/hbct/replace.c @@ -77,7 +77,7 @@ static void do_replace( int iSwitch ) { const char * pcString = hb_parc( 1 ); HB_SIZE sStrLen = hb_parclen( 1 ); - char * pcRet, *pc; + char * pcRet, * pc; char cSearch, cReplace; if( sStrLen == 0 ) diff --git a/harbour/contrib/hbct/strswap.c b/harbour/contrib/hbct/strswap.c index 7645c81ef3..a86a80c8ff 100644 --- a/harbour/contrib/hbct/strswap.c +++ b/harbour/contrib/hbct/strswap.c @@ -65,7 +65,7 @@ HB_FUNC( STRSWAP ) /* get parameters */ const char * pcString1 = hb_parc( 1 ); const char * pcString2 = hb_parc( 2 ); - char * pcRet1 = NULL, *pcRet2 = NULL; + char * pcRet1 = NULL, * pcRet2 = NULL; int iChange1, iChange2; HB_SIZE sIndex, sCmpLen; diff --git a/harbour/contrib/hbct/token1.c b/harbour/contrib/hbct/token1.c index 1fd768811b..9366a487e1 100644 --- a/harbour/contrib/hbct/token1.c +++ b/harbour/contrib/hbct/token1.c @@ -61,7 +61,7 @@ #include "ct.h" /* static const data */ -static const char *s_pcSeparatorStr = +static const char * s_pcSeparatorStr = "\x00" "\x09" "\x0A" "\x0C" "\x1A" "\x20" "\x8A" "\x8C" ",.;:!\?/\\<>()#&%+-*"; static const HB_SIZE s_sSeparatorStrLen = 26; diff --git a/harbour/contrib/hbct/token2.c b/harbour/contrib/hbct/token2.c index 53e13c1400..d55664e613 100644 --- a/harbour/contrib/hbct/token2.c +++ b/harbour/contrib/hbct/token2.c @@ -75,7 +75,7 @@ typedef struct _TOKEN_POSITION HB_SIZE sEndPos; /* relative 0-based index of first char BEHIND token, so that length = sEndPos-sStartPos */ } TOKEN_POSITION; -typedef TOKEN_POSITION *TOKEN_ENVIRONMENT; +typedef TOKEN_POSITION * TOKEN_ENVIRONMENT; /* -------------------------------------------------------------------- */ /* alloc new token environment */ @@ -147,7 +147,7 @@ static HB_SIZE sTokEnvGetSize( TOKEN_ENVIRONMENT env ) /* get position element pointed to by tokenizing pointer */ /* -------------------------------------------------------------------- */ -static TOKEN_POSITION *sTokEnvGetPos( TOKEN_ENVIRONMENT env ) +static TOKEN_POSITION * sTokEnvGetPos( TOKEN_ENVIRONMENT env ) { if( env[ 1 ].sStartPos >= env[ 0 ].sStartPos ) return NULL; @@ -159,7 +159,7 @@ static TOKEN_POSITION *sTokEnvGetPos( TOKEN_ENVIRONMENT env ) /* get position element pointed to by given 0-based index */ /* -------------------------------------------------------------------- */ -static TOKEN_POSITION *sTokEnvGetPosIndex( TOKEN_ENVIRONMENT env, HB_SIZE index ) +static TOKEN_POSITION * sTokEnvGetPosIndex( TOKEN_ENVIRONMENT env, HB_SIZE index ) { if( index >= env[ 0 ].sStartPos ) return NULL; @@ -245,7 +245,7 @@ static void sTokEnvDel( TOKEN_ENVIRONMENT env ) /* ==================================================================== */ /* static data */ -static const char *spcSeparatorStr = +static const char * spcSeparatorStr = "\x00" "\x09" "\x0A" "\x0C" "\x1A" "\x20" "\x8A" "\x8C" ",.;:!\?/\\<>()#&%+-*"; static const HB_SIZE ssSeparatorStrLen = 26; @@ -287,7 +287,7 @@ HB_FUNC( TOKENINIT ) const char * pcSeparatorStr; HB_SIZE sSeparatorStrLen; HB_SIZE nSkipCnt, nSkip; - const char * pcSubStr, *pc; + const char * pcSubStr, * pc; HB_SIZE sSubStrLen; TOKEN_ENVIRONMENT sTokenEnvironment; TOKEN_POSITION sTokenPosition; @@ -433,7 +433,7 @@ HB_FUNC( TOKENNEXT ) HB_SIZE sStrLen = hb_parclen( 1 ); TOKEN_ENVIRONMENT sTokenEnvironment; - TOKEN_POSITION *psTokenPosition; + TOKEN_POSITION * psTokenPosition; /* token environment by parameter ... */ if( HB_ISCHAR( 3 ) && HB_ISBYREF( 3 ) ) diff --git a/harbour/contrib/hbgt/ascposgt.c b/harbour/contrib/hbgt/ascposgt.c index 5cac551891..34ce5c2f1f 100644 --- a/harbour/contrib/hbgt/ascposgt.c +++ b/harbour/contrib/hbgt/ascposgt.c @@ -21,21 +21,24 @@ HB_FUNC( GT_ASCPOS ) { - const char *s; - HB_SIZE p; + const char * s; + HB_SIZE p; - if (HB_ISCHAR(1) && HB_ISNUM(2)) { - s = hb_parc(1); - p = hb_parns(2); - p--; /* decrement p to adjust for c strings */ - /* starting at position 0 */ + if( HB_ISCHAR( 1 ) && HB_ISNUM( 2 ) ) + { + s = hb_parc( 1 ); + p = hb_parns( 2 ); + p--; /* decrement p to adjust for c strings */ + /* starting at position 0 */ - if (p > hb_parclen(1)) /* oh oh p > length of passed string */ - hb_retni(-2); /* error -2 */ - else - hb_retni((int) s[p]); /* return ascii code of appropriate */ - /* character in string */ - } else { - hb_retni(-1); /* parameter mismatch - error -1 */ - } + if( p > hb_parclen( 1 ) ) /* oh oh p > length of passed string */ + hb_retni( -2 ); /* error -2 */ + else + hb_retni( ( int ) s[ p ] ); /* return ascii code of appropriate */ + /* character in string */ + } + else + { + hb_retni( -1 ); /* parameter mismatch - error -1 */ + } } diff --git a/harbour/contrib/hbgt/atdiff.c b/harbour/contrib/hbgt/atdiff.c index 4b1bdde067..a593ae1851 100644 --- a/harbour/contrib/hbgt/atdiff.c +++ b/harbour/contrib/hbgt/atdiff.c @@ -21,29 +21,32 @@ HB_FUNC( GT_ATDIFF ) { - const char *s1, *s2; - HB_ISIZ pos, len; + const char * s1, * s2; + HB_ISIZ pos, len; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - s1 = hb_parc(1); - s2 = hb_parc(2); - len = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + s1 = hb_parc( 1 ); + s2 = hb_parc( 2 ); + len = hb_parclen( 2 ); - /* - loop through comparing both strings + /* + loop through comparing both strings - NOTE: pos starts at 1, so as to return a string index - for CLIPPER - */ + NOTE: pos starts at 1, so as to return a string index + for CLIPPER + */ - for (pos = 1; (pos <= len) && (*s1 == *s2); s2++, s1++) - pos++; + for( pos = 1; ( pos <= len ) && ( *s1 == *s2 ); s2++, s1++ ) + pos++; - if (pos > len) /* strings match exactly!!! */ - hb_retns(0); - else - hb_retns(pos); - } else { - hb_retns(-1); /* parameter mismatch - error -1 */ - } + if( pos > len ) /* strings match exactly!!! */ + hb_retns( 0 ); + else + hb_retns( pos ); + } + else + { + hb_retns( -1 ); /* parameter mismatch - error -1 */ + } } diff --git a/harbour/contrib/hbgt/bitflags.c b/harbour/contrib/hbgt/bitflags.c index dbf802e403..fe96cb099d 100644 --- a/harbour/contrib/hbgt/bitflags.c +++ b/harbour/contrib/hbgt/bitflags.c @@ -28,153 +28,153 @@ #include "hbapi.h" -#define _GT_MAX(x,y) (x > y ? x : y) +#define _GT_MAX( x, y ) ( x > y ? x : y ) HB_FUNC( GT_NEWFLAG ) { - char *FlagString; - unsigned ByteCount; - unsigned FlagCount = 1; - unsigned Byte; + char * FlagString; + unsigned ByteCount; + unsigned FlagCount = 1; + unsigned Byte; - if (ISNUM(1)) - { - FlagCount = (unsigned) hb_parni(1); - } - if (FlagCount > 0) - { - ByteCount = (unsigned)((FlagCount / 8) + 1); - if (!(FlagCount % 8)) - { - --ByteCount; - } - FlagString = hb_xgrab(ByteCount); - for (Byte = 0; Byte < ByteCount; Byte++) - { - FlagString[Byte] = 0; - } - hb_retclen(FlagString, ByteCount); - hb_xfree(FlagString); - } - else - { - hb_retc_null(); - } + if( ISNUM( 1 ) ) + { + FlagCount = ( unsigned ) hb_parni( 1 ); + } + if( FlagCount > 0 ) + { + ByteCount = ( unsigned ) ( ( FlagCount / 8 ) + 1 ); + if( ! ( FlagCount % 8 ) ) + { + --ByteCount; + } + FlagString = hb_xgrab( ByteCount ); + for( Byte = 0; Byte < ByteCount; Byte++ ) + { + FlagString[ Byte ] = 0; + } + hb_retclen( FlagString, ByteCount ); + hb_xfree( FlagString ); + } + else + { + hb_retc_null(); + } } HB_FUNC( GT_SETFLAG ) { - char *FlagString; - unsigned StartBit = 1; - unsigned EndBit = 1; - unsigned BitCount; - unsigned BitPointer; - unsigned BytePointer; + char * FlagString; + unsigned StartBit = 1; + unsigned EndBit = 1; + unsigned BitCount; + unsigned BitPointer; + unsigned BytePointer; - if ( HB_ISCHAR(1) ) - { - FlagString = hb_parc(1); - if ( HB_ISNUM(2) ) - { - StartBit = hb_parni(2); - } - if ( HB_ISNUM(3) ) - { - EndBit = hb_parni(3); - } - EndBit = _GT_MAX(StartBit, EndBit); - if (StartBit > 0 && EndBit <= (hb_parclen(1) * 8)) - { - for (BitCount = StartBit; BitCount <= EndBit; BitCount++) - { - BitPointer = BitCount % 8; - BytePointer = (unsigned) (BitCount / 8); - if (!BitPointer) - { - BitPointer = 8; - --BytePointer; - } - FlagString[BytePointer] |= 1 << (BitPointer - 1); - } - } - hb_retclen(FlagString, hb_parclen(1)); - } - else - { - hb_retc_null(); - } + if( HB_ISCHAR( 1 ) ) + { + FlagString = hb_parc( 1 ); + if( HB_ISNUM( 2 ) ) + { + StartBit = hb_parni( 2 ); + } + if( HB_ISNUM( 3 ) ) + { + EndBit = hb_parni( 3 ); + } + EndBit = _GT_MAX( StartBit, EndBit ); + if( StartBit > 0 && EndBit <= ( hb_parclen( 1 ) * 8 ) ) + { + for( BitCount = StartBit; BitCount <= EndBit; BitCount++ ) + { + BitPointer = BitCount % 8; + BytePointer = ( unsigned ) ( BitCount / 8 ); + if( ! BitPointer ) + { + BitPointer = 8; + --BytePointer; + } + FlagString[ BytePointer ] |= 1 << ( BitPointer - 1 ); + } + } + hb_retclen( FlagString, hb_parclen( 1 ) ); + } + else + { + hb_retc_null(); + } } HB_FUNC( GT_CLRFLAG ) { - char *FlagString; - unsigned StartBit = 1; - unsigned EndBit = 1; - unsigned BitCount; - unsigned BitPointer; - unsigned BytePointer; + char * FlagString; + unsigned StartBit = 1; + unsigned EndBit = 1; + unsigned BitCount; + unsigned BitPointer; + unsigned BytePointer; - if ( HB_ISCHAR(1) ) - { - FlagString = hb_parc(1); - if ( HB_ISNUM(2) ) - { - StartBit = hb_parni(2); - } - if ( HB_ISNUM(3) ) - { - EndBit = hb_parni(3); - } - EndBit = _GT_MAX(StartBit, EndBit); - if (StartBit > 0 && EndBit <= (hb_parclen(1) * 8)) - { - for (BitCount = StartBit; BitCount <= EndBit; BitCount++) - { - BitPointer = BitCount % 8; - BytePointer = (unsigned) (BitCount / 8); - if (!BitPointer) - { - BitPointer = 8; - --BytePointer; - } - FlagString[BytePointer] &= 0xff - (1 << (BitPointer - 1)); - } - } - hb_retclen(FlagString, hb_parclen(1)); - } - else - { - hb_retc_null(); - } + if( HB_ISCHAR( 1 ) ) + { + FlagString = hb_parc( 1 ); + if( HB_ISNUM( 2 ) ) + { + StartBit = hb_parni( 2 ); + } + if( HB_ISNUM( 3 ) ) + { + EndBit = hb_parni( 3 ); + } + EndBit = _GT_MAX( StartBit, EndBit ); + if( StartBit > 0 && EndBit <= ( hb_parclen( 1 ) * 8 ) ) + { + for( BitCount = StartBit; BitCount <= EndBit; BitCount++ ) + { + BitPointer = BitCount % 8; + BytePointer = ( unsigned ) ( BitCount / 8 ); + if( ! BitPointer ) + { + BitPointer = 8; + --BytePointer; + } + FlagString[ BytePointer ] &= 0xff - ( 1 << ( BitPointer - 1 ) ); + } + } + hb_retclen( FlagString, hb_parclen( 1 ) ); + } + else + { + hb_retc_null(); + } } HB_FUNC( GT_ISFLAG ) { - HB_BOOL FlagStatus = HB_FALSE; - unsigned Bit = 1; - unsigned BitPointer; - unsigned BytePointer; - char *FlagString; + HB_BOOL FlagStatus = HB_FALSE; + unsigned Bit = 1; + unsigned BitPointer; + unsigned BytePointer; + char * FlagString; - if ( HB_ISCHAR(1) ) - { - FlagString = hb_parc(1); - if ( HB_ISNUM(2) ) - { - Bit = hb_parni(2); - } - if (Bit > 0 && Bit <= (hb_parclen(1) * 8)) - { - BitPointer = Bit % 8; - BytePointer = (unsigned) (Bit / 8); - if (!BitPointer) - { - BitPointer = 8; - --BytePointer; - } - FlagStatus = FlagString[BytePointer] & (1 << (BitPointer - 1)); - } - } - hb_retl(FlagStatus); + if( HB_ISCHAR( 1 ) ) + { + FlagString = hb_parc( 1 ); + if( HB_ISNUM( 2 ) ) + { + Bit = hb_parni( 2 ); + } + if( Bit > 0 && Bit <= ( hb_parclen( 1 ) * 8 ) ) + { + BitPointer = Bit % 8; + BytePointer = ( unsigned ) ( Bit / 8 ); + if( ! BitPointer ) + { + BitPointer = 8; + --BytePointer; + } + FlagStatus = FlagString[ BytePointer ] & ( 1 << ( BitPointer - 1 ) ); + } + } + hb_retl( FlagStatus ); } diff --git a/harbour/contrib/hbgt/chareven.c b/harbour/contrib/hbgt/chareven.c index f0251da297..42956eac27 100644 --- a/harbour/contrib/hbgt/chareven.c +++ b/harbour/contrib/hbgt/chareven.c @@ -21,21 +21,24 @@ HB_FUNC( GT_CHAREVEN ) { - const char *s1; - char *s2; - HB_ISIZ len, i; + const char * s1; + char * s2; + HB_ISIZ len, i; - if (HB_ISCHAR(1)) { - s1 = hb_parc(1); - len = hb_parclen(1); + if( HB_ISCHAR( 1 ) ) + { + s1 = hb_parc( 1 ); + len = hb_parclen( 1 ); - s2 = (char *) hb_xgrab(len / 2 + 1); /* grab us some mem to work with */ + s2 = ( char * ) hb_xgrab( len / 2 + 1 ); /* grab us some mem to work with */ - for (i = 1; i <= len; i += 2) - s2[(i - 1)/2] = s1[i] & 0x7f; + for( i = 1; i <= len; i += 2 ) + s2[ ( i - 1 ) / 2 ] = s1[ i ] & 0x7f; - hb_retclen_buffer(s2, len/2); - } else { - hb_retc_null(); /* parameter mismatch - error NullStr */ - } + hb_retclen_buffer( s2, len / 2 ); + } + else + { + hb_retc_null(); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/charmixg.c b/harbour/contrib/hbgt/charmixg.c index 2d4143bad4..fdb657002e 100644 --- a/harbour/contrib/hbgt/charmixg.c +++ b/harbour/contrib/hbgt/charmixg.c @@ -21,34 +21,38 @@ HB_FUNC( GT_CHARMIX ) { - const char *s1, *s2; - char *s3; - HB_ISIZ l1, l2, i, pos3; + const char * s1, * s2; + char * s3; + HB_ISIZ l1, l2, i, pos3; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - s1 = hb_parc(1); - s2 = hb_parc(2); - l1 = hb_parclen(1); - l2 = hb_parclen(2); - pos3 = 0; + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + s1 = hb_parc( 1 ); + s2 = hb_parc( 2 ); + l1 = hb_parclen( 1 ); + l2 = hb_parclen( 2 ); + pos3 = 0; - s3 = (char*)hb_xgrab(l1 + l2 + 1); /* grab us some mem to work with */ + s3 = ( char * ) hb_xgrab( l1 + l2 + 1 ); /* grab us some mem to work with */ - for (i = 0; i < l1; i++) { - s3[pos3++] = s1[i]; + for( i = 0; i < l1; i++ ) + { + s3[ pos3++ ] = s1[ i ]; - if (i < l2) - s3[pos3++] = s2[i]; - } + if( i < l2 ) + s3[ pos3++ ] = s2[ i ]; + } - if (l2 > l1) - for (; i < l2; i++) - s3[pos3++] = s2[i]; + if( l2 > l1 ) + for(; i < l2; i++ ) + s3[ pos3++ ] = s2[ i ]; - s3[pos3] = '\0'; - hb_retclen(s3, l1 + l2); - hb_xfree(s3); /* free alloc'ed mem */ - } else { - hb_retc_null(); /* parameter mismatch - error NullStr */ - } + s3[ pos3 ] = '\0'; + hb_retclen( s3, l1 + l2 ); + hb_xfree( s3 ); /* free alloc'ed mem */ + } + else + { + hb_retc_null(); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/charodd.c b/harbour/contrib/hbgt/charodd.c index 0067e084d4..3d6c21e370 100644 --- a/harbour/contrib/hbgt/charodd.c +++ b/harbour/contrib/hbgt/charodd.c @@ -21,22 +21,25 @@ HB_FUNC( GT_CHARODD ) { - const char *s1; - char *s2; - HB_ISIZ len, i; + const char * s1; + char * s2; + HB_ISIZ len, i; - if (HB_ISCHAR(1)) { - s1 = hb_parc(1); - len = hb_parclen(1); + if( HB_ISCHAR( 1 ) ) + { + s1 = hb_parc( 1 ); + len = hb_parclen( 1 ); - s2 = (char *)hb_xgrab(len / 2); /* grab us some mem to work with */ + s2 = ( char * ) hb_xgrab( len / 2 ); /* grab us some mem to work with */ - for (i = 0; i <= len; i += 2) - s2[i/2] = s1[i] & 0x7f; + for( i = 0; i <= len; i += 2 ) + s2[ i / 2 ] = s1[ i ] & 0x7f; - hb_retclen(s2, len); - hb_xfree(s2); /* free alloc'ed mem */ - } else { - hb_retc_null(); /* parameter mismatch - error NullStr */ - } + hb_retclen( s2, len ); + hb_xfree( s2 ); /* free alloc'ed mem */ + } + else + { + hb_retc_null(); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/chrcount.c b/harbour/contrib/hbgt/chrcount.c index 5f1f4ac8f1..f624d2546a 100644 --- a/harbour/contrib/hbgt/chrcount.c +++ b/harbour/contrib/hbgt/chrcount.c @@ -21,22 +21,26 @@ HB_FUNC( GT_CHRCOUNT ) { - const char *s1, *s2; - HB_ISIZ count, pos2, len; + const char * s1, * s2; + HB_ISIZ count, pos2, len; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - s1 = hb_parc(1); - s2 = hb_parc(2); - len = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + s1 = hb_parc( 1 ); + s2 = hb_parc( 2 ); + len = hb_parclen( 2 ); - /* loop through s2 matching passed character (s1) with - each character of s1 */ - for (count = 0, pos2 = 1; pos2 <= len; s2++, pos2++) - if (*s1 == *s2) /* character matches s1 */ - count++; /* increment counter */ + /* loop through s2 matching passed character (s1) with + each character of s1 */ + for( count = 0, pos2 = 1; pos2 <= len; s2++, pos2++ ) + if( *s1 == *s2 ) /* character matches s1 */ + count++; + /* increment counter */ - hb_retns(count); /* return result */ - } else { - hb_retns(-1); /* parameter mismatch - error -1 */ - } + hb_retns( count ); /* return result */ + } + else + { + hb_retns( -1 ); /* parameter mismatch - error -1 */ + } } diff --git a/harbour/contrib/hbgt/chrfirst.c b/harbour/contrib/hbgt/chrfirst.c index e7a505b7c8..18834fa4df 100644 --- a/harbour/contrib/hbgt/chrfirst.c +++ b/harbour/contrib/hbgt/chrfirst.c @@ -21,31 +21,37 @@ HB_FUNC( GT_CHRFIRST ) { - const char *string; - const char *cset; - HB_ISIZ l1, l2; - HB_ISIZ p1, p2; + const char * string; + const char * cset; + HB_ISIZ l1, l2; + HB_ISIZ p1, p2; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - string = hb_parc(2); - cset = hb_parc(1); - l1 = hb_parclen(2); - l2 = hb_parclen(1); - p1 = p2 = 0; + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + string = hb_parc( 2 ); + cset = hb_parc( 1 ); + l1 = hb_parclen( 2 ); + l2 = hb_parclen( 1 ); + p1 = p2 = 0; - do { - for (p2 = 0; (p2 < l2) && (cset[p2] != string[p1]); ++p2) - ; - if (p2 < l2) { - hb_retni(string[p1]); - break; + do + { + for( p2 = 0; ( p2 < l2 ) && ( cset[ p2 ] != string[ p1 ] ); ++p2 ) + ; + if( p2 < l2 ) + { + hb_retni( string[ p1 ] ); + break; + } } - } while (p1++ < l1); + while( p1++ < l1 ); - if (p2 >= l2) - hb_retni(0); + if( p2 >= l2 ) + hb_retni( 0 ); - } else { - hb_retni(-1); /* parameter mismatch - error NullStr */ - } + } + else + { + hb_retni( -1 ); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/chrtotal.c b/harbour/contrib/hbgt/chrtotal.c index 0d7a3d4504..c24a52f5dc 100644 --- a/harbour/contrib/hbgt/chrtotal.c +++ b/harbour/contrib/hbgt/chrtotal.c @@ -21,22 +21,26 @@ HB_FUNC( GT_CHRTOTAL ) { - const char *s1, *s2; - HB_ISIZ count, p1, p2, l2, l1; + const char * s1, * s2; + HB_ISIZ count, p1, p2, l2, l1; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - s1 = hb_parc(1); - s2 = hb_parc(2); - l2 = hb_parclen(2); - l1 = hb_parclen(1); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + s1 = hb_parc( 1 ); + s2 = hb_parc( 2 ); + l2 = hb_parclen( 2 ); + l1 = hb_parclen( 1 ); - for (count = 0, p2 = 0; p2 < l2; p2++) - for (p1 = 0; p1 < l1; p1++) - if (s1[p1] == s2[p2]) - count++; /* increment counter */ + for( count = 0, p2 = 0; p2 < l2; p2++ ) + for( p1 = 0; p1 < l1; p1++ ) + if( s1[ p1 ] == s2[ p2 ] ) + count++; + /* increment counter */ - hb_retns(count); /* return result */ - } else { - hb_retns(-1); /* parameter mismatch - error -1 */ - } + hb_retns( count ); /* return result */ + } + else + { + hb_retns( -1 ); /* parameter mismatch - error -1 */ + } } diff --git a/harbour/contrib/hbgt/strasint.c b/harbour/contrib/hbgt/strasint.c index c7aaa308ba..4c1cca1d78 100644 --- a/harbour/contrib/hbgt/strasint.c +++ b/harbour/contrib/hbgt/strasint.c @@ -11,21 +11,21 @@ #include "hbapi.h" -int _GT_Internal_StringAsInt(char *String, HB_ISIZ Start, HB_ISIZ End) +int _GT_Internal_StringAsInt( char * String, HB_ISIZ Start, HB_ISIZ End ) { int Decimal = 1; - int Value = 0; - HB_ISIZ Digit; + int Value = 0; + HB_ISIZ Digit; - HB_TRACE(HB_TR_DEBUG, ("_GT_Internal_StringAsInt(%s, %" HB_PFS "d, %" HB_PFS "d)", String, Start, End)); + HB_TRACE( HB_TR_DEBUG, ( "_GT_Internal_StringAsInt(%s, %" HB_PFS "d, %" HB_PFS "d)", String, Start, End ) ); - for (Digit = End; Digit >= Start; Digit--) - { - if (HB_ISDIGIT(String[Digit])) - { - Value += (String[Digit] - 0x30) * Decimal; - Decimal *= 0xA; - } - } + for( Digit = End; Digit >= Start; Digit-- ) + { + if( HB_ISDIGIT( String[ Digit ] ) ) + { + Value += ( String[ Digit ] - 0x30 ) * Decimal; + Decimal *= 0xA; + } + } return Value; } diff --git a/harbour/contrib/hbgt/strcount.c b/harbour/contrib/hbgt/strcount.c index c0565036e3..a1992eceaa 100644 --- a/harbour/contrib/hbgt/strcount.c +++ b/harbour/contrib/hbgt/strcount.c @@ -21,35 +21,38 @@ HB_FUNC( GT_STRCOUNT ) { - const char *s1, *s2; - HB_ISIZ count, p1, p2, l1, l2; - int match; + const char * s1, * s2; + HB_ISIZ count, p1, p2, l1, l2; + int match; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - s1 = hb_parc(1); - s2 = hb_parc(2); - l1 = hb_parclen(1); - l2 = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + s1 = hb_parc( 1 ); + s2 = hb_parc( 2 ); + l1 = hb_parclen( 1 ); + l2 = hb_parclen( 2 ); - /* loop through s2 matching passed character (s1) with - each character of s1 */ + /* loop through s2 matching passed character (s1) with + each character of s1 */ - for (count = 0, p2 = 0; p2 <= (l2 - l1); p2++) - { - match = 1; - - for (p1 = 0; p1 < l1; p1++) + for( count = 0, p2 = 0; p2 <= ( l2 - l1 ); p2++ ) { - if (s1[p1] != s2[p2 + p1]) - match = 0; + match = 1; + + for( p1 = 0; p1 < l1; p1++ ) + { + if( s1[ p1 ] != s2[ p2 + p1 ] ) + match = 0; + } + + if( match ) + count++; } - if (match) - count++; - } - - hb_retns(count); /* return result */ - } else { - hb_retns(-1); /* parameter mismatch - error -1 */ - } + hb_retns( count ); /* return result */ + } + else + { + hb_retns( -1 ); /* parameter mismatch - error -1 */ + } } diff --git a/harbour/contrib/hbgt/strcspn.c b/harbour/contrib/hbgt/strcspn.c index ef90e6e3e1..71a0ae1d79 100644 --- a/harbour/contrib/hbgt/strcspn.c +++ b/harbour/contrib/hbgt/strcspn.c @@ -21,26 +21,30 @@ HB_FUNC( GT_STRCSPN ) { - const char *string; - const char *cset; - HB_ISIZ l1, l2; - HB_ISIZ p1, p2; + const char * string; + const char * cset; + HB_ISIZ l1, l2; + HB_ISIZ p1, p2; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - string = hb_parc(1); - cset = hb_parc(2); - l1 = hb_parclen(1); - l2 = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + string = hb_parc( 1 ); + cset = hb_parc( 2 ); + l1 = hb_parclen( 1 ); + l2 = hb_parclen( 2 ); - for (p1 = 0; p1 < l1; ++p1) { - for (p2 = 0; (p2 < l2) && (string[p1] != cset[p2]); ++p2) - ; + for( p1 = 0; p1 < l1; ++p1 ) + { + for( p2 = 0; ( p2 < l2 ) && ( string[ p1 ] != cset[ p2 ] ); ++p2 ) + ; - if (p2 < l2) - break; - } - hb_retns(p1); - } else { - hb_retns(-1); /* parameter mismatch - error -1 */ - } + if( p2 < l2 ) + break; + } + hb_retns( p1 ); + } + else + { + hb_retns( -1 ); /* parameter mismatch - error -1 */ + } } diff --git a/harbour/contrib/hbgt/strdiffg.c b/harbour/contrib/hbgt/strdiffg.c index 2389339873..4c3b5ad670 100644 --- a/harbour/contrib/hbgt/strdiffg.c +++ b/harbour/contrib/hbgt/strdiffg.c @@ -21,29 +21,32 @@ HB_FUNC( GT_STRDIFF ) { - const char *s1, *s2; - HB_ISIZ pos, len; + const char * s1, * s2; + HB_ISIZ pos, len; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - s1 = hb_parc(1); - s2 = hb_parc(2); - len = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + s1 = hb_parc( 1 ); + s2 = hb_parc( 2 ); + len = hb_parclen( 2 ); - /* - loop through comparing both strings + /* + loop through comparing both strings - NOTE: pos starts at 1, so as to return a string index - for CLIPPER - */ + NOTE: pos starts at 1, so as to return a string index + for CLIPPER + */ - for (pos = 1; (pos <= len) && (*s1 == *s2); s2++, s1++) - pos++; + for( pos = 1; ( pos <= len ) && ( *s1 == *s2 ); s2++, s1++ ) + pos++; - if (pos > len) /* strings match exactly!!! */ - hb_retc_null(); - else - hb_retc(s2); - } else { - hb_ret(); /* parameter mismatch - error return NIL */ - } + if( pos > len ) /* strings match exactly!!! */ + hb_retc_null(); + else + hb_retc( s2 ); + } + else + { + hb_ret(); /* parameter mismatch - error return NIL */ + } } diff --git a/harbour/contrib/hbgt/strexpan.c b/harbour/contrib/hbgt/strexpan.c index 11b3191df4..932a441220 100644 --- a/harbour/contrib/hbgt/strexpan.c +++ b/harbour/contrib/hbgt/strexpan.c @@ -21,40 +21,44 @@ HB_FUNC( GT_STREXPAND ) { - const char *in; - char *out; - int nIns = 1; - const char *insert = " "; - HB_ISIZ len; - HB_ISIZ i, p; - int j; + const char * in; + char * out; + int nIns = 1; + const char * insert = " "; + HB_ISIZ len; + HB_ISIZ i, p; + int j; - if (HB_ISCHAR(1) && (HB_ISNUM(2) || hb_pcount() < 2) && (HB_ISCHAR(3) || hb_pcount() < 3)) { - in = hb_parc(1); - len = hb_parclen(1); + if( HB_ISCHAR( 1 ) && ( HB_ISNUM( 2 ) || hb_pcount() < 2 ) && ( HB_ISCHAR( 3 ) || hb_pcount() < 3 ) ) + { + in = hb_parc( 1 ); + len = hb_parclen( 1 ); - if (HB_ISNUM(2)) - nIns = hb_parni(2); + if( HB_ISNUM( 2 ) ) + nIns = hb_parni( 2 ); - if (HB_ISCHAR(3)) - insert = hb_parc(3); + if( HB_ISCHAR( 3 ) ) + insert = hb_parc( 3 ); - out = (char *)hb_xgrab(len * (nIns + 1)); /* alloc us some memory */ + out = ( char * ) hb_xgrab( len * ( nIns + 1 ) ); /* alloc us some memory */ - for (i = 0, p = 0; i < len; i++) { /* loop thru input */ - out[p++] = in[i]; /* insert a character from input */ + for( i = 0, p = 0; i < len; i++ ) /* loop thru input */ + { + out[ p++ ] = in[ i ]; /* insert a character from input */ - if (i < (len - 1)) { /* do not insert fill chars on last */ - /* char of input */ - for (j = 1; j <= nIns; j++) /* insert the fill characters */ - out[p++] = insert[0]; + if( i < ( len - 1 ) ) /* do not insert fill chars on last */ + { /* char of input */ + for( j = 1; j <= nIns; j++ ) /* insert the fill characters */ + out[ p++ ] = insert[ 0 ]; + } } - } - out[p] = '\0'; /* Add terminating NUL */ + out[ p ] = '\0'; /* Add terminating NUL */ - hb_retc(out); - hb_xfree(out); /* free alloc'ed mem */ - } else { - hb_retc_null(); /* parameter mismatch - error NullStr */ - } + hb_retc( out ); + hb_xfree( out ); /* free alloc'ed mem */ + } + else + { + hb_retc_null(); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/strleft.c b/harbour/contrib/hbgt/strleft.c index ae164aada6..bce96cf8c3 100644 --- a/harbour/contrib/hbgt/strleft.c +++ b/harbour/contrib/hbgt/strleft.c @@ -21,27 +21,31 @@ HB_FUNC( GT_STRLEFT ) { - const char *string; - const char *cset; - HB_ISIZ l1, l2; - HB_ISIZ p1, p2; + const char * string; + const char * cset; + HB_ISIZ l1, l2; + HB_ISIZ p1, p2; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - string = hb_parc(1); - cset = hb_parc(2); - l1 = hb_parclen(1); - l2 = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + string = hb_parc( 1 ); + cset = hb_parc( 2 ); + l1 = hb_parclen( 1 ); + l2 = hb_parclen( 2 ); - for (p1 = 0; p1 < l1; p1++) { - for (p2 = 0; p2 < l2 && cset[p2] != string[p1]; p2++) - ; + for( p1 = 0; p1 < l1; p1++ ) + { + for( p2 = 0; p2 < l2 && cset[ p2 ] != string[ p1 ]; p2++ ) + ; - if (p2 == l2) - break; - } - hb_retns(p1); + if( p2 == l2 ) + break; + } + hb_retns( p1 ); - } else { - hb_retns(-1); /* parameter mismatch - error NullStr */ - } + } + else + { + hb_retns( -1 ); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/strpbrk.c b/harbour/contrib/hbgt/strpbrk.c index 9d29d83bdb..da25482906 100644 --- a/harbour/contrib/hbgt/strpbrk.c +++ b/harbour/contrib/hbgt/strpbrk.c @@ -21,31 +21,37 @@ HB_FUNC( GT_STRPBRK ) { - const char *string; - const char *cset; - HB_ISIZ l1, l2; - HB_ISIZ p1, p2; + const char * string; + const char * cset; + HB_ISIZ l1, l2; + HB_ISIZ p1, p2; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - string = hb_parc(1); - cset = hb_parc(2); - l1 = hb_parclen(1); - l2 = hb_parclen(2); - p1 = p2 = 0; + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + string = hb_parc( 1 ); + cset = hb_parc( 2 ); + l1 = hb_parclen( 1 ); + l2 = hb_parclen( 2 ); + p1 = p2 = 0; - do { - for (p2 = 0; (p2 < l2) && (cset[p2] != string[p1]); ++p2) - ; - if (p2 < l2) { - hb_retc(string + p1); - break; + do + { + for( p2 = 0; ( p2 < l2 ) && ( cset[ p2 ] != string[ p1 ] ); ++p2 ) + ; + if( p2 < l2 ) + { + hb_retc( string + p1 ); + break; + } } - } while (p1++ < l1); + while( p1++ < l1 ); - if (p2 >= l2) - hb_retc_null(); + if( p2 >= l2 ) + hb_retc_null(); - } else { - hb_retc_null(); /* parameter mismatch - error NullStr */ - } + } + else + { + hb_retc_null(); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/strright.c b/harbour/contrib/hbgt/strright.c index f48d77976b..6b88651c09 100644 --- a/harbour/contrib/hbgt/strright.c +++ b/harbour/contrib/hbgt/strright.c @@ -21,27 +21,31 @@ HB_FUNC( GT_STRRIGHT ) { - const char *string; - const char *cset; - HB_ISIZ l1, l2; - HB_ISIZ p1, p2; + const char * string; + const char * cset; + HB_ISIZ l1, l2; + HB_ISIZ p1, p2; - if (HB_ISCHAR(1) && HB_ISCHAR(2)) { - string = hb_parc(1); - cset = hb_parc(2); - l1 = hb_parclen(1); - l2 = hb_parclen(2); + if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + { + string = hb_parc( 1 ); + cset = hb_parc( 2 ); + l1 = hb_parclen( 1 ); + l2 = hb_parclen( 2 ); - for (p1 = l1 - 1; p1 >= 0; p1--) { - for (p2 = 0; p2 < l2 && cset[p2] != string[p1]; p2++) - ; + for( p1 = l1 - 1; p1 >= 0; p1-- ) + { + for( p2 = 0; p2 < l2 && cset[ p2 ] != string[ p1 ]; p2++ ) + ; - if (p2 == l2) - break; - } - hb_retns(l1 - p1 - 1); + if( p2 == l2 ) + break; + } + hb_retns( l1 - p1 - 1 ); - } else { - hb_retns(-1); /* parameter mismatch - error NullStr */ - } + } + else + { + hb_retns( -1 ); /* parameter mismatch - error NullStr */ + } } diff --git a/harbour/contrib/hbgt/tests/test.prg b/harbour/contrib/hbgt/tests/test.prg index 7f6db7e083..9b21b7f624 100644 --- a/harbour/contrib/hbgt/tests/test.prg +++ b/harbour/contrib/hbgt/tests/test.prg @@ -2,24 +2,26 @@ * $Id$ */ +#require "hbgt" + PROCEDURE Main() - QOut( 'gt_ascpos("Harbour",1) => ' + LTrim( Str(gt_ascpos("Harbour",1 ) ) ) ) - QOut( 'gt_atdiff("This Is Harbour","This Is Clipper") => ' + LTrim( Str(gt_atdiff("This Is Harbour","This Is Clipper" ) ) ) ) - QOut( 'gt_chareven("The_Power_Of_Harbour") => ' + gt_chareven( "The_Power_Of_Harbour" ) ) - QOut( 'gt_charodd("The_Power_Of_Harbour") => ' + gt_charodd( "The_Power_Of_Harbour" ) ) - QOut( 'gt_chrcount("s","she sells shells by the sea shore") => ' + LTrim( Str(gt_chrcount("s","she sells shells by the sea shore" ) ) ) ) - QOut( 'gt_chrtotal("sl","she sells shells by the sea shore") => ' + LTrim( Str(gt_chrtotal("sl","she sells shells by the sea shore" ) ) ) ) - QOut( 'gt_charmix("CLIPPER","harbour") => ' + gt_charmix( "CLIPPER","harbour" ) ) - QOut( 'gt_asciisum("harbour") => ' + LTrim( Str(gt_asciisum("harbour" ) ) ) ) - QOut( 'gt_chrfirst("Ho", "the power of Harbour") => ' + LTrim( Str(gt_chrfirst("Ho", "the power of Harbour" ) ) ) ) - QOut( 'gt_strcount("the", "the cat sat on the mat") => ' + LTrim( Str(gt_strcount("the", "the cat sat on the mat" ) ) ) ) - QOut( 'gt_strcspn("this is a test", "as ") => ' + LTrim( Str(gt_strcspn("this is a test", "as " ) ) ) ) - QOut( 'gt_strcspn("this is a test", "elnjpq") => ' + LTrim( Str(gt_strcspn("this is a test", "elnjpq" ) ) ) ) - QOut( 'gt_strDiff("the cat", "the rat") => ' + gt_strDiff( "the cat", "the rat" ) ) - QOut( 'gt_strexpand("HARBOUR", 2,"-") => ' + gt_strexpand( "HARBOUR", 2,"-" ) ) - QOut( 'gt_strleft("this is a test", "hsit ") => ' + LTrim( Str(gt_strleft("this is a test", "hsit " ) ) ) ) - QOut( 'gt_strpbrk("this is a test", "sa ") => ' + gt_strpbrk( "this is a test", "sa " ) ) - QOut( 'gt_strright("this is a test", "teas ") => ' + LTrim( Str(gt_strright("this is a test", "teas " ) ) ) ) + QOut( 'gt_ascpos( "Harbour", 1 ) => ' + hb_ntos( gt_ascpos( "Harbour", 1 ) ) ) + QOut( 'gt_atdiff( "This Is Harbour", "This Is Clipper" ) => ' + hb_ntos( gt_atdiff( "This Is Harbour", "This Is Clipper" ) ) ) + QOut( 'gt_chareven( "The_Power_Of_Harbour" ) => ' + gt_chareven( "The_Power_Of_Harbour" ) ) + QOut( 'gt_charodd( "The_Power_Of_Harbour" ) => ' + gt_charodd( "The_Power_Of_Harbour" ) ) + QOut( 'gt_chrcount( "s", "she sells shells by the sea shore" ) => ' + hb_ntos( gt_chrcount( "s", "she sells shells by the sea shore" ) ) ) + QOut( 'gt_chrtotal( "sl", "she sells shells by the sea shore" ) => ' + hb_ntos( gt_chrtotal( "sl", "she sells shells by the sea shore" ) ) ) + QOut( 'gt_charmix( "CLIPPER", "harbour" ) => ' + gt_charmix( "CLIPPER", "harbour" ) ) + QOut( 'gt_asciisum( "harbour" ) => ' + hb_ntos( gt_asciisum( "harbour" ) ) ) + QOut( 'gt_chrfirst( "Ho", "the power of Harbour" ) => ' + hb_ntos( gt_chrfirst( "Ho", "the power of Harbour" ) ) ) + QOut( 'gt_strcount( "the", "the cat sat on the mat" ) => ' + hb_ntos( gt_strcount( "the", "the cat sat on the mat" ) ) ) + QOut( 'gt_strcspn( "this is a test", "as " ) => ' + hb_ntos( gt_strcspn( "this is a test", "as " ) ) ) + QOut( 'gt_strcspn( "this is a test", "elnjpq" ) => ' + hb_ntos( gt_strcspn( "this is a test", "elnjpq" ) ) ) + QOut( 'gt_strDiff( "the cat", "the rat" ) => ' + gt_strDiff( "the cat", "the rat" ) ) + QOut( 'gt_strexpand( "HARBOUR", 2, "-" ) => ' + gt_strexpand( "HARBOUR", 2, "-" ) ) + QOut( 'gt_strleft( "this is a test", "hsit " ) => ' + hb_ntos( gt_strleft( "this is a test", "hsit " ) ) ) + QOut( 'gt_strpbrk( "this is a test", "sa " ) => ' + gt_strpbrk( "this is a test", "sa " ) ) + QOut( 'gt_strright( "this is a test", "teas " ) => ' + hb_ntos( gt_strright( "this is a test", "teas " ) ) ) RETURN