From 8eebea16f5b254257ce9048a3d2889bb50c5b782 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 28 Aug 2007 01:15:31 +0000 Subject: [PATCH] 2007-08-28 03:15 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/diskspac.c * harbour/source/rtl/disksphb.c ! casting for C++ compilers * harbour/source/rtl/hbinet.c * added hack for unimplemented in Linux OpenWatcom version h_errno and hstrerror() * harbour/source/rtl/hbregex.c * harbour/source/hbpcre/pcreglob.c * harbour/contrib/btree/hb_btree.c * workaround for C/C++ compilers which may use different calling convention for standard C functions --- harbour/ChangeLog | 15 +++++++++++++++ harbour/contrib/btree/hb_btree.c | 9 +++++++-- harbour/source/hbpcre/pcreglob.c | 21 +++++++++++++-------- harbour/source/rtl/diskspac.c | 2 +- harbour/source/rtl/disksphb.c | 2 +- harbour/source/rtl/hbinet.c | 10 ++++++---- harbour/source/rtl/hbregex.c | 2 ++ 7 files changed, 45 insertions(+), 16 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 43935c2536..36584feede 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-08-28 03:15 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/diskspac.c + * harbour/source/rtl/disksphb.c + ! casting for C++ compilers + + * harbour/source/rtl/hbinet.c + * added hack for unimplemented in Linux OpenWatcom version + h_errno and hstrerror() + + * harbour/source/rtl/hbregex.c + * harbour/source/hbpcre/pcreglob.c + * harbour/contrib/btree/hb_btree.c + * workaround for C/C++ compilers which may use different calling + convention for standard C functions + 2007-08-27 17:35 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/diskspac.c * harbour/source/rtl/disksphb.c diff --git a/harbour/contrib/btree/hb_btree.c b/harbour/contrib/btree/hb_btree.c index ec4712de96..312e8fb4ef 100644 --- a/harbour/contrib/btree/hb_btree.c +++ b/harbour/contrib/btree/hb_btree.c @@ -1556,6 +1556,11 @@ BOOL hb_BTreeSeek( struct hb_BTree * pBTree, BYTE *szKey, LONG lData, BOOL bSoft } +static int hb_BTstrncmp( const char *s1, const char *s2, size_t n ) +{ + return strncmp( s1, s2, n ); +} + /* allocate hb_BTree structure */ struct hb_BTree * hb_BTreeNew( BYTE * FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers ) { @@ -1643,7 +1648,7 @@ struct hb_BTree * hb_BTreeNew( BYTE * FileName, USHORT usPageSize, USHORT usKeyS } else { - pBTree->pStrCompare = ( BTreeCmpFunc ) strncmp; + pBTree->pStrCompare = ( BTreeCmpFunc ) hb_BTstrncmp; } if ( GETFLAG( pBTree, IsInMemory ) == FALSE ) @@ -1729,7 +1734,7 @@ struct hb_BTree *hb_BTreeOpen( BYTE *FileName, ULONG ulFlags, USHORT usBuffers ) } else { - pBTree->pStrCompare = ( BTreeCmpFunc ) strncmp; + pBTree->pStrCompare = ( BTreeCmpFunc ) hb_BTstrncmp; } return pBTree; diff --git a/harbour/source/hbpcre/pcreglob.c b/harbour/source/hbpcre/pcreglob.c index d926851f6a..ac22435c2c 100644 --- a/harbour/source/hbpcre/pcreglob.c +++ b/harbour/source/hbpcre/pcreglob.c @@ -47,24 +47,29 @@ all threads. However, when compiling for Virtual Pascal, things are done differently, and global variables are not used (see pcre.in). */ +#include "hbapi.h" #include "pcreinal.h" +static void * hb_pcre_grab( size_t size ) +{ + return hb_xgrab( size ); +} #ifndef VPCOMPAT #ifdef __cplusplus extern "C" { - void *(*pcre_malloc)(size_t) = malloc; - void (*pcre_free)(void *) = free; - void *(*pcre_stack_malloc)(size_t) = malloc; - void (*pcre_stack_free)(void *) = free; + void *(*pcre_malloc)(size_t) = hb_pcre_grab; + void (*pcre_free)(void *) = hb_xfree; + void *(*pcre_stack_malloc)(size_t) = hb_pcre_grab; + void (*pcre_stack_free)(void *) = hb_xfree; int (*pcre_callout)(pcre_callout_block *) = NULL; } #else -void *(*pcre_malloc)(size_t) = malloc; -void (*pcre_free)(void *) = free; -void *(*pcre_stack_malloc)(size_t) = malloc; -void (*pcre_stack_free)(void *) = free; +void *(*pcre_malloc)(size_t) = hb_pcre_grab; +void (*pcre_free)(void *) = hb_xfree; +void *(*pcre_stack_malloc)(size_t) = hb_pcre_grab; +void (*pcre_stack_free)(void *) = hb_xfree; int (*pcre_callout)(pcre_callout_block *) = NULL; #endif #endif diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index 11fb495a01..e8f5f1e713 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -215,7 +215,7 @@ HB_FUNC( DISKSPACE ) if( !szName ) szName = ( char * ) "/"; - szName = hb_fileNameConv( hb_strdup( szName ) ); + szName = ( char * ) hb_fileNameConv( hb_strdup( szName ) ); if( statvfs( szName, &st ) == 0 ) { diff --git a/harbour/source/rtl/disksphb.c b/harbour/source/rtl/disksphb.c index bef13c1853..374ab2ad36 100644 --- a/harbour/source/rtl/disksphb.c +++ b/harbour/source/rtl/disksphb.c @@ -329,7 +329,7 @@ HB_FUNC( HB_DISKSPACE ) { struct statvfs sf; - szPath = hb_fileNameConv( hb_strdup( szPath ) ); + szPath = ( char * ) hb_fileNameConv( hb_strdup( szPath ) ); if( statvfs( szPath, &sf ) == 0 ) { switch( uiType ) diff --git a/harbour/source/rtl/hbinet.c b/harbour/source/rtl/hbinet.c index 6cefd6b7d2..2810e6ef22 100644 --- a/harbour/source/rtl/hbinet.c +++ b/harbour/source/rtl/hbinet.c @@ -78,8 +78,6 @@ #include #define HB_INET_CLOSE( x ) closesocket( x ) - - extern char *hstrerror( int i ); #else #if defined( HB_OS_HPUX ) @@ -94,7 +92,11 @@ #include #include - extern int h_errno; + #if defined(__WATCOMC__) + #define h_errno errno + #else + extern int h_errno; + #endif #define HB_INET_CLOSE( x ) close( x ) #include #endif @@ -333,7 +335,7 @@ static struct hostent * hb_getHosts( char * name, HB_SOCKET_STRUCT *Socket ) #if defined(HB_OS_WIN_32) HB_SOCKET_SET_ERROR2( Socket, WSAGetLastError() , "Generic error in GetHostByName()" ); WSASetLastError( 0 ); -#elif defined(HB_OS_OS2) || defined(HB_OS_HPUX) +#elif defined(HB_OS_OS2) || defined(HB_OS_HPUX) || defined(__WATCOMC__) HB_SOCKET_SET_ERROR2( Socket, h_errno, "Generic error in GetHostByName()" ); #else HB_SOCKET_SET_ERROR2( Socket, h_errno, (char *) hstrerror( h_errno ) ); diff --git a/harbour/source/rtl/hbregex.c b/harbour/source/rtl/hbregex.c index 6b1a4a32a4..7253f96656 100644 --- a/harbour/source/rtl/hbregex.c +++ b/harbour/source/rtl/hbregex.c @@ -545,6 +545,8 @@ HB_CALL_ON_STARTUP_BEGIN( _hb_regex_init_ ) #if defined( HB_PCRE_REGEX ) pcre_malloc = hb_pcre_grab; pcre_free = hb_xfree; + pcre_stack_malloc = hb_pcre_grab; + pcre_stack_free = hb_xfree; #endif hb_regexInit( hb_regfree, hb_regcomp, hb_regexec ); HB_CALL_ON_STARTUP_END( _hb_regex_init_ )