From 7f4b915d874ebb34b4e4168786b6cb5ad604e1ed Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 7 May 2009 23:28:13 +0000 Subject: [PATCH] 2009-05-08 01:36 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/xhb/stream.prg ! disabled call to HB_IsByRef(). Such function does not exist in Harbour and in current xHarbour it does not work. * harbour/contrib/xhb/hbserv.c ! removed some peaces of not working old code which used pHVMFuncService. With some calling convention this code can cause application crash on exit in xHarbour so it should be fixed there too. * harbour/contrib/xhb/regexrpl.prg ! use HB_ISREGEX() instead of xHarbour only HB_ISREGEXSTRING() * harbour/contrib/xhb/xhbfunc.c + added xHarbour compatible HB_CREATELEN8() and HB_GETLEN8() functions. They save/restore 64bit signed integers in/from 8 bytes strings. In Clipper terminology they can be called: LL2BIN()/BIN2LL(). Original xHarbour version of HB_CREATELEN8() and HB_GETLEN8() were implemented by Giancarlo Niccolai. --- harbour/ChangeLog | 20 ++++++++++++++++++++ harbour/contrib/xhb/hbserv.c | 24 ++++++++++++++++++------ harbour/contrib/xhb/regexrpl.prg | 2 +- harbour/contrib/xhb/stream.prg | 2 ++ harbour/contrib/xhb/xhbfunc.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4c348558f4..e67f98f90d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,26 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-08 01:36 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/xhb/stream.prg + ! disabled call to HB_IsByRef(). Such function does not exist in Harbour + and in current xHarbour it does not work. + + * harbour/contrib/xhb/hbserv.c + ! removed some peaces of not working old code which used pHVMFuncService. + With some calling convention this code can cause application crash on + exit in xHarbour so it should be fixed there too. + + * harbour/contrib/xhb/regexrpl.prg + ! use HB_ISREGEX() instead of xHarbour only HB_ISREGEXSTRING() + + * harbour/contrib/xhb/xhbfunc.c + + added xHarbour compatible HB_CREATELEN8() and HB_GETLEN8() functions. + They save/restore 64bit signed integers in/from 8 bytes strings. + In Clipper terminology they can be called: LL2BIN()/BIN2LL(). + Original xHarbour version of HB_CREATELEN8() and HB_GETLEN8() were + implemented by Giancarlo Niccolai. + 2009-05-07 19:59 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/rtl/tget.prg ! Fixed to check for ::cType != NIL before diff --git a/harbour/contrib/xhb/hbserv.c b/harbour/contrib/xhb/hbserv.c index ee7b05db4a..7bcde183f8 100644 --- a/harbour/contrib/xhb/hbserv.c +++ b/harbour/contrib/xhb/hbserv.c @@ -86,12 +86,16 @@ #define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION #endif -extern PHB_FUNC pHVMFuncService; - /************************************************** * Global definition, valid for all systems ***************************************************/ +HB_EXTERN_BEGIN +BOOL hb_isService( void ); +void hb_serviceExit( void ); +HB_EXTERN_END + + static void s_serviceSetHBSig( void ); static void s_serviceSetDflSig( void ); static void s_signalHandlersInit( void ); @@ -261,7 +265,7 @@ static void s_signalHandler( int sig, siginfo_t * info, void * v ) to fix as soon as thread support is ready on OS/2 */ #if defined(HB_THREAD_SUPPORT) && ! defined(HB_OS_OS2) -void * s_signalListener( void * my_stack ) +static void * s_signalListener( void * my_stack ) { static BOOL bFirst = TRUE; sigset_t passall; @@ -698,6 +702,13 @@ static int s_translateSignal( UINT sig, UINT subsig ) return HB_SIGNAL_UNKNOWN; } +static void hb_service_exit( void* cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + hb_serviceExit(); +} + /** * Initializes signal handler system */ @@ -718,6 +729,7 @@ static void s_signalHandlersInit() sp_hooks = hb_itemNew( NULL ); hb_arrayNew( sp_hooks, 0 ); + hb_vmAtQuit( hb_service_exit, NULL ); } /***************************************************************************** @@ -771,7 +783,6 @@ HB_FUNC( HB_STARTSERVICE ) /* let's begin */ sb_isService = TRUE; - pHVMFuncService = ( PHB_FUNC ) hb_isService; /* in windows, we just detach from console */ #ifdef HB_OS_WIN @@ -793,7 +804,7 @@ HB_FUNC( HB_STARTSERVICE ) * Been called. C version useful for internal api */ -BOOL hb_isService() +BOOL hb_isService( void ) { return sb_isService; } @@ -803,13 +814,14 @@ BOOL hb_isService() * Called from hb_vmQuit() */ -void hb_serviceExit() +void hb_serviceExit( void ) { if( sp_hooks != NULL ) { /* reset default signal handling */ s_serviceSetDflSig(); hb_itemRelease( sp_hooks ); + sp_hooks = NULL; } } diff --git a/harbour/contrib/xhb/regexrpl.prg b/harbour/contrib/xhb/regexrpl.prg index 29fabd9ff7..e998ddb456 100644 --- a/harbour/contrib/xhb/regexrpl.prg +++ b/harbour/contrib/xhb/regexrpl.prg @@ -64,7 +64,7 @@ FUNCTION hb_RegexReplace( cRegex, cString, cReplace, lCaseSensitive, lNewLine, n LOCAL cSearch, nStart, nLenSearch, nLenReplace //LOCAL nEnd - IF !HB_ISREGEXSTRING( cRegex ) + IF !HB_ISREGEX( cRegex ) pRegex := HB_RegExComp( cRegEx ) ELSE pRegex := cRegEx diff --git a/harbour/contrib/xhb/stream.prg b/harbour/contrib/xhb/stream.prg index 425ef6330c..f03d5f3b61 100644 --- a/harbour/contrib/xhb/stream.prg +++ b/harbour/contrib/xhb/stream.prg @@ -172,9 +172,11 @@ METHOD Read( sBuffer, nOffset, nCount ) CLASS TStreamFileReader LOCAL nRead +/* IF ! HB_IsByRef( @sBuffer ) Throw( ErrorNew( "Stream", 0, 1002, ProcName(), "Buffer not BYREF.", HB_aParams() ) ) ENDIF +*/ nRead := FRead( ::Handle, @sBuffer, nCount, nOffset ) diff --git a/harbour/contrib/xhb/xhbfunc.c b/harbour/contrib/xhb/xhbfunc.c index dc8010d636..a37dcdc523 100644 --- a/harbour/contrib/xhb/xhbfunc.c +++ b/harbour/contrib/xhb/xhbfunc.c @@ -140,6 +140,34 @@ HB_FUNC( XHB__KEYBOARD ) } } +HB_FUNC( HB_CREATELEN8 ) +{ + char buffer[ 8 ]; + HB_LONG llValue; + + if( ISNUM( 1 ) ) + { + llValue = hb_parnint( 1 ); + HB_PUT_LE_UINT64( buffer, llValue ); + hb_retclen( buffer, 8 ); + } + else if( ISBYREF( 1 ) && ISNUM( 2 ) ) + { + llValue = hb_parnint( 2 ); + HB_PUT_LE_UINT64( buffer, llValue ); + hb_storclen( buffer, 8, 1 ); + } +} + +HB_FUNC( HB_GETLEN8 ) +{ + char * buffer = hb_parc( 1 ); + if( buffer && hb_parclen( 1 ) >= 8 ) + hb_retnint( HB_GET_LE_UINT64( buffer ) ); + else + hb_retni( -1 ); +} + HB_FUNC_EXTERN( HB_DESERIALIZE ); HB_FUNC( HB_DESERIALBEGIN )