From ce68dda8ff1f5c8468b2bccbafd74f59486682cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Thu, 12 Jun 2014 19:29:42 +0200 Subject: [PATCH] 2014-06-12 19:29 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/hbgtcore.c + allow to use GTNUL at runtime just like any other GT driver, i.e. creating dynamically new GT and use it as default thread GT. --- ChangeLog.txt | 5 +++++ src/rtl/hbgtcore.c | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 00461bb985..78bfc3d6c1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,11 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2014-06-12 19:29 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/hbgtcore.c + + allow to use GTNUL at runtime just like any other GT driver, i.e. + creating dynamically new GT and use it as default thread GT. + 2014-06-04 14:34 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/vm/classes.c ! added missing const to variable declaration in profiler code - problem diff --git a/src/rtl/hbgtcore.c b/src/rtl/hbgtcore.c index ea07a64aca..e31ae4a781 100644 --- a/src/rtl/hbgtcore.c +++ b/src/rtl/hbgtcore.c @@ -3692,17 +3692,19 @@ static const char * hb_gt_FindDefault( void ) static int hb_gt_FindEntry( const char * pszID ) { + HB_BOOL fGt = hb_strnicmp( pszID, "gt", 2 ); int iPos; - for( iPos = 0; iPos < s_iGtCount; iPos++ ) + for( iPos = -1; iPos < s_iGtCount; iPos++ ) { - if( hb_stricmp( s_gtInit[ iPos ]->id, pszID ) == 0 || - ( hb_strnicmp( pszID, "gt", 2 ) == 0 && - hb_stricmp( s_gtInit[ iPos ]->id, pszID + 2 ) == 0 ) ) + const char * id = iPos < 0 ? "nul" : s_gtInit[ iPos ]->id; + + if( hb_stricmp( pszID, id ) == 0 || + ( fGt && hb_stricmp( pszID + 2, id ) == 0 ) ) return iPos; } - return -1; + return hb_stricmp( pszID + ( fGt ? 2 : 0 ), "null" ) == 0 ? -1 : -2; } void hb_gtSetDefault( const char * szGtName ) @@ -3713,7 +3715,7 @@ void hb_gtSetDefault( const char * szGtName ) HB_BOOL hb_gtRegister( const HB_GT_INIT * gtInit ) { - if( s_iGtCount < HB_GT_MAX_ && hb_gt_FindEntry( gtInit->id ) == -1 ) + if( s_iGtCount < HB_GT_MAX_ && hb_gt_FindEntry( gtInit->id ) < -1 ) { if( gtInit->pGtId ) *gtInit->pGtId = s_iGtCount; @@ -3729,7 +3731,9 @@ PHB_GT hb_gtLoad( const char * szGtName, PHB_GT pGT, PHB_GT_FUNCS pSuperTable ) if( szGtName ) { - if( hb_stricmp( szGtName, "nul" ) == 0 || hb_stricmp( szGtName, "null" ) == 0 ) + iPos = hb_gt_FindEntry( szGtName ); + + if( iPos == -1 ) { if( pGT || pSuperTable ) hb_errInternal( 9996, "Harbour terminal (GT) initialization failure", NULL, NULL ); @@ -3741,10 +3745,7 @@ PHB_GT hb_gtLoad( const char * szGtName, PHB_GT pGT, PHB_GT_FUNCS pSuperTable ) pGT->iUsed++; return pGT; } - - iPos = hb_gt_FindEntry( szGtName ); - - if( iPos != -1 ) + else if( iPos >= 0 ) { HB_BOOL fNew = pGT == NULL; @@ -3856,7 +3857,7 @@ HB_BOOL hb_gtReload( const char * szGtName, { HB_BOOL fResult = HB_FALSE; - if( szGtName && hb_gt_FindEntry( szGtName ) != -1 ) + if( szGtName && hb_gt_FindEntry( szGtName ) >= -1 ) { hb_gtRelease( NULL ); hb_stackSetGT( hb_gtLoad( szGtName, NULL, NULL ) ); @@ -3873,7 +3874,7 @@ void * hb_gtCreate( const char * szGtName, { void * hCurrGT = hb_gtSwap( NULL ); - if( szGtName && hb_gt_FindEntry( szGtName ) != -1 ) + if( szGtName && hb_gt_FindEntry( szGtName ) >= -1 ) { PHB_GT pGT = hb_gtLoad( szGtName, NULL, NULL ); if( pGT )