2008-11-09 15:46 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* contrib/xhb/hboutdbg.c
    ! Fixed to compile without warnings and with more 
      consistent behavior across platforms.

  * source/rtl/gtwvt/gtwvt.c
    * Minor formatting.
This commit is contained in:
Viktor Szakats
2008-11-09 14:47:44 +00:00
parent c6fab64db4
commit 10457b0fcf
3 changed files with 57 additions and 50 deletions

View File

@@ -8,6 +8,14 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-11-09 15:46 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/xhb/hboutdbg.c
! Fixed to compile without warnings and with more
consistent behavior across platforms.
* source/rtl/gtwvt/gtwvt.c
* Minor formatting.
2008-11-09 15:16 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbstack.h
* do not define hb_stack_ptr_from_tls() in BCC builds when

View File

@@ -62,8 +62,10 @@
#include "hbapiitm.h"
#include "hbapifs.h"
#if defined(HB_OS_UNIX)
#include <hbmath.h>
#if defined( HB_OS_UNIX )
#include "hbmath.h"
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
@@ -72,63 +74,60 @@
#include <sys/stat.h>
#include <fcntl.h>
static int s_iDebugFd = 0;
static char s_szDebugName[128];
static char s_szDebugName[ 128 ];
static int s_iUseDebugName = 0;
static int s_iXtermPid = 0;
static void debugInit( void )
{
int iPid, iFifoResult;
char szDebugTitle[30];
char szDebugTitle[ 30 ];
PHB_FNAME pFileName = NULL;
char szDebugName[128];
char szDebugName[ 128 ];
if( ! s_iUseDebugName )
{
int iRand = (int) (hb_random_num()*1000000);
pFileName = hb_fsFNameSplit( hb_cmdargARGV()[0] );
int iRand = ( int ) ( hb_random_num() * 1000000 );
pFileName = hb_fsFNameSplit( hb_cmdargARGV()[ 0 ] );
hb_snprintf( szDebugName, sizeof( szDebugName ) - 1, "/tmp/%s%d_dbg", pFileName->szName, iRand );
}
else
{
hb_snprintf( szDebugName, sizeof( szDebugName ) - 1, "/tmp/%s_dbg", s_szDebugName );
hb_snprintf( szDebugName, sizeof( szDebugName ), "/tmp/%s_dbg", s_szDebugName );
pFileName = hb_fsFNameSplit( szDebugName );
}
iFifoResult = mkfifo( szDebugName, 0666 );
if ( iFifoResult == -1 )
{
if( iFifoResult == -1 )
iFifoResult = errno;
}
if ( iFifoResult == 0 || iFifoResult == EEXIST )
if( iFifoResult == 0 || iFifoResult == EEXIST )
{
if ( strlen( pFileName->szName ) > 20 )
{
( ( char * ) pFileName->szName )[20] = 0;
}
if( strlen( pFileName->szName ) > 20 )
( ( char * ) pFileName->szName )[ 20 ] = 0;
hb_snprintf( szDebugTitle, sizeof( szDebugTitle ), "%s - Debug", pFileName->szName );
iPid = fork();
if ( iPid != 0 )
if( iPid != 0 )
{
s_iDebugFd = open( szDebugName, O_WRONLY );
s_iXtermPid = iPid;
}
else
{
if ( iFifoResult != EEXIST ) {
if( iFifoResult != EEXIST )
{
s_iXtermPid = execlp( "xterm", "xterm", "-T", szDebugTitle, "-e",
"cat", szDebugName, NULL );
if ( s_iXtermPid <= 0 ) {
if( s_iXtermPid <= 0 )
{
int lastresort = open( szDebugName, O_RDONLY );
if ( lastresort >= 0 )
{
if( lastresort >= 0 )
close( lastresort );
}
}
}
@@ -141,54 +140,53 @@ static void debugInit( void )
BOOL hb_OutDebugName( PHB_ITEM pName )
{
#if defined(HB_OS_UNIX)
BOOL bRet;
if ( s_iDebugFd == 0 && pName != NULL)
#if defined( HB_OS_UNIX )
if( s_iDebugFd == 0 && pName != NULL)
{
hb_strncpy( s_szDebugName, hb_itemGetCPtr( pName ), sizeof( s_szDebugName ) - 1 );
s_iUseDebugName = 1;
bRet = TRUE;
}
else if ( pName == NULL)
else if( pName == NULL)
{
s_iUseDebugName = 0;
bRet = TRUE;
}
else
{
bRet = FALSE;
}
#else
HB_SYMBOL_UNUSED( pName );
bRet = FALSE;
#endif
return bRet;
#endif
}
void hb_OutDebug( const char * szMsg, ULONG ulMsgLen )
{
#if defined(HB_OS_UNIX)
#if defined( HB_OS_UNIX )
int iStatus, iPid;
/* Are we under X? */
if ( getenv("DISPLAY") != NULL)
if( getenv( "DISPLAY" ) != NULL )
{
if ( s_iDebugFd <= 0 || s_iXtermPid == 0 )
{
if( s_iDebugFd <= 0 || s_iXtermPid == 0 )
debugInit();
}
/* On error, drop it */
if ( s_iDebugFd <= 0 || s_iXtermPid == 0 )
{
if( s_iDebugFd <= 0 || s_iXtermPid == 0 )
return;
}
/* Chech if display process has terminated in the meanwhile */
if (! s_iUseDebugName )
if( ! s_iUseDebugName )
{
iPid = waitpid( s_iXtermPid, &iStatus, WNOHANG );
if ( iPid == s_iXtermPid || iPid == -1 )
if( iPid == s_iXtermPid || iPid == -1 )
{
s_iXtermPid = 0;
/* close( s_iDebugFd ); */
@@ -197,7 +195,7 @@ void hb_OutDebug( const char * szMsg, ULONG ulMsgLen )
}
}
if ( s_iDebugFd > 0 && ISCHAR(1) )
if( s_iDebugFd > 0 && ISCHAR(1) )
{
fd_set wrds;
struct timeval tv = { 0, 100000 }; /* wait each time a tenth of second */
@@ -211,7 +209,8 @@ void hb_OutDebug( const char * szMsg, ULONG ulMsgLen )
}
}
}
#elif defined(__WIN32__)
#elif defined( HB_OS_WIN_32 )
{
LPTSTR lpMsg = HB_TCHAR_CONVTO( szMsg );
@@ -221,21 +220,23 @@ void hb_OutDebug( const char * szMsg, ULONG ulMsgLen )
HB_SYMBOL_UNUSED(ulMsgLen);
}
#endif
#else
HB_SYMBOL_UNUSED( szMsg );
HB_SYMBOL_UNUSED( ulMsgLen );
#endif
}
HB_FUNC( HB_OUTDEBUGNAME )
{
#if defined(HB_OS_UNIX)
PHB_ITEM pName = hb_param( 1, HB_IT_STRING );
hb_retl( hb_OutDebugName( pName ) );
#endif
}
HB_FUNC( HB_OUTDEBUG )
{
if( ISCHAR(1) )
hb_OutDebug( hb_parcx(1), hb_parclen(1) );
if( ISCHAR( 1 ) )
hb_OutDebug( hb_parcx( 1 ), hb_parclen( 1 ) );
}

View File

@@ -714,9 +714,7 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT )
pWVT->hFont = hFont;
}
else
{
hFont = pWVT->hFont;
}
hdc = GetDC( pWVT->hWnd );
hOldFont = ( HFONT ) SelectObject( hdc, hFont );