Skip to content

Commit

Permalink
Merge branch 'harbour:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Petewg authored Aug 18, 2024
2 parents 91e54ae + 368508e commit 7a883cc
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 91 deletions.
32 changes: 32 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2024-08-17 17:37 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/xhb/xhberror.c
% cleaned code] to overload ERRORNEW() with XHB_ERRORNEW()

* src/rtl/fscopy.c
% removed unnecessary code

* src/rtl/vfile.c
! fixed typo in comment

* src/vm/dynsym.c
+ allow to use symbol items as parameter in functions:
hb_IsFunction(), __dynsGetIndex(), __dynsIsFun()

2024-07-22 13:37 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/xhb/xhberror.c
! fixed very bad bug introduced in this modification:
2023-01-31 23:19 UTC+0100 Przemyslaw Czerpak
It corrupted dynamic symbol table due to stupid mistake.
I overloaded whole function symbol instead of its address only.
Many thanks to Juan Gálvez who found the problem.

* include/hbdefs.h
! fixed INT64_MIN definition

* src/vm/dynsym.c
* minor change in function order

* src/vm/memvars.c
+ allow to use symbol items in the following functions:
__mvScope(), __mvExist(), __mvGet(), __mvGetDef(), __mvPut()

2024-05-31 11:55 UTC+0200 Aleksander Czajczynski (hb fki.pl)
* doc/en/rdddb.txt
! update DBAPPEND( [<lUnlockAll>=.t.] ) documentation regarding
Expand Down
8 changes: 6 additions & 2 deletions contrib/xhb/xhberror.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ static HB_SIZE s_nErrProcLine = 0;
static HB_SIZE s_nErrProcModule = 0;
static HB_SIZE s_nErrCallStack = 0;

static HB_SYMB s_symErrorNew = { "XHB_ERRORNEW", { HB_FS_PUBLIC | HB_FS_LOCAL }, { HB_FUNCNAME( XHB_ERRORNEW ) }, NULL };
static HB_SYMB s_symXhbErrorNew = { "XHB_ERRORNEW", { HB_FS_PUBLIC | HB_FS_LOCAL }, { HB_FUNCNAME( XHB_ERRORNEW ) }, NULL };
#ifdef XHB_ERROR_OVERLOAD_ERRORNEW
static HB_SYMB s_symErrorNew = { "ERRORNEW" , { HB_FS_PUBLIC | HB_FS_LOCAL }, { HB_FUNCNAME( XHB_ERRORNEW ) }, NULL };
#endif

static void s_xhbErrorResize( PHB_ITEM pError )
{
Expand Down Expand Up @@ -342,6 +345,7 @@ static void xhb_errRedefineClass( void * cargo )
PHB_DYNS pDynSym = hb_dynsymFind( "ERRORNEW" );
if( pDynSym )
{
s_symErrorNew.pDynSym = pDynSym;
pDynSym->pSymbol = &s_symErrorNew;
hb_vmSetDynFunc( pDynSym );
}
Expand All @@ -353,7 +357,7 @@ static void xhb_errRedefineClass( void * cargo )
}

HB_CALL_ON_STARTUP_BEGIN( _xhb_error_init_ )
hb_dynsymNew( &s_symErrorNew );
hb_dynsymNew( &s_symXhbErrorNew );
hb_vmAtInit( xhb_errRedefineClass, NULL );
HB_CALL_ON_STARTUP_END( _xhb_error_init_ )

Expand Down
2 changes: 1 addition & 1 deletion include/hbdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#undef INT32_MIN
#define INT32_MIN ((int32_t) (-INT32_MAX-1))
#undef INT64_MIN
#define INT64_MIN (9223372036854775807i64-1)
#define INT64_MIN (-9223372036854775807i64-1)
#undef INT64_MAX
#define INT64_MAX 9223372036854775807i64
#endif
Expand Down
5 changes: 0 additions & 5 deletions src/rtl/fscopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ HB_FUNC( HB_FCOPY )
fResult = hb_fsCopy( pszSource, pszDest );
errCode = hb_fsError();
}
else
{
hb_fsSetFError( 2 /* file not found */ );
hb_retni( F_ERROR );
}
hb_fsSetFError( errCode );
hb_retni( fResult ? 0 : F_ERROR );
}
2 changes: 1 addition & 1 deletion src/rtl/vfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ HB_FUNC( HB_VFCOPYFILE )
hb_retni( iResult );
}

/* hb_vfCopyFile( <cFileSrc>, <cFileDst>, [<nBufSize>], [<lTimePreserve>=.t.], [<bCallBack>] ) --> <nResult> */
/* hb_vfCopyFileEx( <cFileSrc>, <cFileDst>, [<nBufSize>], [<lTimePreserve>=.t.], [<bCallBack>] ) --> <nResult> */
HB_FUNC( HB_VFCOPYFILEEX )
{
const char * pszSource = hb_parc( 1 ),
Expand Down
71 changes: 38 additions & 33 deletions src/vm/dynsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,26 @@ static PHB_DYNS hb_dynsymGetByIndex( HB_LONG lIndex )
return pDynSym;
}

