2009-04-01 22:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/doc/Makefile
    ! removed unexisting license.txt file

  * harbour/include/hbapidbg.h
    * do not export Harbour debugger functions. If someone wants to create
      3-rd party debugger then we should agree the list of functions which
      should be public.

  * harbour/include/hbstack.h
    * minor cleanup in some definitions

  * harbour/include/hbdefs.h
    + added HB_DLL_ENTRY_POINT macro to set default DLL entry point for
      different Windows compilers

  * harbour/source/vm/maindllh.c
  * harbour/source/vm/maindllp.c
    * use HB_DLL_ENTRY_POINT macro

  * harbour/include/hbsetup.h
    * added internal macro to disable flatten optimization

  * harbour/include/hbmath.h
  * harbour/source/rtl/math.c
    * make default math error handler function static

  * harbour/include/hbatomic.h
    + added atomic inc/dec inline asm code to OW x86 builds

  * harbour/source/rtl/console.c
    * small code reorganization to not mix public and private function calls

  * harbour/source/rtl/hbregex.c
  * harbour/source/hbpcre/_hbpcreg.c
    * do not use hb_xfree() function pointer directly to avoid problems
      with different calling conventions.

  * harbour/config/win/owatcom.cf
  * harbour/config/os2/owatcom.cf
    * removed unnecessary in recent OpenWatcom versions explicit wlink.lnk
      including.
This commit is contained in:
Przemyslaw Czerpak
2009-04-01 20:04:37 +00:00
parent 5ff55f2ce6
commit 3672e94c50
15 changed files with 271 additions and 158 deletions

View File

@@ -8,6 +8,49 @@
2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-04-01 22:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/doc/Makefile
! removed unexisting license.txt file
* harbour/include/hbapidbg.h
* do not export Harbour debugger functions. If someone wants to create
3-rd party debugger then we should agree the list of functions which
should be public.
* harbour/include/hbstack.h
* minor cleanup in some definitions
* harbour/include/hbdefs.h
+ added HB_DLL_ENTRY_POINT macro to set default DLL entry point for
different Windows compilers
* harbour/source/vm/maindllh.c
* harbour/source/vm/maindllp.c
* use HB_DLL_ENTRY_POINT macro
* harbour/include/hbsetup.h
* added internal macro to disable flatten optimization
* harbour/include/hbmath.h
* harbour/source/rtl/math.c
* make default math error handler function static
* harbour/include/hbatomic.h
+ added atomic inc/dec inline asm code to OW x86 builds
* harbour/source/rtl/console.c
* small code reorganization to not mix public and private function calls
* harbour/source/rtl/hbregex.c
* harbour/source/hbpcre/_hbpcreg.c
* do not use hb_xfree() function pointer directly to avoid problems
with different calling conventions.
* harbour/config/win/owatcom.cf
* harbour/config/os2/owatcom.cf
* removed unnecessary in recent OpenWatcom versions explicit wlink.lnk
including.
2009-04-01 14:11 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* utils/hbmk2/hbmk2.prg
+ Added clipper/rtlink/exospace/blinker self-name recognition.

View File

@@ -78,7 +78,6 @@ $(foreach file, $(^F), $(link_file))
$(foreach lib, $(LINKLIBS), $(link_lib))
$(foreach lib, $(RDDLIBS), $(link_lib))
$(foreach lib, $(GTLIBS), $(link_lib))
echo @%WATCOM%/binp/wlink.lnk >> __link__.tmp
-$(LD) @__link__.tmp
endef

View File

@@ -84,8 +84,7 @@ $(foreach file, $(^F), $(link_file))
$(foreach lib, $(LINKLIBS), $(link_lib))
$(foreach lib, $(RDDLIBS), $(link_lib))
$(foreach lib, $(GTLIBS), $(link_lib))
echo @%WATCOM%/binnt/wlink.lnk >> __link__.tmp
echo LIB kernel32.lib, user32.lib, ws2_32.lib >> __link__.tmp
echo LIB ws2_32.lib >> __link__.tmp
-$(LD) @__link__.tmp
endef

View File

