From 6199d29f05c697c35bb9e25e660a8facffc638ac Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 20 Jun 2006 22:54:59 +0000 Subject: [PATCH] 2006-06-21 00:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/config/w32/dir.cf + added EOL at EOF * harbour/config/w32/global.cf * changed clean and dirbase commands to work cleanly with CMD.EXE * harbour/source/rtl/gtwin/gtwin.c * always try to allocate console + added workaround for MSYS console which does not support WriteConsoleOutput()/ReadConsoleInput() * harbour/source/rtl/gtwvt/gtwvt.c * changed default codepage to OEM --- harbour/ChangeLog | 15 ++++++ harbour/config/w32/dir.cf | 2 +- harbour/config/w32/global.cf | 33 +++++++++--- harbour/source/rtl/gtwin/gtwin.c | 90 +++++++++++++++++++------------- harbour/source/rtl/gtwvt/gtwvt.c | 4 +- 5 files changed, 99 insertions(+), 45 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ca432d6c51..f67b3c2f37 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + * harbour/utils/hbtest/rt_hvm.prg + + HB_SYMBOL_UNUSED() added for .prg code. It can suppress unused + Note that there are several false "unreachable code" warnings, + and there are still quite a few unused var warnings inside + codeblocks. After fixing these /w2 switch could be added to + ! Fixed a number (>200) of declared but unused variable /w2 error. + All parts were scanned and fixed (except contrib). + Note that there are several false "unreachable code" warnings, + and there are still quite a few unused var warnings inside + codeblocks. After fixing these /w2 switch could be added to + the standard build process to maintain code quality. + +2006-06-21 00:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/config/w32/dir.cf + + added EOL at EOF * harbour/config/w32/global.cf * changed clean and dirbase commands to work cleanly with CMD.EXE diff --git a/harbour/config/w32/dir.cf b/harbour/config/w32/dir.cf index 65ecabf872..d4792650cd 100644 --- a/harbour/config/w32/dir.cf +++ b/harbour/config/w32/dir.cf @@ -27,4 +27,4 @@ DIR_RULE =\ endif # ! Windows -endif # ! compiling a specific program module \ No newline at end of file +endif # ! compiling a specific program module diff --git a/harbour/config/w32/global.cf b/harbour/config/w32/global.cf index d65526df26..5147e74d46 100644 --- a/harbour/config/w32/global.cf +++ b/harbour/config/w32/global.cf @@ -34,21 +34,42 @@ ifeq ($(COMSPEC),) #location of command.com endif endif +ifeq ($(findstring cmd.exe,$(COMSPEC)),cmd.exe) + CMD_EXE := yes +else + CMD_EXE := no +endif + RM = del RD = rmdir +MD = md CP = copy MV = move -MD = md + +ifeq ($(CMD_EXE),yes) + +RM = del /q /f +RD = rmdir /q /s dirbase:: - -@for %%d in ($(HB_ARCHITECTURE) $(ARCH_DOS)) do if not exist %%d\. $(MD) %%d - -@for %d in ($(HB_ARCHITECTURE) $(ARCH_DOS)) do if not exist %d\. $(MD) %d + -@$(COMSPEC) /c \ + 'for %d in ($(HB_ARCHITECTURE) $(ARCH_DOS)) do if not exist %d\. $(MD) %d' + +clean:: + -@$(COMSPEC) /c \ + 'if exist $(ARCH_DOS) $(RD) $(ARCH_DOS)' + +else # command.com + +dirbase:: + -@for %%d in ($(HB_ARCHITECTURE) $(ARCH_DOS)) do if not exist %%d\nul $(MD) %%d clean:: -@for %%f in ($(ARCH_DOS)\*.* *.bak *.obj *.o *.tds) do $(RM) %%f - -@for %f in ($(ARCH_DOS)\*.* *.bak *.obj *.o *.tds) do $(RM) %f - -@for %%d in ($(ARCH_DOS) $(HB_ARCHITECTURE)) do if exist %%d\. $(RD) %%d - -@for %d in ($(ARCH_DOS) $(HB_ARCHITECTURE)) do if exist %d\NUL $(RD) %d + -@for %%d in ($(ARCH_DOS) $(HB_ARCHITECTURE)) do if exist %%d\nul $(RD) %%d + +endif + else # bash ARCH_DIR = $(HB_ARCH)/ diff --git a/harbour/source/rtl/gtwin/gtwin.c b/harbour/source/rtl/gtwin/gtwin.c index d67d04dca8..8255bd7072 100644 --- a/harbour/source/rtl/gtwin/gtwin.c +++ b/harbour/source/rtl/gtwin/gtwin.c @@ -662,16 +662,40 @@ static void hb_gt_win_Init( FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE /* Add Ctrl+Break handler [vszakats] */ SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, TRUE ); +#ifndef HB_NO_ALLOC_CONSOLE + /* + * This is a hack for MSYS console. It does not support full screen output + * so nothing can be seen on the screen and we have to close the MSYS + * console to be able to allocate the MS-Windows one. + * Unfortunatelly I do not know any method to detect the MSYS console + * so I used this hack with checking OSTYPE environemnt variable. [druzus] + */ + { + char * pszOsType; + + pszOsType = hb_getenv( "OSTYPE" ); + if( pszOsType ) + { + if( strcmp( pszOsType, "msys" ) == 0 ) + FreeConsole(); + hb_xfree( pszOsType ); + } + } + + /* Try to allocate console if we haven't inherited any */ + AllocConsole(); +#endif + if( ( s_HInput = GetStdHandle( STD_INPUT_HANDLE ) ) == INVALID_HANDLE_VALUE ) { #ifdef HB_NO_ALLOC_CONSOLE /* allocate console only when debugger is linked */ if( hb_dynsymFindName( "__DBGENTRY" ) ) -#endif { AllocConsole(); /* It is a Windows app without a console, so we create one */ s_HInput = GetStdHandle( STD_INPUT_HANDLE ); } +#endif if( s_HInput == INVALID_HANDLE_VALUE ) { hb_errInternal( 10001, "Can't allocate console", "", "" ); @@ -680,46 +704,44 @@ static void hb_gt_win_Init( FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE HB_GTSUPER_INIT( hFilenoStdin, hFilenoStdout, hFilenoStderr ); - s_HOutput = CreateFile( "CONOUT$", /* filename */ + s_HOutput = CreateFile( "CONOUT$", /* filename */ GENERIC_READ | GENERIC_WRITE, /* Access flag */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ NULL, /* security attributes */ OPEN_EXISTING, /* create mode */ 0, 0 ); - if( s_HOutput != INVALID_HANDLE_VALUE ) - { - GetConsoleScreenBufferInfo( s_HOutput, &s_csbi ); + if( s_HOutput == INVALID_HANDLE_VALUE ) + hb_errInternal( 10001, "Can't allocate console (output)", "", "" ); - /* save screen info to restore on exit */ - memcpy( &s_origCsbi, &s_csbi, sizeof( s_csbi ) ); + s_HInput = CreateFile( "CONIN$", /* filename */ + GENERIC_READ | GENERIC_WRITE, /* Access flag */ + FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ + NULL, /* security attributes */ + OPEN_EXISTING, /* create mode */ + 0, 0 ); - s_csbi.srWindow.Top = s_csbi.srWindow.Left = 0; - s_csbi.srWindow.Right = HB_MIN( s_csbi.srWindow.Right, _GetScreenWidth()-1 ); - s_csbi.srWindow.Bottom = HB_MIN( s_csbi.srWindow.Bottom, _GetScreenHeight()-1 ); + if( s_HInput == INVALID_HANDLE_VALUE ) + hb_errInternal( 10001, "Can't allocate console (input)", "", "" ); - SetConsoleWindowInfo( s_HOutput, TRUE, &s_csbi.srWindow ); - SetConsoleScreenBufferSize( s_HOutput, s_csbi.dwSize ); + GetConsoleScreenBufferInfo( s_HOutput, &s_csbi ); - hb_gt_win_xInitScreenParam(); - } + /* save screen info to restore on exit */ + memcpy( &s_origCsbi, &s_csbi, sizeof( s_csbi ) ); - if( s_HInput != INVALID_HANDLE_VALUE ) - { - if( b_MouseEnable ) - { - /* With Mouse */ - SetConsoleMode( s_HInput, ENABLE_MOUSE_INPUT ); - } - else - { - /* NOMOUSE */ - DWORD dwmode; + s_csbi.srWindow.Top = s_csbi.srWindow.Left = 0; + s_csbi.srWindow.Right = HB_MIN( s_csbi.srWindow.Right, _GetScreenWidth()-1 ); + s_csbi.srWindow.Bottom = HB_MIN( s_csbi.srWindow.Bottom, _GetScreenHeight()-1 ); - GetConsoleMode( s_HInput, &dwmode ); - SetConsoleMode( s_HInput, dwmode & ~ENABLE_MOUSE_INPUT ); - } - } + SetConsoleWindowInfo( s_HOutput, TRUE, &s_csbi.srWindow ); + SetConsoleScreenBufferSize( s_HOutput, s_csbi.dwSize ); + + hb_gt_win_xInitScreenParam(); + + GetConsoleMode( s_HOutput, &s_dwomode ); + GetConsoleMode( s_HInput, &s_dwimode ); + + SetConsoleMode( s_HInput, b_MouseEnable ? ENABLE_MOUSE_INPUT : 0x0000 ); } /* *********************************************************************** */ @@ -849,14 +871,10 @@ static BOOL hb_gt_win_Suspend() if( s_pCharInfoScreen ) { - GetConsoleMode( s_HInput, &s_dwimode ); - GetConsoleMode( s_HOutput, &s_dwomode ); SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, FALSE ); SetConsoleCtrlHandler( NULL, TRUE ); - if( b_MouseEnable ) - { - SetConsoleMode( s_HInput, s_dwimode & ~ENABLE_MOUSE_INPUT ); - } + SetConsoleMode( s_HOutput, s_dwomode ); + SetConsoleMode( s_HInput, s_dwimode ); } return TRUE; } @@ -869,8 +887,8 @@ static BOOL hb_gt_win_Resume() { SetConsoleCtrlHandler( NULL, FALSE ); SetConsoleCtrlHandler( hb_gt_win_CtrlHandler, TRUE ); - SetConsoleMode( s_HInput, s_dwimode ); SetConsoleMode( s_HOutput, s_dwomode ); + SetConsoleMode( s_HInput, b_MouseEnable ? ENABLE_MOUSE_INPUT : 0x0000 ); hb_gt_win_xInitScreenParam(); hb_gt_win_xSetCursorStyle(); } diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 16a4ba5bb8..82664b052c 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -155,8 +155,8 @@ static void hb_gt_wvt_InitStatics( void ) _s.fontQuality = DEFAULT_QUALITY; strcpy( _s.fontFace,"Courier New" ); - _s.CentreWindow = TRUE; /* Default is to always display window in centre of screen */ - _s.CodePage = GetACP() ; /* Set code page to default system */ + _s.CentreWindow = TRUE; /* Default is to always display window in centre of screen */ + _s.CodePage = OEM_CHARSET; /* GetACP(); - set code page to default system */ _s.Win9X = ( s_osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ); _s.AltF4Close = FALSE;