From 4b2790b65eb6dbcd14b923e77bcd49d3714ebc0e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 24 Nov 2012 14:28:34 +0000 Subject: [PATCH] 2012-11-24 15:20 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbct/addascii.c * contrib/hbct/asciisum.c * contrib/hbct/ascpos.c * contrib/hbct/atadjust.c * contrib/hbct/atnum.c * contrib/hbct/atrepl.c * contrib/hbct/charevod.c * contrib/hbct/charmirr.c * contrib/hbct/charmix.c * contrib/hbct/charone.c * contrib/hbct/charonly.c * contrib/hbct/charop.c * contrib/hbct/charrepl.c * contrib/hbct/charsort.c * contrib/hbct/charsprd.c * contrib/hbct/charswap.c * contrib/hbct/count.c * contrib/hbct/ctc.c * contrib/hbct/ctmath.h * contrib/hbct/ctmath2.c * contrib/hbct/ctpad.c * contrib/hbct/ctstr.c * contrib/hbct/datetime.c * contrib/hbct/dattime2.c * contrib/hbct/exponent.c * contrib/hbct/files.c * contrib/hbct/finan.c * contrib/hbct/justify.c * contrib/hbct/num1.c * contrib/hbct/numat.c * contrib/hbct/numcount.c * contrib/hbct/pos1.c * contrib/hbct/pos2.c * contrib/hbct/posdiff.c * contrib/hbct/range.c * contrib/hbct/relation.c * contrib/hbct/remove.c * contrib/hbct/replace.c * contrib/hbct/strdiff.c * contrib/hbct/strswap.c * contrib/hbct/tab.c * contrib/hbct/token1.c * contrib/hbct/token2.c * contrib/hbct/trig.c * contrib/hbct/wordrepl.c * contrib/hbct/wordtoch.c * various cleanups (using hb_par*def(), drop isbyref checks before hb_stor*(), excessive {}, empty lines after {, empty lines before }, code in comment, references to borland, funcnames without (), added few {}s, minor cleanup/opt in sorting callbacks) * utils/hbmk2/hbmk2.prg * avoid commented code --- harbour/ChangeLog | 57 ++++++++++++++++++++++++ harbour/contrib/hbct/addascii.c | 23 +++------- harbour/contrib/hbct/asciisum.c | 2 - harbour/contrib/hbct/ascpos.c | 19 +------- harbour/contrib/hbct/atadjust.c | 17 +++----- harbour/contrib/hbct/atnum.c | 26 +++-------- harbour/contrib/hbct/atrepl.c | 9 ++-- harbour/contrib/hbct/charevod.c | 5 +-- harbour/contrib/hbct/charmirr.c | 17 ++------ harbour/contrib/hbct/charmix.c | 8 +--- harbour/contrib/hbct/charone.c | 9 ++-- harbour/contrib/hbct/charonly.c | 5 +-- harbour/contrib/hbct/charop.c | 26 +++++------ harbour/contrib/hbct/charrepl.c | 31 ++----------- harbour/contrib/hbct/charsort.c | 77 +++++++++------------------------ harbour/contrib/hbct/charsprd.c | 3 +- harbour/contrib/hbct/charswap.c | 21 +-------- harbour/contrib/hbct/count.c | 4 +- harbour/contrib/hbct/ctc.c | 4 -- harbour/contrib/hbct/ctmath.h | 9 ++-- harbour/contrib/hbct/ctmath2.c | 29 +++++-------- harbour/contrib/hbct/ctpad.c | 9 +--- harbour/contrib/hbct/ctstr.c | 25 ++--------- harbour/contrib/hbct/datetime.c | 29 ------------- harbour/contrib/hbct/dattime2.c | 2 - harbour/contrib/hbct/exponent.c | 4 -- harbour/contrib/hbct/files.c | 18 +++----- harbour/contrib/hbct/finan.c | 53 ++++++++--------------- harbour/contrib/hbct/justify.c | 17 +++----- harbour/contrib/hbct/num1.c | 14 ++---- harbour/contrib/hbct/numat.c | 12 ++--- harbour/contrib/hbct/numcount.c | 4 +- harbour/contrib/hbct/pos1.c | 18 ++------ harbour/contrib/hbct/pos2.c | 55 +++++------------------ harbour/contrib/hbct/posdiff.c | 34 ++++----------- harbour/contrib/hbct/range.c | 14 ++---- harbour/contrib/hbct/relation.c | 20 ++------- harbour/contrib/hbct/remove.c | 7 ++- harbour/contrib/hbct/replace.c | 11 ++--- harbour/contrib/hbct/strdiff.c | 26 +++-------- harbour/contrib/hbct/strswap.c | 9 +--- harbour/contrib/hbct/tab.c | 22 +++------- harbour/contrib/hbct/token1.c | 24 +++++----- harbour/contrib/hbct/token2.c | 45 +++++++------------ harbour/contrib/hbct/trig.c | 74 +++++++++++++------------------ harbour/contrib/hbct/wordrepl.c | 21 ++------- harbour/contrib/hbct/wordtoch.c | 7 +-- harbour/utils/hbmk2/hbmk2.prg | 4 +- 48 files changed, 303 insertions(+), 676 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e992e21405..f511d89914 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -10,6 +10,63 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2012-11-24 15:20 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbct/addascii.c + * contrib/hbct/asciisum.c + * contrib/hbct/ascpos.c + * contrib/hbct/atadjust.c + * contrib/hbct/atnum.c + * contrib/hbct/atrepl.c + * contrib/hbct/charevod.c + * contrib/hbct/charmirr.c + * contrib/hbct/charmix.c + * contrib/hbct/charone.c + * contrib/hbct/charonly.c + * contrib/hbct/charop.c + * contrib/hbct/charrepl.c + * contrib/hbct/charsort.c + * contrib/hbct/charsprd.c + * contrib/hbct/charswap.c + * contrib/hbct/count.c + * contrib/hbct/ctc.c + * contrib/hbct/ctmath.h + * contrib/hbct/ctmath2.c + * contrib/hbct/ctpad.c + * contrib/hbct/ctstr.c + * contrib/hbct/datetime.c + * contrib/hbct/dattime2.c + * contrib/hbct/exponent.c + * contrib/hbct/files.c + * contrib/hbct/finan.c + * contrib/hbct/justify.c + * contrib/hbct/num1.c + * contrib/hbct/numat.c + * contrib/hbct/numcount.c + * contrib/hbct/pos1.c + * contrib/hbct/pos2.c + * contrib/hbct/posdiff.c + * contrib/hbct/range.c + * contrib/hbct/relation.c + * contrib/hbct/remove.c + * contrib/hbct/replace.c + * contrib/hbct/strdiff.c + * contrib/hbct/strswap.c + * contrib/hbct/tab.c + * contrib/hbct/token1.c + * contrib/hbct/token2.c + * contrib/hbct/trig.c + * contrib/hbct/wordrepl.c + * contrib/hbct/wordtoch.c + * various cleanups + (using hb_par*def(), drop isbyref checks before + hb_stor*(), excessive {}, empty lines after {, + empty lines before }, code in comment, references + to borland, funcnames without (), added few {}s, + minor cleanup/opt in sorting callbacks) + + * utils/hbmk2/hbmk2.prg + * avoid commented code + 2012-11-23 20:42 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbct/screen2.c + SAYDOWN(): CP translation (UTF-8) support diff --git a/harbour/contrib/hbct/addascii.c b/harbour/contrib/hbct/addascii.c index a140636593..21693ba157 100644 --- a/harbour/contrib/hbct/addascii.c +++ b/harbour/contrib/hbct/addascii.c @@ -66,29 +66,24 @@ HB_FUNC( ADDASCII ) const char * pcSource = hb_parc( 1 ); HB_SIZE sLen = hb_parclen( 1 ); char * pcResult; - HB_SIZE sPos; + HB_SIZE sPos = hb_parnsdef( 3, sLen ); HB_LONG lValue; int iCarryOver; - if( HB_ISNUM( 3 ) ) - sPos = hb_parns( 3 ); - else - sPos = sLen; - if( sPos > sLen || ! HB_ISNUM( 2 ) || sLen == 0 ) { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ADDASCII, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + /* return string unchanged */ if( iNoRet ) hb_retl( HB_FALSE ); else hb_retclen( pcSource, sLen ); + return; } @@ -96,10 +91,7 @@ HB_FUNC( ADDASCII ) hb_xmemcpy( pcResult, pcSource, sLen ); lValue = hb_parnl( 2 ); - if( HB_ISLOG( 4 ) ) - iCarryOver = hb_parl( 4 ); - else - iCarryOver = 0; + iCarryOver = hb_parldef( 4, 0 ); if( iCarryOver ) { @@ -120,12 +112,9 @@ HB_FUNC( ADDASCII ) } } else - { pcResult[ sPos - 1 ] = ( char ) ( ( ( HB_LONG ) pcResult[ sPos - 1 ] + lValue ) % 256 ); - } - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcResult, sLen, 1 ); + hb_storclen( pcResult, sLen, 1 ); if( iNoRet ) { @@ -141,10 +130,8 @@ HB_FUNC( ADDASCII ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ADDASCII, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/asciisum.c b/harbour/contrib/hbct/asciisum.c index 77a167c769..e803d44ebc 100644 --- a/harbour/contrib/hbct/asciisum.c +++ b/harbour/contrib/hbct/asciisum.c @@ -74,11 +74,9 @@ HB_FUNC( ASCIISUM ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ASCIISUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/ascpos.c b/harbour/contrib/hbct/ascpos.c index 9bc05de198..3ee5836a00 100644 --- a/harbour/contrib/hbct/ascpos.c +++ b/harbour/contrib/hbct/ascpos.c @@ -67,17 +67,10 @@ static void do_ascpos( int iSwitch ) { HB_SIZE sStrSize = hb_parclen( 1 ); const HB_BYTE * pcString = ( const HB_BYTE * ) hb_parc( 1 ); - HB_SIZE sPos; - - if( HB_ISNUM( 2 ) ) - sPos = hb_parns( 2 ); - else - sPos = sStrSize; + HB_SIZE sPos = hb_parnsdef( 2, sStrSize ); if( sPos == 0 || sPos > sStrSize ) - { hb_retni( 0 ); - } else { if( iSwitch == DO_ASCPOS_VALPOS ) @@ -87,10 +80,8 @@ static void do_ascpos( int iSwitch ) else hb_retni( 0 ); } - else /* iSwitch == DO_ASCPOS_ASCPOS */ - { + else hb_retni( pcString[ sPos - 1 ] ); - } } } else @@ -99,22 +90,16 @@ static void do_ascpos( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_ASCPOS_VALPOS ? CT_ERROR_VALPOS : CT_ERROR_ASCPOS, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) - { hb_itemReturnRelease( pSubst ); - } else - { hb_retni( 0 ); - } } } diff --git a/harbour/contrib/hbct/atadjust.c b/harbour/contrib/hbct/atadjust.c index 6689e7ef67..1a85fde541 100644 --- a/harbour/contrib/hbct/atadjust.c +++ b/harbour/contrib/hbct/atadjust.c @@ -77,20 +77,16 @@ HB_FUNC( ATADJUST ) HB_SIZE sRetStrLen; /* eventually ignore some characters */ - if( HB_ISNUM( 5 ) ) - sIgnore = hb_parns( 5 ); - else - sIgnore = 0; + sIgnore = hb_parnsdef( 5, 0 ); if( sIgnore >= sStrLen ) { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATADJUST, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retclen( pcString, sStrLen ); return; } @@ -106,10 +102,9 @@ HB_FUNC( ATADJUST ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATADJUST, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retclen( pcString, sStrLen ); return; } @@ -161,7 +156,7 @@ HB_FUNC( ATADJUST ) sSubStrLen = sStrLen - ( pcSubStr - pcString ); } } - else /* ( HB_ISNUM( 4 ) && ( ( nCounter = hb_parns( 4 ) ) != 0 ) */ + else { /* we have to find the last match */ switch( iAtLike ) @@ -257,17 +252,15 @@ HB_FUNC( ATADJUST ) } } } - else /* ( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) && HB_ISNUM( 3 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATADJUST, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/atnum.c b/harbour/contrib/hbct/atnum.c index 36fce7b23c..bd6f63a996 100644 --- a/harbour/contrib/hbct/atnum.c +++ b/harbour/contrib/hbct/atnum.c @@ -74,16 +74,11 @@ static void do_atnum( int iSwitch ) int iMultiPass = ct_getatmupa(); int iAtLike = ct_getatlike(); char cAtLike = ct_getatlikechar(); - HB_SIZE sIgnore, sMatchStrLen = 0; + HB_SIZE sIgnore = hb_parnsdef( 4, 0 ); /* eventually ignore some characters */ + HB_SIZE sMatchStrLen = 0; HB_SIZE nCounter; const char * pc = NULL; - /* eventually ignore some characters */ - if( HB_ISNUM( 4 ) ) - sIgnore = hb_parns( 4 ); - else - sIgnore = 0; - if( sIgnore >= sStrLen ) { switch( iSwitch ) @@ -94,10 +89,9 @@ static void do_atnum( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_AFTERATNUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); break; } @@ -107,10 +101,9 @@ static void do_atnum( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_BEFORATNUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); break; } @@ -120,10 +113,9 @@ static void do_atnum( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATNUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retns( 0 ); break; } @@ -194,7 +186,7 @@ static void do_atnum( int iSwitch ) sSubStrLen = sStrLen - ( pcSubStr - pcString ); } } - else /* ( HB_ISNUM( 3 ) && ( nCounter = hb_parns( 3 ) ) != 0 ) */ + else { /* we have to find the last match and return the string after that last match */ @@ -261,7 +253,7 @@ static void do_atnum( int iSwitch ) break; } } - else /* ( HB_ISCHAR ( 1 ) && HB_ISCHAR( 2 ) ) */ + else { switch( iSwitch ) { @@ -273,13 +265,11 @@ static void do_atnum( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_ATNUM_AFTERATNUM ? CT_ERROR_AFTERATNUM : CT_ERROR_BEFORATNUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -294,11 +284,9 @@ static void do_atnum( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATNUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/atrepl.c b/harbour/contrib/hbct/atrepl.c index 7d20d92f83..4b85b2082b 100644 --- a/harbour/contrib/hbct/atrepl.c +++ b/harbour/contrib/hbct/atrepl.c @@ -83,10 +83,9 @@ HB_FUNC( ATREPL ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retclen( pcString, nStrLen ); return; } @@ -185,7 +184,7 @@ HB_FUNC( ATREPL ) sRetSubStrLen = nRetStrLen - ( pcRetSubStr - pcRetStr ); } } - else /* ( nCounter != 0 ) */ + else { /* find and replace last match */ nRetStrLen = nStrLen; @@ -239,17 +238,15 @@ HB_FUNC( ATREPL ) hb_retclen_buffer( pcRetStr, nRetStrLen ); } - else /* ( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/charevod.c b/harbour/contrib/hbct/charevod.c index 482a3606c3..0d68cd5d72 100644 --- a/harbour/contrib/hbct/charevod.c +++ b/harbour/contrib/hbct/charevod.c @@ -77,13 +77,12 @@ static void do_charevod( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_CHAREVOD_CHAREVEN ? CT_ERROR_CHAREVEN : CT_ERROR_CHARODD, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); return; } @@ -112,13 +111,11 @@ static void do_charevod( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_CHAREVOD_CHAREVEN ? CT_ERROR_CHAREVEN : CT_ERROR_CHARODD, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/charmirr.c b/harbour/contrib/hbct/charmirr.c index 638396a084..49bc064295 100644 --- a/harbour/contrib/hbct/charmirr.c +++ b/harbour/contrib/hbct/charmirr.c @@ -68,22 +68,16 @@ HB_FUNC( CHARMIRR ) const char * pcString = hb_parc( 1 ), * pc1; HB_SIZE sStrLen = hb_parclen( 1 ); char * pcRet, * pc2; - int iDontMirrorSpaces; - - if( HB_ISLOG( 2 ) ) - iDontMirrorSpaces = hb_parl( 2 ); - else - iDontMirrorSpaces = 0; + int iDontMirrorSpaces = hb_parldef( 2, 0 ); if( sStrLen == 0 ) { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIRR, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + if( iNoRet ) hb_retl( HB_FALSE ); else @@ -113,8 +107,7 @@ HB_FUNC( CHARMIRR ) } /* return string */ - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sStrLen, 1 ); + hb_storclen( pcRet, sStrLen, 1 ); if( iNoRet ) { @@ -124,17 +117,15 @@ HB_FUNC( CHARMIRR ) else hb_retclen_buffer( pcRet, sStrLen ); } - else /* if( HB_ISCHAR( 1 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIRR, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/charmix.c b/harbour/contrib/hbct/charmix.c index f0019055e2..68bc0c1009 100644 --- a/harbour/contrib/hbct/charmix.c +++ b/harbour/contrib/hbct/charmix.c @@ -71,10 +71,9 @@ HB_FUNC( CHARMIX ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIX, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); return; } @@ -88,11 +87,10 @@ HB_FUNC( CHARMIX ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIX, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retclen( pcString1, sLen1 ); return; } @@ -121,11 +119,9 @@ HB_FUNC( CHARMIX ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIX, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/charone.c b/harbour/contrib/hbct/charone.c index ee39f07296..233a30d021 100644 --- a/harbour/contrib/hbct/charone.c +++ b/harbour/contrib/hbct/charone.c @@ -116,7 +116,7 @@ static void do_charone( int iSwitch ) hb_retclen( pcRet, sRetStrLen ); hb_xfree( pcRet ); } - else /* if( sStrLen > 1 ) */ + else { /* algorithm does nothing to 1-char-strings */ hb_retclen( pcString, sStrLen ); @@ -170,13 +170,12 @@ static void do_charone( int iSwitch ) /* copy last character if string len is odd */ if( sStrLen & 1 ) - { pcRet[ sRetStrLen++ ] = pcString[ sStrLen - 1 ]; - } + hb_retclen( pcRet, sRetStrLen ); hb_xfree( pcRet ); } - else /* if( sStrLen > 3 ) */ + else { /* algorithm does nothing to 3-char-strings */ hb_retclen( pcString, sStrLen ); @@ -184,7 +183,7 @@ static void do_charone( int iSwitch ) break; } } - else /* if( HB_ISCHAR( 1 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); diff --git a/harbour/contrib/hbct/charonly.c b/harbour/contrib/hbct/charonly.c index 4853c31265..9ab692ba06 100644 --- a/harbour/contrib/hbct/charonly.c +++ b/harbour/contrib/hbct/charonly.c @@ -130,13 +130,12 @@ static void do_charonly( int iSwitch ) /* copy last character if string len is odd */ if( iShift == 2 && sStrLen % 2 == 1 ) - { pcRet[ sRetStrLen++ ] = pcString[ sStrLen - 1 ]; - } + hb_retclen( pcRet, sRetStrLen ); hb_xfree( pcRet ); } - else /* if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(), iError = 0; diff --git a/harbour/contrib/hbct/charop.c b/harbour/contrib/hbct/charop.c index 8aead9df16..91dec3471c 100644 --- a/harbour/contrib/hbct/charop.c +++ b/harbour/contrib/hbct/charop.c @@ -125,21 +125,23 @@ void ct_charop( int iMode ) hb_xmemcpy( pucResult, pucString, sStrLen ); if( iRLL != 0 ) + { for( sPos = 0; sPos < sStrLen; ++sPos ) { int iRLLCnt; for( iRLLCnt = 0; iRLLCnt < iRLL; iRLLCnt++ ) + { if( pucResult[ sPos ] & 0x80 ) /* most left bit set -> roll over */ { pucResult[ sPos ] <<= 1; pucResult[ sPos ] |= 0x01; } else - { pucResult[ sPos ] <<= 1; - } + } } + } break; } @@ -187,11 +189,10 @@ void ct_charop( int iMode ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARADD, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_xmemcpy( pucResult, pucString, sStrLen ); } break; @@ -212,11 +213,10 @@ void ct_charop( int iMode ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARSUB, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_xmemcpy( pucResult, pucString, sStrLen ); } break; @@ -237,10 +237,9 @@ void ct_charop( int iMode ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARAND, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_xmemcpy( pucResult, pucString, sStrLen ); } break; @@ -261,10 +260,9 @@ void ct_charop( int iMode ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHAROR, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_xmemcpy( pucResult, pucString, sStrLen ); } break; @@ -285,24 +283,22 @@ void ct_charop( int iMode ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARXOR, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_xmemcpy( pucResult, pucString, sStrLen ); } break; } - if( HB_ISBYREF( 1 ) ) - hb_storclen( ( char * ) pucResult, sStrLen, 1 ); + hb_storclen( ( char * ) pucResult, sStrLen, 1 ); if( iNoRet ) hb_xfree( pucResult ); else hb_retclen_buffer( ( char * ) pucResult, sStrLen ); } - else /* if( HB_ISCHAR( 1 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); diff --git a/harbour/contrib/hbct/charrepl.c b/harbour/contrib/hbct/charrepl.c index ba16ef8807..2582073c8d 100644 --- a/harbour/contrib/hbct/charrepl.c +++ b/harbour/contrib/hbct/charrepl.c @@ -71,7 +71,7 @@ HB_FUNC( CHARREPL ) const char * pcString = hb_parc( 2 ); HB_SIZE sStrLen = hb_parclen( 2 ); const char * pcReplace = hb_parc( 3 ); - int iMode; + int iMode = hb_parldef( 4, 0 ); char * pcRet; HB_SIZE sIndex; @@ -79,25 +79,12 @@ HB_FUNC( CHARREPL ) if( sStrLen == 0 ) { if( iNoRet ) - { hb_retl( HB_FALSE ); - } else - { hb_retc_null(); - } return; } - if( HB_ISLOG( 4 ) ) - { - iMode = hb_parl( 4 ); - } - else - { - iMode = 0; - } - pcRet = ( char * ) hb_xgrab( sStrLen + 1 ); hb_xmemcpy( pcRet, pcString, sStrLen ); @@ -108,14 +95,12 @@ HB_FUNC( CHARREPL ) HB_SIZE sReplIndex = sIndex; if( sReplIndex > sReplaceLen - 1 ) - { sReplIndex = sReplaceLen - 1; - } if( iMode ) { /* no multiple replacements: searching in pcString, - replacing in pcRet */ + replacing in pcRet */ pc = pcString; while( ( pc = ct_at_exact_forward( pc, sStrLen - ( pc - pcString ), @@ -140,10 +125,7 @@ HB_FUNC( CHARREPL ) } /* return string */ - if( HB_ISBYREF( 2 ) ) - { - hb_storclen( pcRet, sStrLen, 2 ); - } + hb_storclen( pcRet, sStrLen, 2 ); if( iNoRet ) { @@ -151,22 +133,17 @@ HB_FUNC( CHARREPL ) hb_xfree( pcRet ); } else - { hb_retclen_buffer( pcRet, sStrLen ); - } } - else /* ( ( sSearchLen = hb_parclen( 1 ) ) > 0 && HB_ISCHAR( 2 ) && - ( sReplaceLen = hb_parclen( 3 ) ) > 0 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/charsort.c b/harbour/contrib/hbct/charsort.c index f7f4e5ba80..b0cc03cf11 100644 --- a/harbour/contrib/hbct/charsort.c +++ b/harbour/contrib/hbct/charsort.c @@ -66,13 +66,9 @@ static int #endif _hb_do_sortascend( const void * p1, const void * p2 ) { - const char * pc1 = ( const char * ) p1; - const char * pc2 = ( const char * ) p2; - - pc1 += s_sElementPos; - pc2 += s_sElementPos; - - return strncmp( pc1, pc2, s_sCompareLen ); + return strncmp( ( const char * ) p1 + s_sElementPos, + ( const char * ) p2 + s_sElementPos, + s_sCompareLen ); } #ifdef __IBMCPP__ @@ -82,13 +78,9 @@ static int #endif _hb_do_sortdescend( const void * p1, const void * p2 ) { - const char * pc1 = ( const char * ) p1; - const char * pc2 = ( const char * ) p2; - - pc1 += s_sElementPos; - pc2 += s_sElementPos; - - return -strncmp( pc1, pc2, s_sCompareLen ); + return -strncmp( ( const char * ) p1 + s_sElementPos, + ( const char * ) p2 + s_sElementPos, + s_sCompareLen ); } HB_FUNC( CHARSORT ) @@ -103,40 +95,17 @@ HB_FUNC( CHARSORT ) { /* get parameters */ const char * pcString = hb_parc( 1 ); - char * pcRet; - HB_SIZE sStrLen = hb_parclen( 1 ); - HB_SIZE sElementLen, sIgnore, sSortLen; - int iDescend; + char * pcRet; + HB_SIZE sStrLen = hb_parclen( 1 ); + HB_SIZE sElementLen, sIgnore, sSortLen; + int iDescend; - if( HB_ISNUM( 2 ) ) - sElementLen = hb_parns( 2 ); - else - sElementLen = 1; - - if( HB_ISNUM( 3 ) ) - s_sCompareLen = hb_parns( 3 ); - else - s_sCompareLen = sElementLen; - - if( HB_ISNUM( 4 ) ) - sIgnore = hb_parns( 4 ); - else - sIgnore = 0; - - if( HB_ISNUM( 5 ) ) - s_sElementPos = hb_parns( 5 ); - else - s_sElementPos = 0; - - if( HB_ISNUM( 6 ) ) - sSortLen = hb_parns( 6 ); - else - sSortLen = sStrLen - sIgnore; - - if( HB_ISLOG( 7 ) ) - iDescend = hb_parl( 7 ); - else - iDescend = 0; + sElementLen = hb_parnsdef( 2, 1 ); + s_sCompareLen = hb_parnsdef( 3, sElementLen ); + sIgnore = hb_parnsdef( 4, 0 ); + s_sElementPos = hb_parnsdef( 5, 0 ); + sSortLen = hb_parnsdef( 6, sStrLen - sIgnore ); + iDescend = hb_parldef( 7, 0 ); /* param check II */ if( sElementLen == 0 || s_sCompareLen > sElementLen || @@ -147,11 +116,10 @@ HB_FUNC( CHARSORT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARSORT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + if( iNoRet ) hb_retl( HB_FALSE ); else @@ -168,8 +136,7 @@ HB_FUNC( CHARSORT ) qsort( pcRet + sIgnore, ( sSortLen / sElementLen ), sElementLen, _hb_do_sortascend ); /* return string */ - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sStrLen, 1 ); + hb_storclen( pcRet, sStrLen, 1 ); if( iNoRet ) { @@ -179,17 +146,15 @@ HB_FUNC( CHARSORT ) else hb_retclen_buffer( pcRet, sStrLen ); } - else /* if( HB_ISCHAR( 1 ) ) */ + else { - PHB_ITEM pSubst = NULL; - int iArgErrorMode = ct_getargerrormode(); + PHB_ITEM pSubst = NULL; + int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARSORT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/charsprd.c b/harbour/contrib/hbct/charsprd.c index 79c2d0f252..6b90b72d66 100644 --- a/harbour/contrib/hbct/charsprd.c +++ b/harbour/contrib/hbct/charsprd.c @@ -87,10 +87,9 @@ HB_FUNC( CHARSPREAD ) ++ul; } } + if( nTokens == 0 ) - { hb_itemReturn( hb_param( 1, HB_IT_ANY ) ); - } else { nRest = ( HB_SIZE ) nSize - nLen; diff --git a/harbour/contrib/hbct/charswap.c b/harbour/contrib/hbct/charswap.c index 90434a6af6..886dedbe29 100644 --- a/harbour/contrib/hbct/charswap.c +++ b/harbour/contrib/hbct/charswap.c @@ -92,14 +92,10 @@ static void do_charswap( int iSwitch ) { iShift = 4; if( hb_parl( 2 ) ) - { iSwitch = DO_CHARSWAP_WORDSWAP_CHARSWAP; - } } else - { iShift = 2; - } pcRet = ( char * ) hb_xgrab( sStrLen ); @@ -126,24 +122,15 @@ static void do_charswap( int iSwitch ) /* copy rest of string */ if( iSwitch == DO_CHARSWAP_WORDSWAP || iSwitch == DO_CHARSWAP_WORDSWAP_CHARSWAP ) - { iMod = sStrLen % 4; - } else - { iMod = sStrLen % 2; - } for( pcSub = pcString + sStrLen - iMod; pcSub < pcString + sStrLen; pcSub++ ) - { pcRet[ sRetIndex++ ] = *pcSub; - } /* return string */ - if( HB_ISBYREF( 1 ) ) - { - hb_storclen( pcRet, sRetIndex, 1 ); - } + hb_storclen( pcRet, sRetIndex, 1 ); if( iNoRet ) hb_retl( HB_FALSE ); @@ -151,7 +138,7 @@ static void do_charswap( int iSwitch ) hb_retclen( pcRet, sRetIndex ); hb_xfree( pcRet ); } - else /* if( HB_ISCHAR( 1 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); @@ -159,19 +146,15 @@ static void do_charswap( int iSwitch ) if( iArgErrorMode != CT_ARGERR_IGNORE ) { if( iSwitch == DO_CHARSWAP_CHARSWAP ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARSWAP, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } else - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_WORDSWAP, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } } if( pSubst != NULL ) diff --git a/harbour/contrib/hbct/count.c b/harbour/contrib/hbct/count.c index cedf845c6a..2e5e0ab3b3 100644 --- a/harbour/contrib/hbct/count.c +++ b/harbour/contrib/hbct/count.c @@ -102,19 +102,17 @@ static void do_count( int iSwitch ) hb_retns( sRetVal ); } - else /* if( HB_ISCHAR( 1 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_COUNT_COUNTLEFT ? CT_ERROR_COUNTLEFT : CT_ERROR_COUNTRIGHT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/ctc.c b/harbour/contrib/hbct/ctc.c index 8af23002af..77e1dbee86 100644 --- a/harbour/contrib/hbct/ctc.c +++ b/harbour/contrib/hbct/ctc.c @@ -225,10 +225,8 @@ HB_FUNC( CSETARGERR ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETARGERR, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } } } else if( hb_pcount() > 0 ) /* more than one param but not integer */ @@ -236,10 +234,8 @@ HB_FUNC( CSETARGERR ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETARGERR, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } } } diff --git a/harbour/contrib/hbct/ctmath.h b/harbour/contrib/hbct/ctmath.h index f7ac43784b..415cc42011 100644 --- a/harbour/contrib/hbct/ctmath.h +++ b/harbour/contrib/hbct/ctmath.h @@ -4,10 +4,9 @@ /* * Harbour Project source code: - * CTOOLS for Harbour, Math header file - * - * Copyright 2001 Alejandro de garate + * CA-T*ols for Harbour, Math header file * + * Copyright 2001 Alejandro de garate * www - http://harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -56,12 +55,12 @@ #include "hbmath.h" -HB_EXTERN_BEGIN - #define CT_PI 3.14159265358979323846 #define CT_PI_2 1.57079632679489661923 #define CT_PI_RAD 0.0174532925199432957692 /* 3.14159265358979323846 / 180.0 */ +HB_EXTERN_BEGIN + /* initialization */ extern int ct_math_init( void ); extern int ct_math_exit( void ); diff --git a/harbour/contrib/hbct/ctmath2.c b/harbour/contrib/hbct/ctmath2.c index e1684b6392..b300d98124 100644 --- a/harbour/contrib/hbct/ctmath2.c +++ b/harbour/contrib/hbct/ctmath2.c @@ -6,15 +6,13 @@ * Harbour Project source code: * * CT3 mathematical functions - * - FLOOR - * - CEILING - * - SIGN - * - LOG10 - * - FACT + * - FLOOR() + * - CEILING() + * - SIGN() + * - LOG10() + * - FACT() * - * NOTE: All these functions were builded using Borland C++ 5.5 (free version) - * - * Copyright 2001 Alejandro de Garate + * Copyright 2001 Alejandro de Garate * * Documentation and changes concerning error handling Copyright 2001 * IntTec GmbH, Freiburg, Germany, Author: Martin Vogel @@ -91,11 +89,10 @@ HB_FUNC( FLOOR ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_FLOOR, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -128,11 +125,10 @@ HB_FUNC( CEILING ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CEILING, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -164,11 +160,10 @@ HB_FUNC( SIGN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SIGN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -214,11 +209,10 @@ HB_FUNC( LOG10 ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_LOG10, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -249,11 +243,10 @@ HB_FUNC( FACT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_FACT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else diff --git a/harbour/contrib/hbct/ctpad.c b/harbour/contrib/hbct/ctpad.c index f4ac1e0213..438cb3798a 100644 --- a/harbour/contrib/hbct/ctpad.c +++ b/harbour/contrib/hbct/ctpad.c @@ -76,13 +76,12 @@ static void do_pad( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_PAD_PADLEFT ? CT_ERROR_PADLEFT : CT_ERROR_PADRIGHT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); return; } @@ -107,9 +106,7 @@ static void do_pad( int iSwitch ) hb_xmemcpy( pcRet + ( sRetLen - sStrLen ), pcString, sStrLen ); } else - { hb_xmemcpy( pcRet, pcString + ( sStrLen - sRetLen ), sRetLen ); - } } else { @@ -123,19 +120,17 @@ static void do_pad( int iSwitch ) } hb_retclen_buffer( pcRet, sRetLen ); } - else /* HB_ISCHAR( 1 ) && HB_ISNUM( 2 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_PAD_PADLEFT ? CT_ERROR_PADLEFT : CT_ERROR_PADRIGHT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/ctstr.c b/harbour/contrib/hbct/ctstr.c index c3f0193590..744cc92ec4 100644 --- a/harbour/contrib/hbct/ctstr.c +++ b/harbour/contrib/hbct/ctstr.c @@ -75,7 +75,6 @@ int ct_str_exit( void ) const char * ct_at_exact_forward( const char * pcString, HB_SIZE sStrLen, const char * pcMatch, HB_SIZE sMatchLen, HB_SIZE * psMatchStrLen ) { - HB_SIZE sPos; HB_TRACE( HB_TR_DEBUG, ( "ct_at_exact_forward (\"%s\", %" HB_PFS "u, \"%s\", %" HB_PFS "u, %p)", @@ -86,16 +85,13 @@ const char * ct_at_exact_forward( const char * pcString, HB_SIZE sStrLen, sPos = hb_strAt( pcMatch, sMatchLen, pcString, sStrLen ); if( sPos == 0 ) - { return NULL; - } else { if( psMatchStrLen != NULL ) *psMatchStrLen = sMatchLen; return pcString + sPos - 1; } - } /* ------------------------------------------------ */ @@ -104,7 +100,6 @@ const char * ct_at_exact_forward( const char * pcString, HB_SIZE sStrLen, const char * ct_at_exact_backward( const char * pcString, HB_SIZE sStrLen, const char * pcMatch, HB_SIZE sMatchLen, HB_SIZE * psMatchStrLen ) { - HB_SIZE sIndex; const char * pcRet; @@ -117,8 +112,10 @@ const char * ct_at_exact_backward( const char * pcString, HB_SIZE sStrLen, for( pcRet = pcString + sStrLen - sMatchLen; pcRet >= pcString; pcRet-- ) { for( sIndex = 0; sIndex < sMatchLen; sIndex++ ) + { if( *( pcRet + sIndex ) != *( pcMatch + sIndex ) ) break; + } if( sIndex == sMatchLen ) { /* last match found */ @@ -138,7 +135,6 @@ 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; const char * pcRet, * pcStop; @@ -176,7 +172,6 @@ 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; const char * pcRet; @@ -213,7 +208,6 @@ const char * ct_at_wildcard_backward( const char * pcString, HB_SIZE sStrLen, 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; HB_TRACE( HB_TR_DEBUG, ( "ct_at_charset_forward (\"%s\", %" HB_PFS "u, \"%s\", %" HB_PFS "u, %p)", @@ -246,7 +240,6 @@ const char * ct_at_charset_forward( const char * pcString, HB_SIZE sStrLen, 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; HB_TRACE( HB_TR_DEBUG, ( "ct_at_charset_backward (\"%s\", %" HB_PFS "u, \"%s\", %" HB_PFS "u, %p)", @@ -295,18 +288,14 @@ HB_FUNC( CSETREF ) hb_retl( ct_getref() ); if( HB_ISLOG( 1 ) ) - { ct_setref( hb_parl( 1 ) ); - } else if( hb_pcount() > 0 ) /* 1 params, but is not logical ! */ { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETREF, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } } } @@ -333,18 +322,14 @@ HB_FUNC( CSETATMUPA ) hb_retl( ct_getatmupa() ); if( HB_ISLOG( 1 ) ) - { ct_setatmupa( hb_parl( 1 ) ); - } else if( hb_pcount() > 0 ) /* 1 params, but is not logical ! */ { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETATMUPA, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } } } @@ -399,15 +384,13 @@ HB_FUNC( SETATLIKE ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SETATLIKE, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } } } - /* set new wildcard character, if HB_ISCHAR(2) but !HB_ISBYREF(2) */ + /* set new wildcard character, if HB_ISCHAR( 2 ) but ! HB_ISBYREF( 2 ) */ if( HB_ISCHAR( 2 ) ) { if( HB_ISBYREF( 2 ) ) @@ -431,9 +414,7 @@ HB_FUNC( SETATLIKE ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SETATLIKE, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } } } diff --git a/harbour/contrib/hbct/datetime.c b/harbour/contrib/hbct/datetime.c index 797bf752b5..da1d68d69b 100644 --- a/harbour/contrib/hbct/datetime.c +++ b/harbour/contrib/hbct/datetime.c @@ -79,9 +79,7 @@ HB_FUNC( BOM ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { @@ -89,9 +87,7 @@ HB_FUNC( BOM ) hb_retd( iYear, iMonth, 1 ); } else - { hb_retdl( 0 ); - } } HB_FUNC( EOM ) @@ -105,9 +101,7 @@ HB_FUNC( EOM ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { @@ -121,9 +115,7 @@ HB_FUNC( EOM ) hb_retdl( hb_dateEncode( iYear, iMonth, 1 ) - 1 ); } else - { hb_retdl( 0 ); - } } HB_FUNC( BOQ ) @@ -137,9 +129,7 @@ HB_FUNC( BOQ ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { @@ -149,9 +139,7 @@ HB_FUNC( BOQ ) hb_retd( iYear, iMonth, 1 ); } else - { hb_retdl( 0 ); - } } HB_FUNC( EOQ ) @@ -165,13 +153,10 @@ HB_FUNC( EOQ ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { - hb_dateDecode( lDate, &iYear, &iMonth, &iDay ); iMonth += 3 - ( ( iMonth - 1 ) % 3 ); if( iMonth > 12 ) @@ -182,9 +167,7 @@ HB_FUNC( EOQ ) hb_retdl( hb_dateEncode( iYear, iMonth, 1 ) - 1 ); } else - { hb_retdl( 0 ); - } } HB_FUNC( BOY ) @@ -198,9 +181,7 @@ HB_FUNC( BOY ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { @@ -208,9 +189,7 @@ HB_FUNC( BOY ) hb_retd( iYear, 1, 1 ); } else - { hb_retdl( 0 ); - } } HB_FUNC( EOY ) @@ -224,9 +203,7 @@ HB_FUNC( EOY ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { @@ -234,9 +211,7 @@ HB_FUNC( EOY ) hb_retdl( hb_dateEncode( iYear + 1, 1, 1 ) - 1 ); } else - { hb_retdl( 0 ); - } } static int hb_wom( int iYear, int iMonth, int iDay ) @@ -263,9 +238,7 @@ HB_FUNC( WOM ) lDate = hb_dateEncode( iYear, iMonth, iDay ); } else - { lDate = hb_pardl( 1 ); - } if( lDate != 0 ) { @@ -273,7 +246,5 @@ HB_FUNC( WOM ) hb_retni( hb_wom( iYear, iMonth, iDay ) ); } else - { hb_retni( 0 ); - } } diff --git a/harbour/contrib/hbct/dattime2.c b/harbour/contrib/hbct/dattime2.c index 7320fbd7bc..7d9a4a1425 100644 --- a/harbour/contrib/hbct/dattime2.c +++ b/harbour/contrib/hbct/dattime2.c @@ -347,7 +347,6 @@ HB_FUNC( DAYSINMONTH ) HB_BOOL bLeap = hb_parl( 2 ); hb_retni( ct_daysinmonth( iMonth, bLeap ) ); - } HB_FUNC( QUARTER ) @@ -380,7 +379,6 @@ HB_FUNC( LASTDAYOM ) } hb_retni( ( iMonth && ( iMonth <= 12 ) ? ct_daysinmonth( iMonth, bLeap ) : 0 ) ); - } HB_FUNC( NTOCDOW ) diff --git a/harbour/contrib/hbct/exponent.c b/harbour/contrib/hbct/exponent.c index 2e6cdead3e..49d90bef50 100644 --- a/harbour/contrib/hbct/exponent.c +++ b/harbour/contrib/hbct/exponent.c @@ -59,7 +59,6 @@ HB_FUNC( MANTISSA ) { - #ifdef CT_EXPONENT_MANTISSA_BIT union @@ -104,12 +103,10 @@ HB_FUNC( MANTISSA ) hb_retnd( dValue ); #endif - } HB_FUNC( EXPONENT ) { - #ifdef CT_EXPONENT_MANTISSA_BIT int iExponent = 0; @@ -164,5 +161,4 @@ HB_FUNC( EXPONENT ) hb_retni( iExponent ); #endif - } diff --git a/harbour/contrib/hbct/files.c b/harbour/contrib/hbct/files.c index c164cc0e4c..a200d1ccae 100644 --- a/harbour/contrib/hbct/files.c +++ b/harbour/contrib/hbct/files.c @@ -6,15 +6,15 @@ * Harbour Project source code: * CT3 files functions * - * SETFATTR + * SETFATTR() * Copyright 2001 Luiz Rafael Culik * - * SETFDATI, FILESMAX, FILEDELETE + * SETFDATI(), FILESMAX(), FILEDELETE() * Copyright 2004 Phil Krylov * - * FILESEEK, FILESIZE, FILEATTR, FILETIME, FILEDATE - * FILEMOVE, FILESMAX, - * DELETEFILE, RENAMEFILE + * FILESEEK(), FILESIZE(), FILEATTR(), FILETIME(), FILEDATE() + * FILEMOVE(), FILESMAX(), + * DELETEFILE(), RENAMEFILE() * * Copyright 2007 Przemyslaw Czerpak * @@ -241,13 +241,9 @@ HB_FUNC( FILEDELETE ) if( HB_ISCHAR( 1 ) ) { - const char * pszDirSpec; + const char * pszDirSpec = hb_parc( 1 ); + HB_FATTR ulAttr = hb_parnldef( 2, HB_FA_ALL ); PHB_FFIND ffind; - HB_FATTR ulAttr = HB_FA_ALL; - - pszDirSpec = hb_parc( 1 ); - if( HB_ISNUM( 2 ) ) - ulAttr = hb_parnl( 2 ); if( ( ffind = hb_fsFindFirst( pszDirSpec, ulAttr ) ) != NULL ) { diff --git a/harbour/contrib/hbct/finan.c b/harbour/contrib/hbct/finan.c index 19fbadefd7..7f51ed4652 100644 --- a/harbour/contrib/hbct/finan.c +++ b/harbour/contrib/hbct/finan.c @@ -5,15 +5,13 @@ /* * Harbour Project source code: * CT3 Financial functions - * - PV - * - FV - * - PAYMENT - * - PERIODS - * - RATE + * - PV() + * - FV() + * - PAYMENT() + * - PERIODS() + * - RATE() * - * NOTE: All these functions were builded using Borland C++ 5.5 (free version) - * - * Copyright 2001 Alejandro de Garate + * Copyright 2001 Alejandro de Garate * * Documentation and changes concerning error handling Copyright 2001 * IntTec GmbH, Freiburg, Germany, Author: Martin Vogel @@ -86,10 +84,10 @@ HB_FUNC( FV ) hb_mathResetError( &hb_exc ); dResult = pow( dBase, dTime ); + if( hb_mathGetError( &hb_exc, "POW", dBase, dTime, dResult ) ) - { dResult = hb_exc.handled ? hb_exc.retval : 0.0; - } + dResult = dPayment * ( dResult - 1.0 ) / dRate; } @@ -101,11 +99,9 @@ HB_FUNC( FV ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_FV, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -135,10 +131,10 @@ HB_FUNC( PV ) hb_mathResetError( &hb_exc ); dResult = pow( dBase, -dTime ); + if( hb_mathGetError( &hb_exc, "POW", dBase, -dTime, dResult ) ) - { dResult = hb_exc.handled ? hb_exc.retval : 0.0; - } + dResult = dPayment * ( 1.0 - dResult ) / dRate; } @@ -150,11 +146,9 @@ HB_FUNC( PV ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_PV, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -184,10 +178,10 @@ HB_FUNC( PAYMENT ) hb_mathResetError( &hb_exc ); dResult = pow( dBase, -dTime ); + if( hb_mathGetError( &hb_exc, "POW", dBase, -dTime, dResult ) ) - { dResult = hb_exc.handled ? hb_exc.retval : 0.0; - } + dResult = dCapital * dRate / ( 1.0 - dResult ); } @@ -199,11 +193,9 @@ HB_FUNC( PAYMENT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_PAYMENT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -239,9 +231,7 @@ HB_FUNC( PERIODS ) hb_mathResetError( &hb_exc ); dResult = log( dBase ); if( hb_mathGetError( &hb_exc, "LOG", dBase, 0.0, dResult ) ) - { dResult = hb_exc.handled ? hb_exc.retval : 0.0; - } if( dResult ) { @@ -249,10 +239,10 @@ HB_FUNC( PERIODS ) hb_mathResetError( &hb_exc ); dBase = 1.0 - ( dCapital * dRate / dPayment ); dResult2 = log( dBase ); + if( hb_mathGetError( &hb_exc, "LOG", dBase, 0.0, dResult2 ) ) - { dResult2 = hb_exc.handled ? hb_exc.retval : 0.0; - } + dResult = -dResult2 / dResult; } } @@ -265,11 +255,9 @@ HB_FUNC( PERIODS ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_PERIODS, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -285,11 +273,11 @@ HB_FUNC( RATE ) double dCapital = hb_parnd( 1 ); double dPayment = hb_parnd( 2 ); double dTime = hb_parnd( 3 ); - double dAux; /* estimated payment to compare for */ + double dAux; /* estimated payment to compare for */ double dEpsilon = 0.00001; /* mimimal to consider 2 numbers as equal */ - double dScale = 1.0; /* fractional step */ - double r; /* temptative rate */ - double j = 1.0; /* index */ + double dScale = 1.0; /* fractional step */ + double r; /* temptative rate */ + double j = 1.0; /* index */ double dExp; while( j < 1020.0 ) /* maximum anual rate */ @@ -322,8 +310,7 @@ HB_FUNC( RATE ) } else j += dScale; - - } /* endwhile */ + } hb_retnd( j * 0.000833333 ); /* return as mensual's rate */ } @@ -333,11 +320,9 @@ HB_FUNC( RATE ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_RATE, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/justify.c b/harbour/contrib/hbct/justify.c index 13717cb7cc..01df6bba41 100644 --- a/harbour/contrib/hbct/justify.c +++ b/harbour/contrib/hbct/justify.c @@ -61,7 +61,6 @@ /* helper function for the justxxx() functions */ static void do_justify( int iSwitch ) { - int iNoRet; iNoRet = ct_getref() && HB_ISBYREF( 1 ); @@ -103,11 +102,12 @@ static void do_justify( int iSwitch ) sJustOffset++; pc++; } + hb_xmemcpy( pcRet, pcString + sJustOffset, sStrLen - sJustOffset ); + for( pcw = pcRet + sStrLen - sJustOffset; pcw < pcRet + sStrLen; pcw++ ) - { *pcw = cJustChar; - } + break; case DO_JUSTIFY_JUSTRIGHT: @@ -118,16 +118,15 @@ static void do_justify( int iSwitch ) sJustOffset++; pc--; } + for( pcw = pcRet; pcw < pcRet + sJustOffset; pcw++ ) - { *pcw = cJustChar; - } + hb_xmemcpy( pcRet + sJustOffset, pcString, sStrLen - sJustOffset ); break; } - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sStrLen, 1 ); + hb_storclen( pcRet, sStrLen, 1 ); if( iNoRet ) { @@ -137,19 +136,17 @@ static void do_justify( int iSwitch ) else hb_retclen_buffer( pcRet, sStrLen ); } - else /* HB_ISCHAR( 1 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_JUSTIFY_JUSTLEFT ? CT_ERROR_JUSTLEFT : CT_ERROR_JUSTRIGHT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/num1.c b/harbour/contrib/hbct/num1.c index b7468b5e04..916f89466a 100644 --- a/harbour/contrib/hbct/num1.c +++ b/harbour/contrib/hbct/num1.c @@ -6,13 +6,11 @@ * Harbour Project source code: * * CT3 Numeric functions - PART 1 - * - CELSIUS - * - FAHRENHEIT - * - INFINITY + * - CELSIUS() + * - FAHRENHEIT() + * - INFINITY() * - * NOTE: All these functions were builded using Borland C++ 5.5 (free version) - * - * Copyright 2001 Alejandro de Garate + * Copyright 2001 Alejandro de Garate * * Documentation and changes concerning error handling Copyright 2001 * IntTec GmbH, Freiburg, Germany, Author: Martin Vogel @@ -81,11 +79,9 @@ HB_FUNC( CELSIUS ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CELSIUS, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -110,11 +106,9 @@ HB_FUNC( FAHRENHEIT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_FAHRENHEIT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/numat.c b/harbour/contrib/hbct/numat.c index 9f8fa98584..2d34f0ed8c 100644 --- a/harbour/contrib/hbct/numat.c +++ b/harbour/contrib/hbct/numat.c @@ -70,20 +70,16 @@ HB_FUNC( NUMAT ) const char * pc, * pcSubStr; /* eventually ignore some characters */ - if( HB_ISNUM( 3 ) ) - sIgnore = hb_parns( 3 ); - else - sIgnore = 0; + sIgnore = hb_parnsdef( 3, 0 ); if( sIgnore >= sStrLen ) { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_NUMAT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retni( 0 ); return; } @@ -126,17 +122,15 @@ HB_FUNC( NUMAT ) hb_retns( nCounter - 1 ); } - else /* ( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_NUMAT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/numcount.c b/harbour/contrib/hbct/numcount.c index b4dec33bbe..278f43523a 100644 --- a/harbour/contrib/hbct/numcount.c +++ b/harbour/contrib/hbct/numcount.c @@ -57,11 +57,9 @@ static HB_LONG s_lCounter = 0; HB_FUNC( NUMCOUNT ) { - HB_BOOL bMode = hb_parl( 2 ); - if( HB_ISNUM( 1 ) ) { - if( bMode ) + if( hb_parl( 2 ) ) s_lCounter = hb_parnl( 1 ); else s_lCounter += hb_parnl( 1 ); diff --git a/harbour/contrib/hbct/pos1.c b/harbour/contrib/hbct/pos1.c index 5a4d1bdb98..63690a4796 100644 --- a/harbour/contrib/hbct/pos1.c +++ b/harbour/contrib/hbct/pos1.c @@ -81,16 +81,13 @@ static void do_pos1( int iSwitch ) if( iSwitch == DO_POS1_POSRANGE ) { - if( hb_parclen( 1 ) == 0 ) { hb_retns( 0 ); return; } else - { ucChar1 = *( hb_parc( 1 ) ); - } if( hb_parclen( 2 ) == 0 ) { @@ -98,9 +95,7 @@ static void do_pos1( int iSwitch ) return; } else - { ucChar2 = *( hb_parc( 2 ) ); - } iParamShift += 2; } @@ -108,15 +103,8 @@ static void do_pos1( int iSwitch ) pcString = ( const unsigned char * ) hb_parc( iParamShift + 1 ); sStrLen = hb_parclen( iParamShift + 1 ); - if( HB_ISLOG( iParamShift + 2 ) ) - iMode = hb_parl( iParamShift + 2 ); - else - iMode = 0; - - if( HB_ISNUM( iParamShift + 3 ) ) - sIgnore = hb_parns( iParamShift + 3 ); - else - sIgnore = 0; + iMode = hb_parldef( iParamShift + 2, 0 ); + sIgnore = hb_parnsdef( iParamShift + 3, 0 ); for( puc = pcString + sIgnore; puc < pcString + sStrLen; puc++ ) { @@ -149,7 +137,7 @@ static void do_pos1( int iSwitch ) } hb_retns( 0 ); } - else /* ISCHAR (1) etc. */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); diff --git a/harbour/contrib/hbct/pos2.c b/harbour/contrib/hbct/pos2.c index ff9f325a94..e55af335df 100644 --- a/harbour/contrib/hbct/pos2.c +++ b/harbour/contrib/hbct/pos2.c @@ -88,8 +88,7 @@ HB_FUNC( POSCHAR ) hb_xmemcpy( pcRet, pcString, sStrLen ); *( pcRet + sPosition - 1 ) = cReplace; - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sStrLen, 1 ); + hb_storclen( pcRet, sStrLen, 1 ); if( iNoRet ) { @@ -99,17 +98,15 @@ HB_FUNC( POSCHAR ) else hb_retclen_buffer( pcRet, sStrLen ); } - else /* ( hb_parclen( 2 ) > 0 ) || HB_ISNUM( 2 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSCHAR, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -119,17 +116,15 @@ HB_FUNC( POSCHAR ) hb_retclen( hb_parc( 1 ), hb_parclen( 1 ) ); } } - else /* hb_parclen( 1 ) > 0 */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSCHAR, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -146,14 +141,10 @@ HB_FUNC( POSDEL ) { const char * pcString = hb_parc( 1 ); HB_SIZE sStrLen = hb_parclen( 1 ); - HB_SIZE sStartPos, sDelLen; + HB_SIZE sStartPos; + HB_SIZE sDelLen = hb_parnsdef( 3, 1 ); char * pcRet; - if( HB_ISNUM( 3 ) ) - sDelLen = hb_parns( 3 ); - else - sDelLen = 1; /* set new standard behavior */ - if( HB_ISNUM( 2 ) ) { sStartPos = hb_parns( 2 ); @@ -173,30 +164,24 @@ HB_FUNC( POSDEL ) /* copy first part */ if( sStartPos > 1 ) - { hb_xmemcpy( pcRet, pcString, sStartPos - 1 ); - } /* copy second part */ if( sStrLen > ( sStartPos - 1 + sDelLen ) ) - { hb_xmemcpy( pcRet + sStartPos - 1, pcString + sStartPos - 1 + sDelLen, sStrLen - ( sStartPos - 1 + sDelLen ) ); - } hb_retclen_buffer( pcRet, sStrLen - sDelLen ); } - else /* HB_ISCHAR( 1 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSDEL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -236,11 +221,10 @@ HB_FUNC( POSINS ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSINS, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retclen( pcString, sStrLen ); return; } @@ -256,27 +240,23 @@ HB_FUNC( POSINS ) /* copy second part */ if( sStrLen > ( sStartPos - 1 ) ) - { hb_xmemcpy( pcRet + sStartPos - 1 + sInsLen, pcString + sStartPos - 1, sStrLen - ( sStartPos - 1 ) ); - } hb_retclen_buffer( pcRet, sStrLen + sInsLen ); } - else /* hb_parclen( 2 ) > 0 */ + else hb_retclen( pcString, sStrLen ); } - else /* HB_ISCHAR( 1 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSINS, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -300,7 +280,6 @@ HB_FUNC( POSREPL ) if( ( sReplLen = hb_parclen( 2 ) ) > 0 ) { - HB_SIZE sStartPos; char * pcRet; HB_SIZE sRetLen; @@ -332,11 +311,9 @@ HB_FUNC( POSREPL ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } if( iNoRet ) hb_ret(); @@ -364,10 +341,7 @@ HB_FUNC( POSREPL ) hb_xmemcpy( pcRet + sStartPos - 1 + sReplLen, pcString + sStartPos - 1 + sReplLen, sStrLen - ( sStartPos - 1 + sReplLen ) ); - if( HB_ISBYREF( 1 ) ) - { - hb_storclen( pcRet, sRetLen, 1 ); - } + hb_storclen( pcRet, sRetLen, 1 ); if( iNoRet ) { @@ -376,19 +350,16 @@ HB_FUNC( POSREPL ) } else hb_retclen_buffer( pcRet, sRetLen ); - } - else /* hb_parclen( 2 ) > 0 */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -398,17 +369,15 @@ HB_FUNC( POSREPL ) hb_retclen( pcString, sStrLen ); } } - else /* HB_ISCHAR( 1 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/posdiff.c b/harbour/contrib/hbct/posdiff.c index 13f9ee3ba8..b7f3d62f20 100644 --- a/harbour/contrib/hbct/posdiff.c +++ b/harbour/contrib/hbct/posdiff.c @@ -63,22 +63,16 @@ HB_FUNC( POSDIFF ) const char * pcString2 = hb_parc( 2 ); HB_SIZE sStrLen2 = hb_parclen( 2 ); const char * pc1, * pc2; - HB_SIZE sIgnore; + HB_SIZE sIgnore = hb_parnsdef( 3, 0 ); - if( HB_ISNUM( 3 ) ) - sIgnore = hb_parns( 3 ); - else - sIgnore = 0; - - if( ( sIgnore > sStrLen1 ) || ( sIgnore > sStrLen2 ) ) + if( sIgnore > sStrLen1 || sIgnore > sStrLen2 ) { int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSDIFF, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retns( 0 ); return; } @@ -102,17 +96,15 @@ HB_FUNC( POSDIFF ) else hb_retns( 0 ); } - else /* ( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSDIFF, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -132,12 +124,8 @@ HB_FUNC( POSEQUAL ) const char * pcString2 = hb_parc( 2 ); HB_SIZE sStrLen2 = hb_parclen( 2 ); const char * pc1, * pc2; - HB_SIZE sIgnore, sCompare, sCompareCnt, sRet = 0; - - if( HB_ISNUM( 4 ) ) - sIgnore = hb_parns( 4 ); - else - sIgnore = 0; + HB_SIZE sIgnore = hb_parnsdef( 4, 0 ); + HB_SIZE sCompare, sCompareCnt, sRet = 0; if( HB_ISNUM( 3 ) ) sCompare = hb_parns( 3 ); @@ -149,10 +137,9 @@ HB_FUNC( POSEQUAL ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSEQUAL, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retns( 0 ); return; } @@ -162,10 +149,9 @@ HB_FUNC( POSEQUAL ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSEQUAL, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retns( 0 ); return; } @@ -199,17 +185,15 @@ HB_FUNC( POSEQUAL ) } hb_retns( 0 ); } - else /* ( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSEQUAL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/range.c b/harbour/contrib/hbct/range.c index b179d8ed5f..f3bf9eae12 100644 --- a/harbour/contrib/hbct/range.c +++ b/harbour/contrib/hbct/range.c @@ -99,18 +99,15 @@ HB_FUNC( RANGEREM ) hb_retclen( pcRet, sRetIndex ); hb_xfree( pcRet ); } - else /* ( hb_parclen( 1 ) > 0 || HB_ISNUM( 1 ) ) && - ( hb_parclen( 2 ) > 0 || HB_ISNUM( 2 ) ) && HB_ISCHAR( 3 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_RANGEREM, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -176,8 +173,7 @@ HB_FUNC( RANGEREPL ) } } - if( HB_ISBYREF( 3 ) ) - hb_storclen( pcRet, sStrLen, 3 ); + hb_storclen( pcRet, sStrLen, 3 ); if( iNoRef ) /* Contrary to the official documentation, RANGREPL() returns NIL instead of .F. @@ -189,19 +185,15 @@ HB_FUNC( RANGEREPL ) hb_xfree( pcRet ); } - else /* ( hb_parclen( 1 ) > 0 || HB_ISNUM( 1 ) ) && - ( hb_parclen( 2 ) > 0 || HB_ISNUM( 2 ) ) && - HB_ISCHAR( 3 ) && ( hb_parclen( 4 ) > 0 || HB_ISNUM( 4 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_RANGEREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/relation.c b/harbour/contrib/hbct/relation.c index c2305453bf..60e90bbccc 100644 --- a/harbour/contrib/hbct/relation.c +++ b/harbour/contrib/hbct/relation.c @@ -107,24 +107,20 @@ HB_FUNC( CHARRELA ) } } else - { sOffset1 = sOffset2 = sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2; - } } hb_retns( 0 ); } - else /* HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) && HB_ISCHAR( 3 ) && HB_ISCHAR( 4 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARRELA, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -222,15 +218,10 @@ HB_FUNC( CHARRELREP ) } } else - { sOffset1 = sOffset2 = sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2; - } } - if( HB_ISBYREF( 4 ) ) - { - hb_storclen( pcRet, sStrLen2, 4 ); - } + hb_storclen( pcRet, sStrLen2, 4 ); if( iNoRet ) { @@ -238,22 +229,17 @@ HB_FUNC( CHARRELREP ) hb_ret(); } else - { hb_retclen_buffer( pcRet, sStrLen2 ); - } } - else /* HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) && HB_ISCHAR( 3 ) && - HB_ISCHAR( 4 ) && HB_ISCHAR( 5 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARRELREP, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/remove.c b/harbour/contrib/hbct/remove.c index 30d6fcd23b..03574ad2d8 100644 --- a/harbour/contrib/hbct/remove.c +++ b/harbour/contrib/hbct/remove.c @@ -59,7 +59,8 @@ #define DO_REMOVE_REMLEFT 1 #define DO_REMOVE_REMRIGHT 2 -static const HB_ERRCODE sulErrorSubcodes[] = { +static const HB_ERRCODE sulErrorSubcodes[] = +{ CT_ERROR_REMALL, CT_ERROR_REMLEFT, CT_ERROR_REMRIGHT @@ -112,18 +113,16 @@ static void do_remove( int iSwitch ) else hb_retclen( pcRet, sRetLen ); } - else /* if( HB_ISCHAR( 1 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, sulErrorSubcodes[ iSwitch ], NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/replace.c b/harbour/contrib/hbct/replace.c index d2259398a8..7687b07188 100644 --- a/harbour/contrib/hbct/replace.c +++ b/harbour/contrib/hbct/replace.c @@ -59,7 +59,8 @@ #define DO_REPLACE_REPLLEFT 1 #define DO_REPLACE_REPLRIGHT 2 -static const HB_ERRCODE sulErrorSubcodes[] = { +static const HB_ERRCODE sulErrorSubcodes[] = +{ CT_ERROR_REPLALL, CT_ERROR_REPLLEFT, CT_ERROR_REPLRIGHT @@ -68,7 +69,6 @@ static const HB_ERRCODE sulErrorSubcodes[] = { /* helper function for the replxxx functions */ static void do_replace( int iSwitch ) { - /* suppressing return value ? */ int iNoRet = ct_getref() && HB_ISBYREF( 1 ); @@ -124,8 +124,7 @@ static void do_replace( int iSwitch ) } } - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sStrLen, 1 ); + hb_storclen( pcRet, sStrLen, 1 ); if( iNoRet ) { @@ -135,18 +134,16 @@ static void do_replace( int iSwitch ) else hb_retclen_buffer( pcRet, sStrLen ); } - else /* HB_ISCHAR( 1 ) && ( hb_parclen( 2 ) > 0 || HB_ISNUM( 2 ) ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, sulErrorSubcodes[ iSwitch ], NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/strdiff.c b/harbour/contrib/hbct/strdiff.c index b366759308..5176518e90 100644 --- a/harbour/contrib/hbct/strdiff.c +++ b/harbour/contrib/hbct/strdiff.c @@ -109,38 +109,24 @@ HB_FUNC( STRDIFF ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_STRDIFF, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retni( -1 ); return; } /* get penalty points */ - if( HB_ISNUM( 3 ) ) - iReplace = hb_parni( 3 ); - else - iReplace = 3; - - if( HB_ISNUM( 4 ) ) - iDelete = hb_parni( 4 ); - else - iDelete = 6; - - if( HB_ISNUM( 5 ) ) - iInsert = hb_parni( 5 ); - else - iInsert = 1; + iReplace = hb_parnidef( 3, 3 ); + iDelete = hb_parnidef( 4, 6 ); + iInsert = hb_parnidef( 5, 1 ); piPenalty = ( int * ) hb_xgrab( ( sStrLen1 + 1 ) * ( sStrLen2 + 1 ) * sizeof( int ) ); MATRIXELEMENT( 0, 0 ) = 0; for( sColCnt = 0; sColCnt <= sStrLen2 - 1; sColCnt++ ) - { MATRIXELEMENT( 0, sColCnt + 1 ) = MATRIXELEMENT( 0, sColCnt ) + iInsert; - } for( sRowCnt = 0; sRowCnt <= sStrLen1 - 1; sRowCnt++ ) { @@ -167,17 +153,15 @@ HB_FUNC( STRDIFF ) hb_retni( MATRIXELEMENT( sStrLen1, sStrLen2 ) ); hb_xfree( piPenalty ); } - else /* HB_ISCHAR( 1 ) || HB_ISCHAR( 2 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_STRDIFF, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/strswap.c b/harbour/contrib/hbct/strswap.c index a86a80c8ff..776f093809 100644 --- a/harbour/contrib/hbct/strswap.c +++ b/harbour/contrib/hbct/strswap.c @@ -91,14 +91,10 @@ HB_FUNC( STRSWAP ) cExchange = *( pcString1 + sIndex ); *( pcRet1 + sIndex ) = *( pcString2 + sIndex ); if( iChange2 ) - { *( pcRet2 + sIndex ) = cExchange; - } } else - { *( pcRet2 + sIndex ) = *( pcString1 + sIndex ); - } } /* strings */ @@ -116,18 +112,15 @@ HB_FUNC( STRSWAP ) hb_retc_null(); } - else /* ( sStrLen1 = hb_parclen( 1 ) ) > 0 && - ( sStrLen2 = hb_parclen( 2 ) ) > 0 */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_STRSWAP, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/tab.c b/harbour/contrib/hbct/tab.c index c773f286a6..759287085a 100644 --- a/harbour/contrib/hbct/tab.c +++ b/harbour/contrib/hbct/tab.c @@ -106,10 +106,7 @@ HB_FUNC( TABEXPAND ) else cTab = 0x09; - if( HB_ISLOG( 6 ) ) - iIgnore141 = hb_parl( 6 ); - else - iIgnore141 = 0; + iIgnore141 = hb_parldef( 6, 0 ); /* estimate maximum return length by assuming that EVERY tab char can be replaced by at most characters */ @@ -193,17 +190,16 @@ HB_FUNC( TABEXPAND ) hb_retclen( pcRet, sRetLen ); hb_xfree( pcRet ); } - else /* HB_ISCHAR( 1 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TABEXPAND, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -258,10 +254,7 @@ HB_FUNC( TABPACK ) else cTab = 0x09; - if( HB_ISLOG( 6 ) ) - iIgnore141 = hb_parl( 6 ); - else - iIgnore141 = 0; + iIgnore141 = hb_parldef( 6, 0 ); if( sStrLen == 0 ) { @@ -363,9 +356,7 @@ HB_FUNC( TABPACK ) sRetLen++; sTabIndex++; if( sTabIndex == sTabWidth - 1 ) - { sTabIndex = 0; - } } *( pcRet + sRetLen ) = *( pcString + sIndex ); sRetLen++; @@ -384,17 +375,16 @@ HB_FUNC( TABPACK ) hb_retclen( pcRet, sRetLen ); hb_xfree( pcRet ); } - else /* HB_ISCHAR( 1 ) */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TABPACK, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else diff --git a/harbour/contrib/hbct/token1.c b/harbour/contrib/hbct/token1.c index ec5bc6cf43..361183ea13 100644 --- a/harbour/contrib/hbct/token1.c +++ b/harbour/contrib/hbct/token1.c @@ -226,8 +226,7 @@ static void do_token1( int iSwitch ) case DO_TOKEN1_TOKENLOWER: case DO_TOKEN1_TOKENUPPER: - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sRetStrLen, 1 ); + hb_storclen( pcRet, sRetStrLen, 1 ); if( iNoRef ) { @@ -268,9 +267,11 @@ static void do_token1( int iSwitch ) if( pc == NULL ) { - pc = pcSubStr + sSubStrLen; /* little trick for return values */ - break; /* we must leave the while loop even if we have not - yet found the th token */ + /* little trick for return values */ + pc = pcSubStr + sSubStrLen; + /* we must leave the while loop even if we have not + yet found the th token */ + break; } /* should we find the last token, but string ends with tokenizer, i.e. @@ -337,8 +338,7 @@ static void do_token1( int iSwitch ) case DO_TOKEN1_TOKENLOWER: case DO_TOKEN1_TOKENUPPER: - if( HB_ISBYREF( 1 ) ) - hb_storclen( pcRet, sRetStrLen, 1 ); + hb_storclen( pcRet, sRetStrLen, 1 ); if( iNoRef ) { @@ -350,7 +350,7 @@ static void do_token1( int iSwitch ) break; } } - else /* iParamCheck */ + else { switch( iSwitch ) { @@ -372,12 +372,10 @@ static void do_token1( int iSwitch ) } if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKEN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); @@ -394,14 +392,13 @@ static void do_token1( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_TOKEN1_TOKENLOWER ? CT_ERROR_TOKENLOWER : CT_ERROR_TOKENUPPER, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else if( ! iNoRef ) @@ -417,13 +414,12 @@ static void do_token1( int iSwitch ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, iSwitch == DO_TOKEN1_NUMTOKEN ? CT_ERROR_NUMTOKEN : CT_ERROR_ATTOKEN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else diff --git a/harbour/contrib/hbct/token2.c b/harbour/contrib/hbct/token2.c index 3fcd2e92db..bf8b35d399 100644 --- a/harbour/contrib/hbct/token2.c +++ b/harbour/contrib/hbct/token2.c @@ -282,11 +282,10 @@ HB_FUNC( TOKENINIT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_MEM, CT_ERROR_TOKENINIT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retl( HB_FALSE ); return; } @@ -327,11 +326,10 @@ HB_FUNC( TOKENINIT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_MEM, CT_ERROR_TOKENINIT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + sTokEnvDel( sTokenEnvironment ); hb_retl( HB_FALSE ); return; @@ -348,12 +346,11 @@ HB_FUNC( TOKENINIT ) sTokEnvDel( sTokenEnvironment ); } else - { sTokSet( sTokenEnvironment ); - } + hb_retl( HB_TRUE ); } - else /* HB_ISCHAR( 1 ) */ + else { /* if there is a token environment stored in either the 4th parameter or in the static variable -> rewind to first token */ @@ -378,11 +375,10 @@ HB_FUNC( TOKENINIT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENINIT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -411,11 +407,10 @@ HB_FUNC( TOKENNEXT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); return; } @@ -430,11 +425,10 @@ HB_FUNC( TOKENNEXT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); return; } @@ -459,10 +453,9 @@ HB_FUNC( TOKENNEXT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + if( HB_ISCHAR( 3 ) && HB_ISBYREF( 3 ) ) { hb_storclen( ( char * ) sTokenEnvironment, sTokEnvGetSize( sTokenEnvironment ), 3 ); @@ -484,7 +477,6 @@ HB_FUNC( TOKENNEXT ) hb_storclen( ( char * ) sTokenEnvironment, sTokEnvGetSize( sTokenEnvironment ), 3 ); hb_xfree( sTokenEnvironment ); } - } else { @@ -493,11 +485,10 @@ HB_FUNC( TOKENNEXT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -522,11 +513,10 @@ HB_FUNC( TOKENNUM ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNUM, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -551,11 +541,10 @@ HB_FUNC( TOKENEND ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENEND, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -595,10 +584,9 @@ HB_FUNC( TOKENAT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENAT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retns( 0 ); return; } @@ -614,10 +602,9 @@ HB_FUNC( TOKENAT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENAT, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retns( 0 ); return; } @@ -657,11 +644,10 @@ HB_FUNC( RESTTOKEN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { ct_error( ( HB_USHORT ) iArgErrorMode, EG_MEM, CT_ERROR_RESTTOKEN, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS ); - } + hb_retc_null(); return; } @@ -686,11 +672,10 @@ HB_FUNC( RESTTOKEN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_RESTTOKEN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else diff --git a/harbour/contrib/hbct/trig.c b/harbour/contrib/hbct/trig.c index d908635540..264e511306 100644 --- a/harbour/contrib/hbct/trig.c +++ b/harbour/contrib/hbct/trig.c @@ -5,24 +5,22 @@ /* * Harbour Project source code: * CT3 trigonometric functions - * - PI - * - SIN - * - COS - * - TAN - * - COT - * - ASIN - * - ACOS - * - ATAN - * - SINH - * - COSH - * - TANH - * - ATN2 - * - RTOD - * - DTOR + * - PI() + * - SIN() + * - COS() + * - TAN() + * - COT() + * - ASIN() + * - ACOS() + * - ATAN() + * - SINH() + * - COSH() + * - TANH() + * - ATN2() + * - RTOD() + * - DTOR() * - * NOTE: All these functions were builded using Borland C++ 5.5 (free version) - * - * Copyright 2001 Alejandro de Garate + * Copyright 2001 Alejandro de Garate * * Documentation and changes concerning error handling Copyright 2001 * IntTec GmbH, Freiburg, Germany, Author: Martin Vogel @@ -104,11 +102,10 @@ HB_FUNC( SIN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SIN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -141,11 +138,10 @@ HB_FUNC( COS ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_COS, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -178,11 +174,10 @@ HB_FUNC( TAN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TAN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -200,9 +195,8 @@ HB_FUNC( COT ) hb_mathResetError( &hb_exc ); dResult = tan( dArg ); if( hb_mathGetError( &hb_exc, "TAN", dArg, 0.0, dResult ) ) - { dResult = hb_exc.handled ? hb_exc.retval : 0.0; - } + dResult = dResult ? 1 / dResult : HUGE_VAL; hb_retnd( dResult ); } @@ -212,11 +206,10 @@ HB_FUNC( COT ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_COT, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -249,11 +242,10 @@ HB_FUNC( ASIN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ASIN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -286,11 +278,10 @@ HB_FUNC( ACOS ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ACOS, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -331,11 +322,10 @@ HB_FUNC( ATAN ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATAN, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -382,11 +372,10 @@ HB_FUNC( ATN2 ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATN2, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -426,11 +415,10 @@ HB_FUNC( SINH ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SINH, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -465,11 +453,10 @@ HB_FUNC( COSH ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_COSH, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -509,11 +496,10 @@ HB_FUNC( TANH ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TANH, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -536,11 +522,10 @@ HB_FUNC( RTOD ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_RTOD, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else @@ -563,11 +548,10 @@ HB_FUNC( DTOR ) int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_DTOR, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } + if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); else diff --git a/harbour/contrib/hbct/wordrepl.c b/harbour/contrib/hbct/wordrepl.c index b599762b42..a9869221b7 100644 --- a/harbour/contrib/hbct/wordrepl.c +++ b/harbour/contrib/hbct/wordrepl.c @@ -74,15 +74,10 @@ HB_FUNC( WORDREPL ) const char * pcString = hb_parc( 2 ); HB_SIZE sStrLen = hb_parclen( 2 ); const char * pcReplace = hb_parc( 3 ); - int iMode; + int iMode = hb_parldef( 4, 0 ); char * pcRet; HB_SIZE sIndex; - if( HB_ISLOG( 4 ) ) - iMode = hb_parl( 4 ); - else - iMode = 0; - pcRet = ( char * ) hb_xgrab( sStrLen + 1 ); hb_xmemcpy( pcRet, pcString, sStrLen ); @@ -94,9 +89,7 @@ HB_FUNC( WORDREPL ) HB_SIZE sReplIndex = sIndex; if( sReplIndex > ( sReplaceLen & 0xFFFFFFFE ) ) - { sReplIndex = ( sReplaceLen & 0xFFFFFFFE ); - } pc = pcString; while( ( pc = ct_at_exact_forward( pc, sStrLen - ( pc - pcString ), @@ -133,10 +126,7 @@ HB_FUNC( WORDREPL ) } /* return string */ - if( HB_ISBYREF( 2 ) ) - { - hb_storclen( pcRet, sStrLen, 2 ); - } + hb_storclen( pcRet, sStrLen, 2 ); if( iNoRet ) { @@ -144,22 +134,17 @@ HB_FUNC( WORDREPL ) hb_xfree( pcRet ); } else - { hb_retclen_buffer( pcRet, sStrLen ); - } } - else /* ( sSearchLen = hb_parclen( 1 ) ) / 2 > 0 && HB_ISCHAR( 2 ) && - ( sReplaceLen = hb_parclen( 3 ) ) / 2 > 0 */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_WORDREPL, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/contrib/hbct/wordtoch.c b/harbour/contrib/hbct/wordtoch.c index e26647177e..f60080d747 100644 --- a/harbour/contrib/hbct/wordtoch.c +++ b/harbour/contrib/hbct/wordtoch.c @@ -66,7 +66,6 @@ HB_FUNC( WORDTOCHAR ) ( sStrLen = hb_parclen( 2 ) ) / 2 > 0 && ( sReplaceLen = hb_parclen( 3 ) ) > 0 ) { - /* get parameters */ const char * pcSearch = hb_parc( 1 ); const char * pcString = hb_parc( 2 ); @@ -118,19 +117,15 @@ HB_FUNC( WORDTOCHAR ) hb_retclen( pcRet, sRetIndex + 1 ); hb_xfree( pcRet ); } - else /* ( sSearchLen = hb_parclen( 1 ) ) / 2 > 0 && - ( sStrLen = hb_parclen( 2 ) ) / 2 > 0 && - ( sReplaceLen = hb_parclen( 3 ) ) > 0 */ + else { PHB_ITEM pSubst = NULL; int iArgErrorMode = ct_getargerrormode(); if( iArgErrorMode != CT_ARGERR_IGNORE ) - { pSubst = ct_error_subst( ( HB_USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_WORDTOCHAR, NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS ); - } if( pSubst != NULL ) hb_itemReturnRelease( pSubst ); diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 27f937c556..5214aaa853 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -3815,7 +3815,9 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) IF hbmk[ _HBMK_cPLAT ] == "darwin" .AND. hbmk[ _HBMK_cCOMP ] == "gcc" /* It's to avoid warning message generated when 'long double' is used remove it if you have newer compiler version */ -/* AAdd( hbmk[ _HBMK_aOPTC ], "-Wno-long-double" ) */ +#if 0 + AAdd( hbmk[ _HBMK_aOPTC ], "-Wno-long-double" ) +#endif IF hbmk[ _HBMK_lSHARED ] AAdd( hbmk[ _HBMK_aOPTL ], "-bind_at_load" ) ENDIF