@@ -61,32 +61,32 @@ HB_EXTERN_BEGIN
/* HVM debugger function */
typedef void (*HB_DBGENTRY_FUNC) ( int , int , char *, int , PHB_ITEM );
HB_EXPORT extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry );
HB_EXPORT extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke );
HB_EXPORT extern ULONG hb_dbg_ProcLevel( void );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarSGet( PHB_ITEM pStaticsBase, int nOffset );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal );
HB_EXPORT extern ULONG hb_dbg_vmVarGCount( void );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset );
extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry );
extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke );
extern ULONG hb_dbg_ProcLevel( void );
extern PHB_ITEM hb_dbg_vmVarSGet( PHB_ITEM pStaticsBase, int nOffset );
extern PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal );
extern ULONG hb_dbg_vmVarGCount( void );
extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset );
/* internal debugger function */
HB_EXPORT extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame );
HB_EXPORT extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction );
HB_EXPORT extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace );
HB_EXPORT extern void hb_dbgDelBreak( void *handle, int nBreak );
HB_EXPORT extern void hb_dbgDelWatch( void *handle, int nWatch );
HB_EXPORT extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression );
HB_EXPORT extern PHB_ITEM hb_dbgGetSourceFiles( void *handle );
HB_EXPORT extern PHB_ITEM hb_dbgGetWatchValue( void *handle, int nWatch );
HB_EXPORT extern BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine );
HB_EXPORT extern void hb_dbgSetCBTrace( void *handle, BOOL bCBTrace );
HB_EXPORT extern void hb_dbgSetGo( void *handle );
HB_EXPORT extern void hb_dbgSetInvoke( void *handle, BOOL ( *pFunInvoke )( void ) );
HB_EXPORT extern void hb_dbgSetNextRoutine( void *handle );
HB_EXPORT extern void hb_dbgSetQuit( void *handle );
HB_EXPORT extern void hb_dbgSetToCursor( void *handle, char *szModule, int nLine );
HB_EXPORT extern void hb_dbgSetTrace( void *handle );
HB_EXPORT extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace );
extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame );
extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction );
extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace );
extern void hb_dbgDelBreak( void *handle, int nBreak );
extern void hb_dbgDelWatch( void *handle, int nWatch );
extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression );
extern PHB_ITEM hb_dbgGetSourceFiles( void *handle );
extern PHB_ITEM hb_dbgGetWatchValue( void *handle, int nWatch );
extern BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine );
extern void hb_dbgSetCBTrace( void *handle, BOOL bCBTrace );
extern void hb_dbgSetGo( void *handle );
extern void hb_dbgSetInvoke( void *handle, BOOL ( *pFunInvoke )( void ) );
extern void hb_dbgSetNextRoutine( void *handle );
extern void hb_dbgSetQuit( void *handle );
extern void hb_dbgSetToCursor( void *handle, char *szModule, int nLine );
extern void hb_dbgSetTrace( void *handle );
extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace );
HB_EXTERN_END

View File

@@ -292,7 +292,46 @@ HB_EXTERN_BEGIN
# endif
# endif
# endif /* x86 */
#elif defined( __WATCOMC__ ) && defined( __cplusplus )
# if defined( i386 ) || defined( __i386__ ) || defined( __x86_64__ ) || \
defined( _M_IX86 ) || defined( _M_AMD64 )
# 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 int hb_atomic_dec32( volatile int * p )
{
unsigned char c;
_asm {
mov eax, p
lock dec dword ptr [eax]
setne c
}
return c;
}
# define HB_ATOM_INC( p ) ( hb_atomic_inc32( ( volatile int * ) (p) ) )
# define HB_ATOM_DEC( p ) ( hb_atomic_dec32( ( volatile int * ) (p) ) )
# define HB_ATOM_GET( p ) (*(int volatile *)(p))
# define HB_ATOM_SET( p, n ) do { *((int volatile *)(p)) = (n); } while(0)
# elif HB_COUNTER_SIZE == 8
/* TODO: */
# endif
# endif /* x86 */
#endif /* ??? C compiler ??? */

View File

@@ -1260,6 +1260,13 @@ typedef long hbVMIntMax; /* TOFIX */
#define HB_START_PROC_STRICT
#endif
#if defined(__WATCOMC__) || defined(__DMC__) || \
defined(_MSC_VER) || defined(__POCC__)
#define HB_DLL_ENTRY_POINT DllMain
#else
#define HB_DLL_ENTRY_POINT DllEntryPoint
#endif
#if defined(HB_FUNC_CALLCONV)
#define HARBOUR void HB_FUNC_CALLCONV
#else

View File

