From 9b2a23a1941bf5bbdb9eb67b6cff1b28e9d9bb2a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 24 Nov 2012 19:07:23 +0000 Subject: [PATCH] 2012-11-24 20:01 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbct/charsort.c * contrib/hbct/ctstr.c * contrib/hbct/dattime3.c * contrib/hbct/token1.c + added MT support for certain C level statics * contrib/hbgt/bitflags.c * contrib/hbnf/ftattr.c * contrib/hbnf/fttext.c * contrib/hbnf/proper.c % var scope cleanups * doc/gmake.txt ! deleted obsolete reference --- harbour/ChangeLog | 16 +++++++ harbour/contrib/hbct/charsort.c | 53 ++++++++++++++--------- harbour/contrib/hbct/ctstr.c | 76 +++++++++++++++++++++++++-------- harbour/contrib/hbct/dattime3.c | 30 ++++++++++--- harbour/contrib/hbct/token1.c | 66 ++++++++++++++++++---------- harbour/contrib/hbgt/bitflags.c | 32 +++++++------- harbour/contrib/hbnf/ftattr.c | 11 ++--- harbour/contrib/hbnf/fttext.c | 66 ++++++++++++++-------------- harbour/contrib/hbnf/proper.c | 2 - harbour/doc/gmake.txt | 5 +-- 10 files changed, 230 insertions(+), 127 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 435306413d..f6dbe18d04 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -10,6 +10,22 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2012-11-24 20:01 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbct/charsort.c + * contrib/hbct/ctstr.c + * contrib/hbct/dattime3.c + * contrib/hbct/token1.c + + added MT support for certain C level statics + + * contrib/hbgt/bitflags.c + * contrib/hbnf/ftattr.c + * contrib/hbnf/fttext.c + * contrib/hbnf/proper.c + % var scope cleanups + + * doc/gmake.txt + ! deleted obsolete reference + 2012-11-24 16:48 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbgt/hbgt.hbp * contrib/hbgt/hbgt.hbx diff --git a/harbour/contrib/hbct/charsort.c b/harbour/contrib/hbct/charsort.c index b0cc03cf11..c48585589b 100644 --- a/harbour/contrib/hbct/charsort.c +++ b/harbour/contrib/hbct/charsort.c @@ -54,9 +54,17 @@ #include "ct.h" +#include "hbstack.h" + /* statics */ -static HB_SIZE s_sCompareLen; /* TODO: make this thread safe */ -static HB_SIZE s_sElementPos; /* TODO: make this thread safe */ + +typedef struct +{ + HB_SIZE sCompareLen; + HB_SIZE sElementPos; +} CT_CHARSORT, * PCT_CHARSORT; + +static HB_TSD_NEW( s_charsort, sizeof( CT_CHARSORT ), NULL, NULL ); /* qsort function */ #ifdef __IBMCPP__ @@ -66,9 +74,11 @@ static int #endif _hb_do_sortascend( const void * p1, const void * p2 ) { - return strncmp( ( const char * ) p1 + s_sElementPos, - ( const char * ) p2 + s_sElementPos, - s_sCompareLen ); + PCT_CHARSORT charsort = ( PCT_CHARSORT ) hb_stackGetTSD( &s_charsort ); + + return strncmp( ( const char * ) p1 + charsort->sElementPos, + ( const char * ) p2 + charsort->sElementPos, + charsort->sCompareLen ); } #ifdef __IBMCPP__ @@ -78,9 +88,11 @@ static int #endif _hb_do_sortdescend( const void * p1, const void * p2 ) { - return -strncmp( ( const char * ) p1 + s_sElementPos, - ( const char * ) p2 + s_sElementPos, - s_sCompareLen ); + PCT_CHARSORT charsort = ( PCT_CHARSORT ) hb_stackGetTSD( &s_charsort ); + + return -strncmp( ( const char * ) p1 + charsort->sElementPos, + ( const char * ) p2 + charsort->sElementPos, + charsort->sCompareLen ); } HB_FUNC( CHARSORT ) @@ -93,24 +105,25 @@ HB_FUNC( CHARSORT ) /* param check I */ if( HB_ISCHAR( 1 ) ) { + PCT_CHARSORT charsort = ( PCT_CHARSORT ) hb_stackGetTSD( &s_charsort ); + /* get parameters */ const char * pcString = hb_parc( 1 ); - char * pcRet; - HB_SIZE sStrLen = hb_parclen( 1 ); - HB_SIZE sElementLen, sIgnore, sSortLen; - int iDescend; - 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 ); + char * pcRet; + HB_SIZE sStrLen = hb_parclen( 1 ); + HB_SIZE sElementLen = hb_parnsdef( 2, 1 ); + HB_SIZE sIgnore = hb_parnsdef( 4, 0 ); + HB_SIZE sSortLen = hb_parnsdef( 6, sStrLen - sIgnore ); + int iDescend = hb_parldef( 7, 0 ); + + charsort->sCompareLen = hb_parnsdef( 3, sElementLen ); + charsort->sElementPos = hb_parnsdef( 5, 0 ); /* param check II */ - if( sElementLen == 0 || s_sCompareLen > sElementLen || + if( sElementLen == 0 || charsort->sCompareLen > sElementLen || sIgnore + sElementLen > sStrLen || - s_sElementPos + s_sCompareLen > sElementLen || + charsort->sElementPos + charsort->sCompareLen > sElementLen || sSortLen + sIgnore > sStrLen ) { int iArgErrorMode = ct_getargerrormode(); diff --git a/harbour/contrib/hbct/ctstr.c b/harbour/contrib/hbct/ctstr.c index 744cc92ec4..553b8fbac7 100644 --- a/harbour/contrib/hbct/ctstr.c +++ b/harbour/contrib/hbct/ctstr.c @@ -54,6 +54,28 @@ #include "ct.h" +#include "hbstack.h" + +typedef struct +{ + int iRefSwitch; + int iAtMupaSwitch; + int iAtLikeMode; + char cAtLikeChar; +} CT_STR, * PCT_STR; + +static void s_ct_str_init( void * cargo ) +{ + PCT_STR ct_str = ( PCT_STR ) cargo; + + ct_str->iRefSwitch = 0; + ct_str->iAtMupaSwitch = 0; + ct_str->iAtLikeMode = 0; + ct_str->cAtLikeChar = '?'; +} + +static HB_TSD_NEW( s_ct_str, sizeof( CT_STR ), s_ct_str_init, NULL ); + /* -------------- */ /* initialization */ /* -------------- */ @@ -223,12 +245,14 @@ const char * ct_at_charset_forward( const char * pcString, HB_SIZE sStrLen, for( pcRet = pcString; pcRet < pcStop1; pcRet++ ) { for( pcSet = pcCharSet; pcSet < pcStop2; pcSet++ ) + { if( *pcSet == *pcRet ) { if( psMatchedCharPos != NULL ) *( psMatchedCharPos ) = pcSet - pcCharSet; return pcRet; } + } } return NULL; @@ -254,12 +278,14 @@ const char * ct_at_charset_backward( const char * pcString, HB_SIZE sStrLen, for( pcRet = pcString + sStrLen - 1; pcRet >= pcString; pcRet-- ) { for( pcSet = pcCharSet; pcSet < pcStop; pcSet++ ) + { if( *pcSet == *pcRet ) { if( psMatchedCharPos != NULL ) *( psMatchedCharPos ) = pcSet - pcCharSet; return pcRet; } + } } return NULL; @@ -269,18 +295,22 @@ const char * ct_at_charset_backward( const char * pcString, HB_SIZE sStrLen, * CSETREF() stuff */ -static int s_iRefSwitch = 0; /* TODO: make this tread safe */ - void ct_setref( int iNewSwitch ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_setref(%i)", iNewSwitch ) ); - s_iRefSwitch = iNewSwitch; + + ct_str->iRefSwitch = iNewSwitch; } int ct_getref( void ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_getref()" ) ); - return s_iRefSwitch; + + return ct_str->iRefSwitch; } HB_FUNC( CSETREF ) @@ -303,18 +333,22 @@ HB_FUNC( CSETREF ) * CSETATMUPA() stuff */ -static int s_iAtMupaSwitch = 0; /* TODO: make this tread safe */ - void ct_setatmupa( int iNewSwitch ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_setatmupa(%i)", iNewSwitch ) ); - s_iAtMupaSwitch = iNewSwitch; + + ct_str->iAtMupaSwitch = iNewSwitch; } int ct_getatmupa( void ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_getatmupa()" ) ); - return s_iAtMupaSwitch; + + return ct_str->iAtMupaSwitch; } HB_FUNC( CSETATMUPA ) @@ -337,36 +371,44 @@ HB_FUNC( CSETATMUPA ) * SETATLIKE() stuff */ -static int s_iAtLikeMode = 0; /* TODO: make this tread safe */ -static char s_cAtLikeChar = '?'; /* TODO: make this tread safe */ - void ct_setatlike( int iNewMode ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_setatlike(%i)", iNewMode ) ); - s_iAtLikeMode = iNewMode; + + ct_str->iAtLikeMode = iNewMode; } int ct_getatlike( void ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_getatlike()" ) ); - return s_iAtLikeMode; + + return ct_str->iAtLikeMode; } void ct_setatlikechar( char cNewChar ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_setatlikechar(\'%c\')", cNewChar ) ); - s_cAtLikeChar = cNewChar; + + ct_str->cAtLikeChar = cNewChar; } char ct_getatlikechar( void ) { + PCT_STR ct_str = ( PCT_STR ) hb_stackGetTSD( &s_ct_str ); + HB_TRACE( HB_TR_DEBUG, ( "ct_getatlikechar()" ) ); - return s_cAtLikeChar; + + return ct_str->cAtLikeChar; } HB_FUNC( SETATLIKE ) { - hb_retni( ct_getatlike() ); /* set new mode if first parameter is CT_SETATLIKE_EXACT (==0) @@ -376,9 +418,7 @@ HB_FUNC( SETATLIKE ) int iNewMode = hb_parni( 1 ); if( iNewMode == CT_SETATLIKE_EXACT || iNewMode == CT_SETATLIKE_WILDCARD ) - { ct_setatlike( iNewMode ); - } else { int iArgErrorMode = ct_getargerrormode(); diff --git a/harbour/contrib/hbct/dattime3.c b/harbour/contrib/hbct/dattime3.c index e2901e3edb..487f48f588 100644 --- a/harbour/contrib/hbct/dattime3.c +++ b/harbour/contrib/hbct/dattime3.c @@ -58,30 +58,46 @@ #include "hbapi.h" #include "hbdate.h" +#include "hbstack.h" #if defined( HB_OS_WIN ) # include #endif #include +typedef struct +{ + /* even if these are chars, variable must be int, since we need an extra -1 */ + double dTimeSet; + double dTimeCounter; +} CT_DATE, * PCT_DATE; + +static void s_ct_date_init( void * cargo ) +{ + PCT_DATE ct_date = ( PCT_DATE ) cargo; + + ct_date->dTimeSet = 0; + ct_date->dTimeCounter = 0; +} + +static HB_TSD_NEW( s_ct_date, sizeof( CT_DATE ), s_ct_date_init, NULL ); + HB_FUNC( WAITPERIOD ) { - /* TODO: make it MT safe */ - static double s_dTimeSet = 0; - static double s_dTimeCounter = 0; + PCT_DATE ct_date = ( PCT_DATE ) hb_stackGetTSD( &s_ct_date ); double d = hb_dateSeconds(); if( hb_pcount() > 0 ) { - s_dTimeSet = d; - s_dTimeCounter = d + hb_parnd( 1 ) / 100.0; + ct_date->dTimeSet = d; + ct_date->dTimeCounter = d + hb_parnd( 1 ) / 100.0; } - if( d < s_dTimeSet ) + if( d < ct_date->dTimeSet ) d += 86400.0; - hb_retl( d < s_dTimeCounter ); + hb_retl( d < ct_date->dTimeCounter ); } static HB_BOOL _hb_timeValid( const char * szTime, HB_SIZE nLen, int * piDecode ) diff --git a/harbour/contrib/hbct/token1.c b/harbour/contrib/hbct/token1.c index 361183ea13..ac6b58d6f2 100644 --- a/harbour/contrib/hbct/token1.c +++ b/harbour/contrib/hbct/token1.c @@ -60,15 +60,31 @@ #include "ct.h" +#include "hbstack.h" + /* static const data */ static const char * sc_pcSeparatorStr = "\x00" "\x09" "\x0A" "\x0C" "\x1A" "\x20" "\x8A" "\x8C" ",.;:!\?/\\<>()#&%+-*"; static const HB_SIZE sc_sSeparatorStrLen = 26; /* static data */ -/* even if these are chars, variable must be int, since we need an extra -1 */ -static int s_iPreSeparator = -1; /* TODO: make this threadsafe */ -static int s_iPostSeparator = -1; /* TODO: make this threadsafe */ + +typedef struct +{ + /* even if these are chars, variable must be int, since we need an extra -1 */ + int iPreSeparator; + int iPostSeparator; +} CT_TOKEN, * PCT_TOKEN; + +static void s_ct_token_init( void * cargo ) +{ + PCT_TOKEN ct_token = ( PCT_TOKEN ) cargo; + + ct_token->iPreSeparator = -1; + ct_token->iPostSeparator = -1; +} + +static HB_TSD_NEW( s_ct_token, sizeof( CT_TOKEN ), s_ct_token_init, NULL ); /* defines */ #define DO_TOKEN1_TOKEN 0 @@ -80,13 +96,15 @@ static int s_iPostSeparator = -1; /* TODO: make this threadsafe */ /* helper function for the token function group I */ static void do_token1( int iSwitch ) { + PCT_TOKEN ct_token = ( PCT_TOKEN ) hb_stackGetTSD( &s_ct_token ); + int iParamCheck = 0; int iNoRef = ct_getref() && HB_ISBYREF( 1 ); switch( iSwitch ) { case DO_TOKEN1_TOKEN: - s_iPreSeparator = s_iPostSeparator = -1; + ct_token->iPreSeparator = ct_token->iPostSeparator = -1; /* no "break" here !! */ case DO_TOKEN1_ATTOKEN: case DO_TOKEN1_NUMTOKEN: @@ -183,11 +201,11 @@ static void do_token1( int iSwitch ) pcSeparatorStr, sSeparatorStrLen, &sMatchedPos ); if( iSwitch == DO_TOKEN1_TOKEN ) { - s_iPreSeparator = s_iPostSeparator; + ct_token->iPreSeparator = ct_token->iPostSeparator; if( sMatchedPos < sSeparatorStrLen ) - s_iPostSeparator = pcSeparatorStr[ sMatchedPos ]; + ct_token->iPostSeparator = pcSeparatorStr[ sMatchedPos ]; else - s_iPostSeparator = -1; + ct_token->iPostSeparator = -1; } nSkipCnt++; } @@ -206,13 +224,13 @@ static void do_token1( int iSwitch ) hb_retc_null(); if( HB_ISBYREF( 5 ) ) { - cRet = ( char ) s_iPreSeparator; - hb_storclen( &cRet, ( s_iPreSeparator != -1 ? 1 : 0 ), 5 ); + cRet = ( char ) ct_token->iPreSeparator; + hb_storclen( &cRet, ( ct_token->iPreSeparator != -1 ? 1 : 0 ), 5 ); } if( HB_ISBYREF( 6 ) ) { - cRet = ( char ) s_iPostSeparator; - hb_storclen( &cRet, ( s_iPostSeparator != -1 ? 1 : 0 ), 6 ); + cRet = ( char ) ct_token->iPostSeparator; + hb_storclen( &cRet, ( ct_token->iPostSeparator != -1 ? 1 : 0 ), 6 ); } break; } @@ -314,13 +332,13 @@ static void do_token1( int iSwitch ) if( HB_ISBYREF( 5 ) ) { - cRet = ( char ) s_iPreSeparator; - hb_storclen( &cRet, ( s_iPreSeparator != -1 ? 1 : 0 ), 5 ); + cRet = ( char ) ct_token->iPreSeparator; + hb_storclen( &cRet, ( ct_token->iPreSeparator != -1 ? 1 : 0 ), 5 ); } if( HB_ISBYREF( 6 ) ) { - cRet = ( char ) s_iPostSeparator; - hb_storclen( &cRet, ( s_iPostSeparator != -1 ? 1 : 0 ), 6 ); + cRet = ( char ) ct_token->iPostSeparator; + hb_storclen( &cRet, ( ct_token->iPostSeparator != -1 ? 1 : 0 ), 6 ); } break; } @@ -362,13 +380,13 @@ static void do_token1( int iSwitch ) if( HB_ISBYREF( 5 ) ) { - cRet = ( char ) s_iPreSeparator; - hb_storclen( &cRet, ( s_iPreSeparator != -1 ? 1 : 0 ), 5 ); + cRet = ( char ) ct_token->iPreSeparator; + hb_storclen( &cRet, ( ct_token->iPreSeparator != -1 ? 1 : 0 ), 5 ); } if( HB_ISBYREF( 6 ) ) { - cRet = ( char ) s_iPostSeparator; - hb_storclen( &cRet, ( s_iPostSeparator != -1 ? 1 : 0 ), 6 ); + cRet = ( char ) ct_token->iPostSeparator; + hb_storclen( &cRet, ( ct_token->iPostSeparator != -1 ? 1 : 0 ), 6 ); } if( iArgErrorMode != CT_ARGERR_IGNORE ) @@ -457,14 +475,16 @@ HB_FUNC( TOKENUPPER ) HB_FUNC( TOKENSEP ) { + PCT_TOKEN ct_token = ( PCT_TOKEN ) hb_stackGetTSD( &s_ct_token ); + char cRet; if( hb_parl( 1 ) ) { /* return the separator char BEHIND the last token */ - if( s_iPostSeparator != -1 ) + if( ct_token->iPostSeparator != -1 ) { - cRet = ( char ) s_iPostSeparator; + cRet = ( char ) ct_token->iPostSeparator; hb_retclen( &cRet, 1 ); } else @@ -473,9 +493,9 @@ HB_FUNC( TOKENSEP ) else { /* return the separator char BEFORE the last token */ - if( s_iPreSeparator != -1 ) + if( ct_token->iPreSeparator != -1 ) { - cRet = ( char ) s_iPreSeparator; + cRet = ( char ) ct_token->iPreSeparator; hb_retclen( &cRet, 1 ); } else diff --git a/harbour/contrib/hbgt/bitflags.c b/harbour/contrib/hbgt/bitflags.c index 513cb2b603..f4b1a0152c 100644 --- a/harbour/contrib/hbgt/bitflags.c +++ b/harbour/contrib/hbgt/bitflags.c @@ -56,18 +56,18 @@ HB_FUNC( GT_SETFLAG ) char * FlagString = hb_itemGetC( hb_param( 1, HB_IT_STRING ) ); unsigned StartBit = hb_parnidef( 2, 1 ); unsigned EndBit = hb_parnidef( 3, 1 ); - unsigned BitCount; - unsigned BitPointer; - unsigned BytePointer; EndBit = HB_MAX( StartBit, EndBit ); if( StartBit > 0 && EndBit <= ( hb_parclen( 1 ) * 8 ) ) { + unsigned BitCount; + for( BitCount = StartBit; BitCount <= EndBit; BitCount++ ) { - BitPointer = BitCount % 8; - BytePointer = ( unsigned ) ( BitCount / 8 ); + unsigned BitPointer = BitCount % 8; + unsigned BytePointer = ( unsigned ) ( BitCount / 8 ); + if( ! BitPointer ) { BitPointer = 8; @@ -89,18 +89,18 @@ HB_FUNC( GT_CLRFLAG ) char * FlagString = hb_itemGetC( hb_param( 1, HB_IT_STRING ) ); unsigned StartBit = hb_parnidef( 2, 1 ); unsigned EndBit = hb_parnidef( 3, 1 ); - unsigned BitCount; - unsigned BitPointer; - unsigned BytePointer; EndBit = HB_MAX( StartBit, EndBit ); if( StartBit > 0 && EndBit <= ( hb_parclen( 1 ) * 8 ) ) { + unsigned BitCount; + for( BitCount = StartBit; BitCount <= EndBit; BitCount++ ) { - BitPointer = BitCount % 8; - BytePointer = ( unsigned ) ( BitCount / 8 ); + unsigned BitPointer = BitCount % 8; + unsigned BytePointer = ( unsigned ) ( BitCount / 8 ); + if( ! BitPointer ) { BitPointer = 8; @@ -121,15 +121,15 @@ HB_FUNC( GT_ISFLAG ) if( HB_ISCHAR( 1 ) ) { - unsigned Bit = hb_parnidef( 2, 1 ); - unsigned BitPointer; - unsigned BytePointer; - const char * FlagString = hb_parc( 1 ); + unsigned Bit = hb_parnidef( 2, 1 ); if( Bit > 0 && Bit <= ( hb_parclen( 1 ) * 8 ) ) { - BitPointer = Bit % 8; - BytePointer = ( unsigned ) ( Bit / 8 ); + const char * FlagString = hb_parc( 1 ); + + unsigned BitPointer = Bit % 8; + unsigned BytePointer = ( unsigned ) ( Bit / 8 ); + if( ! BitPointer ) { BitPointer = 8; diff --git a/harbour/contrib/hbnf/ftattr.c b/harbour/contrib/hbnf/ftattr.c index 942145f586..f3a8074825 100644 --- a/harbour/contrib/hbnf/ftattr.c +++ b/harbour/contrib/hbnf/ftattr.c @@ -35,10 +35,6 @@ HB_FUNC( FT_SAVEATT ) int iBottom = hb_parnidef( 3, iMaxRow ); int iRight = hb_parnidef( 4, iMaxRow ); - HB_SIZE nSize; - char * pBuffer; - char * pAttrib; - if( iTop < 0 ) iTop = 0; if( iLeft < 0 ) @@ -50,6 +46,10 @@ HB_FUNC( FT_SAVEATT ) if( iTop <= iBottom && iLeft <= iRight ) { + HB_SIZE nSize; + char * pBuffer; + char * pAttrib; + nSize = ( iBottom - iTop + 1 ) * ( iRight - iLeft + 1 ); pBuffer = pAttrib = ( char * ) hb_xgrab( nSize + 1 ); while( iTop <= iBottom ) @@ -106,7 +106,6 @@ HB_FUNC( FT_RESTATT ) int iMaxCol = hb_gtMaxCol(); int iBottom = hb_parnidef( 3, iMaxRow ); int iRight = hb_parnidef( 4, iMaxCol ); - const char * pAttrib = hb_parc( 5 ); if( iTop < 0 ) iTop = 0; @@ -119,6 +118,8 @@ HB_FUNC( FT_RESTATT ) if( iTop <= iBottom && iLeft <= iRight ) { + const char * pAttrib = hb_parc( 5 ); + hb_gtDispBegin(); while( nLen && iTop <= iBottom ) diff --git a/harbour/contrib/hbnf/fttext.c b/harbour/contrib/hbnf/fttext.c index cd8377a49a..f02754a8d3 100644 --- a/harbour/contrib/hbnf/fttext.c +++ b/harbour/contrib/hbnf/fttext.c @@ -176,14 +176,14 @@ typedef struct HB_ERRCODE error[ TEXT_WORKAREAS ]; } FT_TEXT, * PFT_TEXT; -static void s_fttext_init_init( void * cargo ) +static void s_ft_text_init( void * cargo ) { PFT_TEXT ft_text = ( PFT_TEXT ) cargo; ft_text->area = 0; } -static HB_TSD_NEW( s_fttext, sizeof( FT_TEXT ), s_fttext_init_init, NULL ); +static HB_TSD_NEW( s_ft_text, sizeof( FT_TEXT ), s_ft_text_init, NULL ); /* routines internal to this module */ static HB_ISIZ _findeol( char * buf, HB_ISIZ buf_len ); @@ -196,7 +196,7 @@ static HB_BOOL _writeeol( HB_FHANDLE fhnd ); HB_FUNC( FT_FOFFSET ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); hb_retnint( ft_text->offset[ ft_text->area ] ); } @@ -207,14 +207,14 @@ HB_FUNC( FT_FOFFSET ) HB_FUNC( FT_FUSE ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); - - int attr = hb_parnidef( 2, FO_READWRITE | FO_DENYNONE ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); ft_text->error[ ft_text->area ] = 0; if( HB_ISCHAR( 1 ) ) { + int attr = hb_parnidef( 2, FO_READWRITE | FO_DENYNONE ); + ft_text->handles[ ft_text->area ] = hb_fsOpen( hb_parc( 1 ), ( HB_USHORT ) attr ); if( ft_text->handles[ ft_text->area ] <= 0 ) ft_text->error[ ft_text->area ] = hb_fsError(); @@ -243,14 +243,14 @@ HB_FUNC( FT_FUSE ) HB_FUNC( FT_FSELECT ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); int oldarea = ft_text->area + 1; - int newArea; if( HB_ISNUM( 1 ) ) { - newArea = hb_parni( 1 ); + int newArea = hb_parni( 1 ); + if( newArea <= TEXT_WORKAREAS ) { if( newArea == 0 ) @@ -273,7 +273,7 @@ HB_FUNC( FT_FSELECT ) HB_FUNC( FT_FGOTOP ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); ft_text->error[ ft_text->area ] = 0; ft_text->offset[ ft_text->area ] = 0L; @@ -284,21 +284,21 @@ HB_FUNC( FT_FGOTOP ) HB_FUNC( FT_FERROR ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); hb_retni( ft_text->error[ ft_text->area ] ); } HB_FUNC( FT_FRECNO ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); hb_retnl( ft_text->recno[ ft_text->area ] ); } HB_FUNC( FT_FGOBOT ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); ft_text->error[ ft_text->area ] = 0; if( ! ft_text->last_rec[ ft_text->area ] ) @@ -332,7 +332,7 @@ HB_FUNC( FT_FSKIP ) Returns a long indicating the number of records skipped */ static long _ft_skip( long iRecs ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); HB_ISIZ iByteCount; HB_ISIZ iBytesRead, iBytesRemaining; @@ -519,7 +519,7 @@ static long _ft_skip( long iRecs ) HB_FUNC( FT_FREADLN ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); HB_ISIZ iByteCount; HB_ISIZ iBytesRead; @@ -545,7 +545,7 @@ HB_FUNC( FT_FREADLN ) HB_FUNC( FT_FDELETE ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); int iBytesRead; HB_FOFFSET srcPtr; @@ -601,7 +601,7 @@ HB_FUNC( FT_FDELETE ) HB_FUNC( FT_FINSERT ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); int no_lines = hb_parnidef( 1, 1 ); HB_ISIZ no_bytes = no_lines * 2; @@ -625,7 +625,7 @@ HB_FUNC( FT_FINSERT ) HB_FUNC( FT_FAPPEND ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); int no_lines = hb_parnidef( 1, 1 ); HB_ISIZ iRead; @@ -666,7 +666,9 @@ HB_FUNC( FT_FAPPEND ) } ft_text->recno[ ft_text->area ]++; ft_text->offset[ ft_text->area ] = hb_fsSeekLarge( ft_text->handles[ ft_text->area ], 0, FS_RELATIVE ); -/* no_lines--; !Harbour FIX! */ +#if 0 + no_lines--; /* !Harbour FIX! */ +#endif } if( ! ft_text->error[ ft_text->area ] ) @@ -687,16 +689,12 @@ HB_FUNC( FT_FAPPEND ) HB_FUNC( FT_FWRITELN ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); const char * theData = hb_parc( 1 ); HB_ISIZ iDataLen = hb_parclen( 1 ); HB_BOOL bInsert = hb_parl( 2 ); int err; - HB_ISIZ iLineLen = 0; - HB_ISIZ iRead, iEOL; - - char * buffer; /* position file pointer to insertion point */ hb_fsSeekLarge( ft_text->handles[ ft_text->area ], ft_text->offset[ ft_text->area ], FS_SET ); @@ -715,7 +713,10 @@ HB_FUNC( FT_FWRITELN ) else { /* overwrite mode, determine how many bytes over/under */ - buffer = ( char * ) hb_xgrab( BUFFSIZE ); + char * buffer = ( char * ) hb_xgrab( BUFFSIZE ); + + HB_ISIZ iLineLen = 0; + HB_ISIZ iRead, iEOL; /* find length of current line, loop if longer than buffer */ do @@ -762,7 +763,7 @@ HB_FUNC_TRANSLATE( FT_FWRITEL, FT_FWRITELN ) HB_FUNC( FT_FLASTRE ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); long cur_rec; HB_FOFFSET cur_offset; @@ -779,21 +780,21 @@ HB_FUNC( FT_FLASTRE ) HB_FUNC( FT_FEOF ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); hb_retl( ft_text->isEof[ ft_text->area ] ); } HB_FUNC( FT_FBOF ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); hb_retl( ft_text->isBof[ ft_text->area ] ); } HB_FUNC( FT_FGOTO ) { - PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_fttext ); + PFT_TEXT ft_text = ( PFT_TEXT ) hb_stackGetTSD( &s_ft_text ); long target = hb_parnl( 1 ); @@ -968,7 +969,9 @@ static int _ins_buff( PFT_TEXT ft_text, HB_ISIZ iLen ) ft_text->error[ ft_text->area ] = hb_fsError(); break; } - /* WriteLen = SaveLen; */ +#if 0 + WriteLen = SaveLen; +#endif /* swap buffers */ SaveBuff = WriteBuff; @@ -1066,8 +1069,7 @@ static int _writeLine( PFT_TEXT ft_text, const char * theData, HB_SIZE iDataLen err = 1; ft_text->error[ ft_text->area ] = hb_fsError(); } - else - if( ! _writeeol( ft_text->handles[ ft_text->area ] ) ) + else if( ! _writeeol( ft_text->handles[ ft_text->area ] ) ) { err = 1; ft_text->error[ ft_text->area ] = hb_fsError(); diff --git a/harbour/contrib/hbnf/proper.c b/harbour/contrib/hbnf/proper.c index f8e81090db..6cc42f8870 100644 --- a/harbour/contrib/hbnf/proper.c +++ b/harbour/contrib/hbnf/proper.c @@ -91,9 +91,7 @@ HB_FUNC( FT_PROPER ) for( i = 0; i < iLen - 2; i++ ) { if( cStr[ i ] == 'M' && cStr[ i + 1 ] == 'c' ) - { cDst[ i + 2 ] = _ftToUpper( cDst[ i + 2 ] ); - } } } diff --git a/harbour/doc/gmake.txt b/harbour/doc/gmake.txt index ee10d4b55f..98cc9e77ac 100644 --- a/harbour/doc/gmake.txt +++ b/harbour/doc/gmake.txt @@ -181,13 +181,10 @@ For GCC on OS/2 for VIO mode: HB_PLATFORM os2 HB_COMPILER gcc -For Borland C++ 5.5 +For Borland C++ HB_PLATFORM win HB_COMPILER bcc -For Borland C++ 3.x - HB_PLATFORM dos - For DJGPP (GCC port for MS-DOS) HB_PLATFORM dos HB_COMPILER djgpp