static PHB_DYNS hb_dynsymByItem( PHB_ITEM pItem )
{
PHB_DYNS pDynSym = NULL;

if( pItem )
{
if( HB_IS_STRING( pItem ) )
pDynSym = hb_dynsymFindName( pItem->item.asString.value );
else if( HB_IS_SYMBOL( pItem ) )
{
pDynSym = pItem->item.asSymbol.value->pDynSym;
if( pDynSym == NULL )
pDynSym = hb_dynsymFind( pItem->item.asSymbol.value->szName );
}
else if( HB_IS_NUMERIC( pItem ) )
pDynSym = hb_dynsymGetByIndex( hb_itemGetNL( pItem ) );
}
return pDynSym;
}

HB_LONG hb_dynsymCount( void )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_dynsymCount()" ) );
Expand Down Expand Up @@ -668,53 +688,38 @@ HB_FUNC( __DYNSGETNAME ) /* Get name of symbol: cSymbol = __dynsymGetName( dsInd
hb_retc( pDynSym ? pDynSym->pSymbol->szName : NULL );
}

HB_FUNC( __DYNSGETINDEX ) /* Gimme index number of symbol: dsIndex = __dynsymGetIndex( cSymbol ) */
HB_FUNC( __DYNSGETINDEX ) /* Gimme index number of symbol: dsIndex = __dynsymGetIndex( cSymbol | sSymbol ) */
{
HB_STACK_TLS_PRELOAD
HB_SYMCNT uiPos = 0;
const char * szName = hb_parc( 1 );
PHB_DYNS pDynSym = hb_dynsymByItem( hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL ) );

if( szName )
if( pDynSym )
{
PHB_DYNS pDynSym = hb_dynsymFindName( szName );
if( pDynSym )
{
HB_DYNSYM_LOCK();
if( hb_dynsymPos( pDynSym->pSymbol->szName, &uiPos ) )
++uiPos;
else
uiPos = 0;
HB_DYNSYM_UNLOCK();
}
HB_DYNSYM_LOCK();
if( hb_dynsymPos( pDynSym->pSymbol->szName, &uiPos ) )
++uiPos;
else
uiPos = 0;
HB_DYNSYM_UNLOCK();
}

hb_retnint( uiPos );
}

HB_FUNC( HB_ISFUNCTION ) /* returns .T. if a symbol has a function/procedure pointer,
given its name */
given its symbol or name */
{
HB_STACK_TLS_PRELOAD
const char * szProc = hb_parc( 1 );
HB_BOOL fResult = HB_FALSE;

if( szProc )
{
PHB_DYNS pDynSym = hb_dynsymFindName( szProc );
if( pDynSym )
fResult = hb_dynsymIsFunction( pDynSym );
}
PHB_DYNS pDynSym = hb_dynsymByItem( hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL ) );

hb_retl( fResult );
hb_retl( pDynSym && hb_dynsymIsFunction( pDynSym ) );
}

HB_FUNC( __DYNSISFUN ) /* returns .T. if a symbol has a function/procedure pointer,
given its symbol index or name */
{
HB_STACK_TLS_PRELOAD
const char * szName = hb_parc( 1 );
PHB_DYNS pDynSym = szName ? hb_dynsymFindName( szName ) :
hb_dynsymGetByIndex( hb_parnl( 1 ) );
PHB_DYNS pDynSym = hb_dynsymByItem( hb_param( 1, HB_IT_STRING | HB_IT_SYMBOL | HB_IT_NUMERIC ) );

hb_retl( pDynSym && hb_dynsymIsFunction( pDynSym ) );
}
Expand Down Expand Up @@ -744,21 +749,21 @@ HB_FUNC( __DYNSGETPRF ) /* profiler: It returns an array with a function or proc
#endif
}

HB_FUNC( __DYNSN2PTR )
HB_FUNC( __DYNSN2SYM )
{
HB_STACK_TLS_PRELOAD
const char * szName = hb_parc( 1 );

hb_retptr( szName ? hb_dynsymGet( szName ) : NULL );
if( szName )
hb_itemPutSymbol( hb_stackReturnItem(), hb_dynsymGet( szName )->pSymbol );
}

HB_FUNC( __DYNSN2SYM )
HB_FUNC( __DYNSN2PTR )
{
HB_STACK_TLS_PRELOAD
const char * szName = hb_parc( 1 );

if( szName )
hb_itemPutSymbol( hb_stackReturnItem(), hb_dynsymGet( szName )->pSymbol );
hb_retptr( szName ? hb_dynsymGet( szName ) : NULL );
}

HB_FUNC( __DYNSP2NAME )
Expand Down
Loading

0 comments on commit 7a883cc

Please sign in to comment.