@@ -125,7 +125,6 @@ extern HB_EXPORT BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *
extern HB_EXPORT int hb_mathSetErrMode( int imode );
extern HB_EXPORT int hb_mathGetErrMode( void );
extern HB_EXPORT int hb_matherr( HB_MATH_EXCEPTION * pexc );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathGetHandler( void );

View File

@@ -412,7 +412,7 @@
#define HB_NORETURN_ATTR
# endif
# if ( ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 1 ) ) && \
!defined( __ICC )
!defined( __ICC ) && !defined( HB_NO_FALTTEN )
#define HB_FLATTEN_ATTR \
__attribute__ (( flatten ))
# else

View File

@@ -200,7 +200,7 @@ typedef struct
extern HB_TLS_KEY hb_stack_key;
# if defined( __BORLANDC__ ) && defined( HB_STACK_PRELOAD ) && \
!defined( HB_OS_WIN_64 ) && !defined( HB_OS_WIN_CE )
static __inline void* hb_stack_ptr_from_tls( void )
static __inline void * hb_stack_ptr_from_tls( void )
{
/* mov ecx,hb_stack_key */
_ECX = hb_stack_key;
@@ -211,6 +211,7 @@ typedef struct
/* ret (if function is not inlined) */
return (void*) _EAX;
}
# define hb_stack_ptr_get() hb_stack_ptr_from_tls()
# elif defined( __MINGW32__ ) && \
!defined( HB_OS_WIN_64 ) && !defined( HB_OS_WIN_CE )
static __inline__ __attribute__ ((pure, malloc)) void * hb_stack_ptr_from_tls( void )
@@ -224,6 +225,7 @@ typedef struct
);
return p;
}
# define hb_stack_ptr_get() hb_stack_ptr_from_tls()
# define hb_stack_ptr ( ( PHB_STACK ) hb_stack_ptr_from_tls() )
# endif
# if !defined( hb_stack_ptr )
@@ -231,19 +233,21 @@ typedef struct
# endif
# endif
# if defined( HB_STACK_PRELOAD ) && !defined( HB_USE_TLS )
# if ( defined( __BORLANDC__ ) || defined( __MINGW32__ ) ) && \
!defined( HB_OS_WIN_64 ) && !defined( HB_OS_WIN_CE )
# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = ( PHB_STACK ) hb_stack_ptr_from_tls();
# if defined( hb_stack_ptr_get )
# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = ( PHB_STACK ) hb_stack_ptr_get();
# undef hb_stack_ptr
# else
# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = hb_stack_ptr;
# endif
# define hb_stack ( * _hb_stack_ptr_ )
# define hb_stack ( * _hb_stack_ptr_ )
# define hb_stack_ref() ( _hb_stack_ptr_ )
# else
# define hb_stack ( * hb_stack_ptr )
# define hb_stack ( * hb_stack_ptr )
# define hb_stack_ref() ( hb_stack_ptr )
# endif
# else
extern HB_STACK hb_stack;
# define hb_stack_ref() ( &hb_stack )
# endif
#endif
#if !defined( HB_STACK_TLS_PRELOAD ) && defined( HB_STACK_PRELOAD )
@@ -381,7 +385,7 @@ extern void hb_stackIsStackRef( void *, PHB_TSD_FUNC );
#define hb_stackGetI18N( ) ( hb_stack.pI18N )
#define hb_stackSetI18N( p ) do { hb_stack.pI18N = ( p ); } while ( 0 )
#define hb_stackId( ) ( ( void * ) &hb_stack )
#define hb_stackId( ) ( ( void * ) hb_stack_ref() )
#if defined( HB_MT_VM )
# define hb_stackList() ( hb_stack.pStackLst )
# define hb_stackListSet( p ) do { hb_stack.pStackLst = ( p ); } while ( 0 )

View File

@@ -60,6 +60,11 @@ static void * hb_pcre_grab( size_t size )
return hb_xgrab( size );
}
static void hb_pcre_free( void * ptr )
{
hb_xfree( ptr );
}
#if 1
#include "_hbconf.h"
#endif
@@ -69,9 +74,9 @@ static void * hb_pcre_grab( size_t size )
#ifndef VPCOMPAT
HB_EXTERN_BEGIN
PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = hb_pcre_grab;
PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = hb_xfree;
PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = hb_pcre_free;
PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = hb_pcre_grab;
PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = hb_xfree;
PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = hb_pcre_free;
PCRE_EXP_DATA_DEFN int (*pcre_callout)(pcre_callout_block *) = NULL;
HB_EXTERN_END
#endif

