From f674969aba1e69fefa270964b6b7d35c9ca20abc Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 10 Dec 2009 09:42:34 +0000 Subject: [PATCH] 2009-12-10 10:42 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/xhb/fparse.c * pacified BCC warning * harbour/src/rtl/base64c.c * harbour/src/rtl/diskspac.c * harbour/src/rtl/filesys.c * harbour/src/rtl/hbproces.c * harbour/src/rtl/gtos2/gtos2.c * harbour/src/rdd/dbffpt/dbffpt1.c * harbour/contrib/xhb/freadlin.c * harbour/contrib/xhb/txtline.c * harbour/contrib/hbbtree/hb_btree.c * harbour/contrib/rddsql/sqlbase.c * harbour/contrib/rddsql/sddodbc/odbcdd.c * pacified OpenWatcom C warnings * harbour/include/hbatomic.h % rewritten OpenWatcom atomic ASM macros. Now they precisely informs compiler about used and modified registered and also force passing arguments in strictly defined what simplify ASM code. --- harbour/ChangeLog | 23 +++++++++++++ harbour/contrib/hbbtree/hb_btree.c | 2 +- harbour/contrib/rddsql/sddodbc/odbcdd.c | 2 +- harbour/contrib/rddsql/sqlbase.c | 4 +-- harbour/contrib/xhb/fparse.c | 2 +- harbour/contrib/xhb/freadlin.c | 22 ++++++------- harbour/contrib/xhb/txtline.c | 2 +- harbour/include/hbatomic.h | 44 +++++++++---------------- harbour/src/rdd/dbffpt/dbffpt1.c | 8 ++--- harbour/src/rtl/base64c.c | 4 +-- harbour/src/rtl/diskspac.c | 2 ++ harbour/src/rtl/filesys.c | 4 +++ harbour/src/rtl/gtos2/gtos2.c | 2 +- harbour/src/rtl/hbproces.c | 8 +++-- 14 files changed, 74 insertions(+), 55 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 78695e6d27..41d1c7a69c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,29 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-10 10:42 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/xhb/fparse.c + * pacified BCC warning + + * harbour/src/rtl/base64c.c + * harbour/src/rtl/diskspac.c + * harbour/src/rtl/filesys.c + * harbour/src/rtl/hbproces.c + * harbour/src/rtl/gtos2/gtos2.c + * harbour/src/rdd/dbffpt/dbffpt1.c + * harbour/contrib/xhb/freadlin.c + * harbour/contrib/xhb/txtline.c + * harbour/contrib/hbbtree/hb_btree.c + * harbour/contrib/rddsql/sqlbase.c + * harbour/contrib/rddsql/sddodbc/odbcdd.c + * pacified OpenWatcom C warnings + + * harbour/include/hbatomic.h + % rewritten OpenWatcom atomic ASM macros. + Now they precisely informs compiler about used and modified + registered and also force passing arguments in strictly defined + what simplify ASM code. + 2009-12-10 02:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/generator/hbqtgen.prg % Changed to only save files which have indeed changed diff --git a/harbour/contrib/hbbtree/hb_btree.c b/harbour/contrib/hbbtree/hb_btree.c index 2837f32c49..d8741adf3f 100644 --- a/harbour/contrib/hbbtree/hb_btree.c +++ b/harbour/contrib/hbbtree/hb_btree.c @@ -421,7 +421,7 @@ static void ioBufferAlloc( struct hb_BTree * pBTree, ULONG ulBuffers ) { ioBuffer_T *thisptr = NULL, *last = NULL; - if ( ulBuffers <= 0 ) + if ( ulBuffers == 0 ) ulBuffers = 1; if ( ulBuffers > 1 || GETFLAG( pBTree, IsInMemory ) ) diff --git a/harbour/contrib/rddsql/sddodbc/odbcdd.c b/harbour/contrib/rddsql/sddodbc/odbcdd.c index e6dcc452a7..03c71dbd9e 100644 --- a/harbour/contrib/rddsql/sddodbc/odbcdd.c +++ b/harbour/contrib/rddsql/sddodbc/odbcdd.c @@ -672,7 +672,7 @@ static HB_ERRCODE odbcGoTo( SQLBASEAREAP pArea, ULONG ulRecNo ) pArea->pRowFlags[ pArea->ulRecCount ] = SQLDD_FLAG_CACHED; } - if ( ulRecNo <= 0 || ulRecNo > pArea->ulRecCount ) + if ( ulRecNo == 0 || ulRecNo > pArea->ulRecCount ) { pArea->pRecord = pArea->pRow[ 0 ]; pArea->bRecordFlags = pArea->pRowFlags[ 0 ]; diff --git a/harbour/contrib/rddsql/sqlbase.c b/harbour/contrib/rddsql/sqlbase.c index 690bc02a6c..91160ab12c 100644 --- a/harbour/contrib/rddsql/sqlbase.c +++ b/harbour/contrib/rddsql/sqlbase.c @@ -188,7 +188,7 @@ static HB_ERRCODE sddClose( SQLBASEAREAP pArea ) static HB_ERRCODE sddGoTo( SQLBASEAREAP pArea, ULONG ulRecNo ) { - if ( ulRecNo <= 0 || ulRecNo > pArea->ulRecCount ) + if ( ulRecNo == 0 || ulRecNo > pArea->ulRecCount ) { pArea->pRecord = pArea->pRow[ 0 ]; pArea->bRecordFlags = pArea->pRowFlags[ 0 ]; @@ -786,7 +786,7 @@ static HB_ERRCODE sqlbaseOpen( SQLBASEAREAP pArea, LPDBOPENINFO pOpenInfo ) pArea->ulConnection = pOpenInfo->ulConnection ? pOpenInfo->ulConnection : s_ulConnectionCurrent; - if ( pArea->ulConnection <= 0 || pArea->ulConnection > s_ulConnectionCount || + if ( pArea->ulConnection == 0 || pArea->ulConnection > s_ulConnectionCount || ! s_pConnection[ pArea->ulConnection - 1 ].hConnection ) { hb_errRT_SQLBASE( EG_OPEN, ESQLDD_NOTCONNECTED, "Not connected", NULL ); diff --git a/harbour/contrib/xhb/fparse.c b/harbour/contrib/xhb/fparse.c index 76486bf32b..0d16a80f1a 100644 --- a/harbour/contrib/xhb/fparse.c +++ b/harbour/contrib/xhb/fparse.c @@ -669,7 +669,7 @@ HB_FUNC( FCHARCOUNT ) /*----------------------------------------------------------------------------*/ HB_FUNC( FPARSELINE ) { - PHB_ITEM pArray = NULL; + PHB_ITEM pArray; int iWords = 0; const char * szText; diff --git a/harbour/contrib/xhb/freadlin.c b/harbour/contrib/xhb/freadlin.c index 577f418843..003d585434 100644 --- a/harbour/contrib/xhb/freadlin.c +++ b/harbour/contrib/xhb/freadlin.c @@ -58,14 +58,14 @@ #define READING_BLOCK 4096 -char * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, const char ** Term, int * iTermSizes, USHORT iTerms, BOOL * bFound, BOOL * bEOF ) +char * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, const char ** Term, int * iTermSizes, int iTerms, BOOL * bFound, BOOL * bEOF ) { - USHORT uiPosTerm = 0, iPos, uiPosition; - USHORT nTries; + int iPosTerm = 0, iPos, iPosition; + int nTries; LONG lRead = 0, lOffset, lSize; char * pBuff; - HB_TRACE(HB_TR_DEBUG, ("hb_fsReadLine(%p, %ld, %p, %p, %hu, %i, %i)", ( void * ) ( HB_PTRDIFF ) hFileHandle, *plBuffLen, Term, iTermSizes, iTerms, *bFound, *bEOF )); + HB_TRACE(HB_TR_DEBUG, ("hb_fsReadLine(%p, %ld, %p, %p, %i, %i, %i)", ( void * ) ( HB_PTRDIFF ) hFileHandle, *plBuffLen, Term, iTermSizes, iTerms, *bFound, *bEOF )); *bFound = FALSE; *bEOF = FALSE; @@ -97,16 +97,16 @@ char * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, const char ** Te { for( iPos = 0; iPos < lRead; iPos++ ) { - for( uiPosTerm = 0; uiPosTerm < iTerms; uiPosTerm++ ) + for( iPosTerm = 0; iPosTerm < iTerms; iPosTerm++ ) { /* Compare with the LAST terminator byte */ - if( pBuff[lOffset+iPos] == Term[uiPosTerm][iTermSizes[uiPosTerm]-1] && (iTermSizes[uiPosTerm]-1) <= (iPos+lOffset) ) + if( pBuff[lOffset+iPos] == Term[iPosTerm][iTermSizes[iPosTerm]-1] && (iTermSizes[iPosTerm]-1) <= (iPos+lOffset) ) { *bFound = TRUE; - for(uiPosition=0; uiPosition < (iTermSizes[uiPosTerm]-1); uiPosition++) + for(iPosition=0; iPosition < (iTermSizes[iPosTerm]-1); iPosition++) { - if(Term[uiPosTerm][uiPosition] != pBuff[ lOffset+(iPos-iTermSizes[uiPosTerm])+uiPosition+1 ]) + if(Term[iPosTerm][iPosition] != pBuff[ lOffset+(iPos-iTermSizes[iPosTerm])+iPosition+1 ]) { *bFound = FALSE; break; @@ -124,7 +124,7 @@ char * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, const char ** Te if( *bFound ) { - *plBuffLen = lOffset + iPos - iTermSizes[ uiPosTerm ] + 1; + *plBuffLen = lOffset + iPos - iTermSizes[ iPosTerm ] + 1; pBuff[ *plBuffLen ] = '\0'; @@ -170,7 +170,7 @@ HB_FUNC( HB_FREADLINE ) char * pBuffer; int * iTermSizes; LONG lSize = hb_parnl( 4 ); - USHORT i, iTerms; + int i, iTerms; BOOL bFound, bEOF; if( ( !HB_ISBYREF( 2 ) ) || ( !HB_ISNUM( 1 ) ) ) @@ -188,7 +188,7 @@ HB_FUNC( HB_FREADLINE ) if( HB_ISARRAY( 3 ) ) { pTerm1 = hb_param( 3, HB_IT_ARRAY ); - iTerms = ( USHORT ) hb_arrayLen( pTerm1 ); + iTerms = ( int ) hb_arrayLen( pTerm1 ); if( iTerms <= 0 ) { diff --git a/harbour/contrib/xhb/txtline.c b/harbour/contrib/xhb/txtline.c index 2c472af484..c50ebf3336 100644 --- a/harbour/contrib/xhb/txtline.c +++ b/harbour/contrib/xhb/txtline.c @@ -70,7 +70,7 @@ void hb_readLine( const char * szText, ULONG ulTextLen, ULONG uiLineLen, USHORT ulCurrCol = 0; ulLastBlk = 0; - if( ulTextLen <= 0 ) + if( ulTextLen == 0 ) { *lEnd = -1; *ulEndOffset = 0; diff --git a/harbour/include/hbatomic.h b/harbour/include/hbatomic.h index 9c49924f65..f8e4713e27 100644 --- a/harbour/include/hbatomic.h +++ b/harbour/include/hbatomic.h @@ -293,30 +293,22 @@ HB_EXTERN_BEGIN # endif /* x86 */ -#elif defined( __WATCOMC__ ) && defined( __cplusplus ) +#elif defined( __WATCOMC__ ) # if defined( HB_CPU_X86 ) || defined( HB_CPU_X86_64 ) # if HB_COUNTER_SIZE == 4 - static inline void hb_atomic_inc32( volatile int * p ) - { - _asm { - mov eax, p - lock inc dword ptr [eax] - } - } + static inline void hb_atomic_inc32( volatile int * p ); + #pragma aux hb_atomic_inc32 = \ + "lock inc dword ptr [eax]" \ + parm [ eax ] modify exact [] ; - static inline int hb_atomic_dec32( volatile int * p ) - { - unsigned char c; - _asm { - mov eax, p - lock dec dword ptr [eax] - setne c - } - return c; - } + static inline unsigned char hb_atomic_dec32( volatile int * p ); + #pragma aux hb_atomic_dec32 = \ + "lock dec dword ptr [eax]", \ + "setne al" \ + parm [ eax ] value [ al ] modify exact [ al ] ; # define HB_ATOM_INC( p ) ( hb_atomic_inc32( ( volatile int * ) (p) ) ) # define HB_ATOM_DEC( p ) ( hb_atomic_dec32( ( volatile int * ) (p) ) ) @@ -329,17 +321,11 @@ HB_EXTERN_BEGIN # endif - static inline int hb_spinlock_trylock( volatile int * p ) - { - int i = 1; - _asm { - mov eax, i - mov edx, p - xchg eax, dword ptr [edx] - mov i, eax - } - return i; - } + static inline int hb_spinlock_trylock( volatile int * p ); + #pragma aux hb_spinlock_trylock = \ + "mov eax, 1", \ + "xchg eax, dword ptr [edx]" \ + parm [ edx ] value [ eax ] modify exact [ eax ] ; static inline void hb_spinlock_acquire( volatile int * l ) { diff --git a/harbour/src/rdd/dbffpt/dbffpt1.c b/harbour/src/rdd/dbffpt/dbffpt1.c index e9553836e2..7b32e3c8a9 100644 --- a/harbour/src/rdd/dbffpt/dbffpt1.c +++ b/harbour/src/rdd/dbffpt/dbffpt1.c @@ -963,7 +963,7 @@ static ULONG hb_fptGetMemoLen( FPTAREAP pArea, USHORT uiIndex ) { ulLen = hb_fileReadAt( pArea->pMemoFile, pBlock, DBT_DEFBLOCKSIZE, fOffset ); fOffset += ulLen; - if( ulLen <= 0 ) + if( ulLen == 0 ) break; u = 0; while( u < ulLen && pBlock[ u ] != 0x1A ) @@ -2364,7 +2364,7 @@ static HB_ERRCODE hb_fptCopyToRawFile( PHB_FILE pSrc, HB_FOFFSET from, ulRead = hb_fileReadAt( pSrc, pBuffer, ( ULONG ) HB_MIN( ( HB_FOFFSET ) ulBufSize, size - written ), from + written ); - if( ulRead <= 0 ) + if( ulRead == 0 ) errCode = EDBF_READ; else if( hb_fsWriteLarge( hDst, pBuffer, ulRead ) != ulRead ) errCode = EDBF_WRITE; @@ -2398,7 +2398,7 @@ static HB_ERRCODE hb_fptCopyToFile( PHB_FILE pSrc, HB_FOFFSET from, ulRead = hb_fileReadAt( pSrc, pBuffer, ( ULONG ) HB_MIN( ( HB_FOFFSET ) ulBufSize, size - written ), from + written ); - if( ulRead <= 0 ) + if( ulRead == 0 ) errCode = EDBF_READ; else if( hb_fileWriteAt( pDst, pBuffer, ulRead, to + written ) != ulRead ) @@ -2833,7 +2833,7 @@ static HB_ERRCODE hb_fptWriteMemo( FPTAREAP pArea, ULONG ulBlock, ULONG ulSize, { ulRead = hb_fsReadLarge( hFile, bBuffer, HB_MIN( ulBufSize, ulLen - ulWritten ) ); - if( ulRead <= 0 ) + if( ulRead == 0 ) errCode = EDBF_READ; else if( hb_fileWriteAt( pArea->pMemoFile, bBuffer, ulRead, fOffset ) != ulRead ) diff --git a/harbour/src/rtl/base64c.c b/harbour/src/rtl/base64c.c index 519d29a5b1..a8d44bc4f8 100644 --- a/harbour/src/rtl/base64c.c +++ b/harbour/src/rtl/base64c.c @@ -71,7 +71,7 @@ HB_FUNC( HB_BASE64ENCODE ) x = *s++; *p++ = s_b64chars[ ( x >> 2 ) & 0x3F ]; - if( len-- <= 0 ) + if( len-- == 0 ) { *p++ = s_b64chars[ ( x << 4 ) & 0x3F ]; *p++ = '='; @@ -81,7 +81,7 @@ HB_FUNC( HB_BASE64ENCODE ) y = *s++; *p++ = s_b64chars[ ( ( x << 4 ) | ( ( y >> 4 ) & 0x0F ) ) & 0x3F ]; - if( len-- <= 0 ) + if( len-- == 0 ) { *p++ = s_b64chars[ ( y << 2 ) & 0x3F ]; *p++ = '='; diff --git a/harbour/src/rtl/diskspac.c b/harbour/src/rtl/diskspac.c index f74f7eb6dd..bb19138e6c 100644 --- a/harbour/src/rtl/diskspac.c +++ b/harbour/src/rtl/diskspac.c @@ -202,6 +202,8 @@ HB_FUNC( DISKSPACE ) { #if defined( __WATCOMC__ ) || defined( __CEGCC__ ) int iTODO; + + bError = FALSE; #else #if defined( HB_OS_DARWIN ) struct statfs st; diff --git a/harbour/src/rtl/filesys.c b/harbour/src/rtl/filesys.c index fc3cae9620..4ddec6cf2f 100644 --- a/harbour/src/rtl/filesys.c +++ b/harbour/src/rtl/filesys.c @@ -615,7 +615,11 @@ HB_FHANDLE hb_fsPOpen( const char * pFilename, const char * pMode ) close( hNullHandle ); setuid( getuid() ); setgid( getgid() ); +#if defined( __WATCOMC__ ) + execv( "/bin/sh", argv ); +#else execv( "/bin/sh", ( char ** ) argv ); +#endif exit(1); } } diff --git a/harbour/src/rtl/gtos2/gtos2.c b/harbour/src/rtl/gtos2/gtos2.c index 3b105b6636..00424ecb82 100644 --- a/harbour/src/rtl/gtos2/gtos2.c +++ b/harbour/src/rtl/gtos2/gtos2.c @@ -681,7 +681,7 @@ static void hb_gt_os2_Tone( PHB_GT pGT, double dFrequency, double dDuration ) USHORT temp = ( USHORT ) HB_MIN( HB_MAX( 0, dDuration ), USHRT_MAX ); dDuration -= temp; - if( temp <= 0 ) + if( temp == 0 ) { /* Ensure that the loop gets terminated when only a fraction of the delay time remains. */ diff --git a/harbour/src/rtl/hbproces.c b/harbour/src/rtl/hbproces.c index cd558abe40..c559631b6d 100644 --- a/harbour/src/rtl/hbproces.c +++ b/harbour/src/rtl/hbproces.c @@ -347,7 +347,7 @@ static int hb_fsProcessExec( const char *pszFilename, #elif defined( _MSC_VER ) || defined( __LCC__ ) || \ defined( __XCC__ ) || defined( __POCC__ ) iResult = _spawnvp( _P_WAIT, argv[ 0 ], argv ); -#elif defined( __MINGW32__ ) +#elif defined( __MINGW32__ ) || defined( __WATCOMC__ ) iResult = spawnvp( P_WAIT, argv[ 0 ], ( const char * const * ) argv ); #else iResult = spawnvp( P_WAIT, argv[ 0 ], ( char * const * ) argv ); @@ -607,7 +607,11 @@ HB_FHANDLE hb_fsProcessOpen( const char *pszFilename, char ** argv; argv = hb_buildArgs( pszFilename ); +#if defined( __WATCOMC__ ) + execvp( argv[ 0 ], ( const char ** ) argv ); +#else execvp( argv[ 0 ], argv ); +#endif hb_freeArgs( argv ); #endif exit(1); @@ -717,7 +721,7 @@ HB_FHANDLE hb_fsProcessOpen( const char *pszFilename, #if defined( _MSC_VER ) || defined( __LCC__ ) || \ defined( __XCC__ ) || defined( __POCC__ ) pid = _spawnvp( _P_NOWAIT, argv[ 0 ], argv ); -#elif defined( __MINGW32__ ) +#elif defined( __MINGW32__ ) || defined( __WATCOMC__ ) pid = spawnvp( P_NOWAIT, argv[ 0 ], ( const char * const * ) argv ); #else pid = spawnvp( P_NOWAIT, argv[ 0 ], ( char * const * ) argv );