View File

@@ -268,8 +268,6 @@ static void hb_conOutDev( const char * pStr, ULONG ulLen )
hb_gtWrite( ( BYTE * ) pStr, ulLen );
}
typedef void hb_out_func_typedef( const char *, ULONG );
static char * hb_itemStringCon( PHB_ITEM pItem, ULONG * pulLen, BOOL * pfFreeReq )
{
/* logical values in device output (not console, stdout or stderr) are
@@ -283,38 +281,21 @@ static char * hb_itemStringCon( PHB_ITEM pItem, ULONG * pulLen, BOOL * pfFreeReq
return hb_itemString( pItem, pulLen, pfFreeReq );
}
/* Format items for output, then call specified output function */
static void hb_conOut( USHORT uiParam, hb_out_func_typedef * pOutFunc )
{
char * pszString;
ULONG ulLen;
BOOL bFreeReq;
PHB_ITEM pItem;
HB_TRACE(HB_TR_DEBUG, ("hb_conOut(%hu, %p)", uiParam, pOutFunc));
pItem = hb_param( uiParam, HB_IT_ANY );
if( pOutFunc == hb_conOutDev )
pszString = hb_itemStringCon( pItem, &ulLen, &bFreeReq );
else
pszString = hb_itemString( pItem, &ulLen, &bFreeReq );
if( ulLen )
pOutFunc( pszString, ulLen );
if( bFreeReq )
hb_xfree( pszString );
}
HB_FUNC( OUTSTD ) /* writes a list of values to the standard output device */
{
USHORT uiPCount = ( USHORT ) hb_pcount();
USHORT uiParam;
char * pszString;
ULONG ulLen;
BOOL fFree;
for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
{
hb_conOut( uiParam, hb_conOutStd );
pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &fFree );
if( ulLen )
hb_conOutStd( pszString, ulLen );
if( fFree )
hb_xfree( pszString );
if( uiParam < uiPCount )
hb_conOutStd( " ", 1 );
}
@@ -324,10 +305,17 @@ HB_FUNC( OUTERR ) /* writes a list of values to the standard error device */
{
USHORT uiPCount = ( USHORT ) hb_pcount();
USHORT uiParam;
char * pszString;
ULONG ulLen;
BOOL fFree;
for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
{
hb_conOut( uiParam, hb_conOutErr );
pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &fFree );
if( ulLen )
hb_conOutErr( pszString, ulLen );
if( fFree )
hb_xfree( pszString );
if( uiParam < uiPCount )
hb_conOutErr( " ", 1 );
}
@@ -337,10 +325,17 @@ HB_FUNC( QQOUT ) /* writes a list of values to the current device (screen or pri
{
USHORT uiPCount = ( USHORT ) hb_pcount();
USHORT uiParam;
char * pszString;
ULONG ulLen;
BOOL fFree;
for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
{
hb_conOut( uiParam, hb_conOutAlt );
pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &fFree );
if( ulLen )
hb_conOutAlt( pszString, ulLen );
if( fFree )
hb_xfree( pszString );
if( uiParam < uiPCount )
hb_conOutAlt( " ", 1 );
}
@@ -493,6 +488,10 @@ HB_FUNC( SETPRC ) /* Sets the current printer row and column positions */
HB_FUNC( DEVOUT ) /* writes a single value to the current device (screen or printer), but is not affected by SET ALTERNATE */
{
char * pszString;
ULONG ulLen;
BOOL fFree;
if( ISCHAR( 2 ) )
{
char szOldColor[ HB_CLRSTR_LEN ];
@@ -500,12 +499,22 @@ HB_FUNC( DEVOUT ) /* writes a single value to the current device (screen or prin
hb_gtGetColorStr( szOldColor );
hb_gtSetColorStr( hb_parc( 2 ) );
hb_conOut( 1, hb_conOutDev );
pszString = hb_itemStringCon( hb_param( 1, HB_IT_ANY ), &ulLen, &fFree );
if( ulLen )
hb_conOutDev( pszString, ulLen );
if( fFree )
hb_xfree( pszString );
hb_gtSetColorStr( szOldColor );
}
else if( hb_pcount() >= 1 )
hb_conOut( 1, hb_conOutDev );
{
pszString = hb_itemStringCon( hb_param( 1, HB_IT_ANY ), &ulLen, &fFree );
if( ulLen )
hb_conOutDev( pszString, ulLen );
if( fFree )
hb_xfree( pszString );
}
}
HB_FUNC( DISPOUT ) /* writes a single value to the screen, but is not affected by SET ALTERNATE */

View File

@@ -541,6 +541,10 @@ static void * hb_pcre_grab( size_t size )
{
return hb_xgrab( size );
}
static void hb_pcre_free( void * ptr )
{
hb_xfree( ptr );
}
#endif
HB_CALL_ON_STARTUP_BEGIN( _hb_regex_init_ )
@@ -553,9 +557,9 @@ HB_CALL_ON_STARTUP_BEGIN( _hb_regex_init_ )
}
# endif
pcre_malloc = hb_pcre_grab;
pcre_free = hb_xfree;
pcre_free = hb_pcre_free;
pcre_stack_malloc = hb_pcre_grab;
pcre_stack_free = hb_xfree;
pcre_stack_free = hb_pcre_free;
#endif
hb_regexInit( hb_regfree, hb_regcomp, hb_regexec );
HB_CALL_ON_STARTUP_END( _hb_regex_init_ )

View File

@@ -87,6 +87,87 @@ typedef struct
#endif
} HB_MATHERRDATA, * PHB_MATHERRDATA;
/* Harbour default math error handling routine */
static int hb_matherr( HB_MATH_EXCEPTION * pexc )
{
int mode = hb_mathGetErrMode();
int iRet = 1;
HB_TRACE( HB_TR_DEBUG, ( "hb_matherr(%p)", pexc ) );
if( pexc == NULL || pexc->handled != 0 )
{
/* error already handled by other handlers ! */
return 1;
}
if( mode == HB_MATH_ERRMODE_USER || mode == HB_MATH_ERRMODE_USERDEFAULT ||
mode == HB_MATH_ERRMODE_USERCDEFAULT )
{
PHB_ITEM pArg1, pArg2, pError;
PHB_ITEM pMatherrResult;
/* create an error object */
/* NOTE: In case of HB_MATH_ERRMODE_USER[C]DEFAULT, I am setting both EF_CANSUBSTITUTE and EF_CANDEFAULT to .T. here.
This is forbidden according to the original Cl*pper docs, but I think this reflects the situation best here:
The error handler can either substitute the errorneous value (by returning a numeric value) or choose the
default error handling (by returning .F., as usual) [martin vogel] */
pError = hb_errRT_New_Subst( ES_ERROR, "MATH", EG_NUMERR, pexc->type,
pexc->error, pexc->funcname, 0, EF_CANSUBSTITUTE |
( mode == HB_MATH_ERRMODE_USER ? 0 : EF_CANDEFAULT ) );
/* Assign the new array to the object data item. */
/* NOTE: Unfortunately, we cannot decide whether one or two parameters have been used when the
math function has been called, so we always take two */
pArg1 = hb_itemPutND( NULL, pexc->arg1 );
pArg2 = hb_itemPutND( NULL, pexc->arg2 );
hb_errPutArgs( pError, 2, pArg1, pArg2 );
hb_itemRelease( pArg1 );
hb_itemRelease( pArg2 );
/* launch error codeblock */
pMatherrResult = hb_errLaunchSubst( pError );
hb_errRelease( pError );
if( pMatherrResult )
{
if( HB_IS_NUMERIC( pMatherrResult ) )
{
pexc->retval = hb_itemGetND( pMatherrResult );
hb_itemGetNLen( pMatherrResult, &pexc->retvalwidth, &pexc->retvaldec );
pexc->handled = 1;
}
hb_itemRelease( pMatherrResult );
}
}
/* math exception not handled by Harbour error routine above ? */
if( pexc->handled == 0 )
{
switch( mode )
{
case HB_MATH_ERRMODE_USER:
/* user failed to handle the math exception, so quit the app [yes, that's the meaning of this mode !!] */
iRet = 0;
hb_vmRequestQuit();
break;
case HB_MATH_ERRMODE_DEFAULT:
case HB_MATH_ERRMODE_USERDEFAULT:
/* return 1 to suppress C RTL error msgs, but leave error handling to the calling Harbour routine */
break;
case HB_MATH_ERRMODE_CDEFAULT:
case HB_MATH_ERRMODE_USERCDEFAULT:
/* use the correction value supplied in pexc->retval */
pexc->handled = 1;
break;
}
}
return iRet; /* error handling successful */
}
static void hb_mathErrDataInit( void * Cargo )
{
PHB_MATHERRDATA pMathErr = ( PHB_MATHERRDATA ) Cargo;
@@ -371,87 +452,6 @@ HB_FUNC( HB_MATHERMODE ) /* ([<nNewMode>]) -> <nOldMode> */
hb_mathSetErrMode( hb_parni( 1 ) );
}
/* Harbour default math error handling routine */
int hb_matherr( HB_MATH_EXCEPTION * pexc )
{
int mode = hb_mathGetErrMode();
int iRet = 1;
HB_TRACE( HB_TR_DEBUG, ( "hb_matherr(%p)", pexc ) );
if( pexc == NULL || pexc->handled != 0 )
{
/* error already handled by other handlers ! */
return 1;
}
if( mode == HB_MATH_ERRMODE_USER || mode == HB_MATH_ERRMODE_USERDEFAULT ||
mode == HB_MATH_ERRMODE_USERCDEFAULT )
{
PHB_ITEM pArg1, pArg2, pError;
PHB_ITEM pMatherrResult;
/* create an error object */
/* NOTE: In case of HB_MATH_ERRMODE_USER[C]DEFAULT, I am setting both EF_CANSUBSTITUTE and EF_CANDEFAULT to .T. here.
This is forbidden according to the original Cl*pper docs, but I think this reflects the situation best here:
The error handler can either substitute the errorneous value (by returning a numeric value) or choose the
default error handling (by returning .F., as usual) [martin vogel] */
pError = hb_errRT_New_Subst( ES_ERROR, "MATH", EG_NUMERR, pexc->type,
pexc->error, pexc->funcname, 0, EF_CANSUBSTITUTE |
( mode == HB_MATH_ERRMODE_USER ? 0 : EF_CANDEFAULT ) );
/* Assign the new array to the object data item. */
/* NOTE: Unfortunately, we cannot decide whether one or two parameters have been used when the
math function has been called, so we always take two */
pArg1 = hb_itemPutND( NULL, pexc->arg1 );
pArg2 = hb_itemPutND( NULL, pexc->arg2 );
hb_errPutArgs( pError, 2, pArg1, pArg2 );
hb_itemRelease( pArg1 );
hb_itemRelease( pArg2 );
/* launch error codeblock */
pMatherrResult = hb_errLaunchSubst( pError );
hb_errRelease( pError );
if( pMatherrResult )
{
if( HB_IS_NUMERIC( pMatherrResult ) )
{
pexc->retval = hb_itemGetND( pMatherrResult );
hb_itemGetNLen( pMatherrResult, &pexc->retvalwidth, &pexc->retvaldec );
pexc->handled = 1;
}
hb_itemRelease( pMatherrResult );
}
}
/* math exception not handled by Harbour error routine above ? */
if( pexc->handled == 0 )
{
switch( mode )
{
case HB_MATH_ERRMODE_USER:
/* user failed to handle the math exception, so quit the app [yes, that's the meaning of this mode !!] */
iRet = 0;
hb_vmRequestQuit();
break;
case HB_MATH_ERRMODE_DEFAULT:
case HB_MATH_ERRMODE_USERDEFAULT:
/* return 1 to suppress C RTL error msgs, but leave error handling to the calling Harbour routine */
break;
case HB_MATH_ERRMODE_CDEFAULT:
case HB_MATH_ERRMODE_USERCDEFAULT:
/* use the correction value supplied in pexc->retval */
pexc->handled = 1;
break;
}
}
return iRet; /* error handling successful */
}
/*
* ************************************************************

View File

@@ -60,9 +60,9 @@
#include "hbvm.h"
#include "hbapiitm.h"
#if defined(HB_OS_WIN)
#if defined( HB_OS_WIN )
BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
HB_EXPORT BOOL WINAPI HB_DLL_ENTRY_POINT( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason,
pvReserved ) );
@@ -83,4 +83,11 @@ BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserve
return TRUE;
}
#if defined( __DMC__ ) || defined( __WATCOMC__ )
HB_EXTERN_BEGIN
void hb_forceLinkMainWin( void ) {}
void hb_forceLinkMainStd( void ) {}
HB_EXTERN_END
#endif
#endif

View File

@@ -122,9 +122,7 @@ static FARPROC hb_getProcAddress( LPCSTR szProcName )
return pProcAddr;
}
HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved );
BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
HB_EXPORT BOOL WINAPI HB_DLL_ENTRY_POINT( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason,
pvReserved ) );