diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cde2d840d4..ce16eb14e2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,22 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-08-25 14:46 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/vm/cmdarg.c + ! hb_hInstance, hb_hPrevInstance, s_iCmdShow, s_WinMainParam + vars marked as 'static', hb_ prefix changed to s_. + NOTE: This may pose a problem if some 3rd party code + was relying on the names or the fact that these + vars were exported by incident (since they were + not declared in any Harbour headers.) + [INCOMPATIBLE] + + * contrib/hbwhat32/whtmain.c + ! Removed WinMain() function and some global vars colliding + with some Harbour core ones. + * HINSTANCE(), HPREVINSTANCE(), NCMDSHOW() functions now + use Harbour API calls to retrieve values. + 2008-08-25 14:12 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * make_vc.mak * make_vcce.mak diff --git a/harbour/contrib/hbwhat32/whtmain.c b/harbour/contrib/hbwhat32/whtmain.c index 6943138f12..43eeeeedf9 100644 --- a/harbour/contrib/hbwhat32/whtmain.c +++ b/harbour/contrib/hbwhat32/whtmain.c @@ -53,94 +53,35 @@ #define HB_OS_WIN_32_USED #include "hbapi.h" -#include "hbvm.h" #if defined(HB_OS_WIN_32) -int argc = 0; -char * argv[ 20 ]; - -HANDLE hb_hInstance = 0; -HANDLE hb_hPrevInstance = 0; -int hb_iCmdShow = 0; - -int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ - HINSTANCE hPrevInstance, /* handle to previous instance */ - LPSTR lpCmdLine, /* pointer to command line */ - int iCmdShow ) /* show state of window */ -{ - LPSTR pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( lpCmdLine ) + 1 ), pArg = pArgs; - char szAppName[ 250 ]; - - hb_hInstance = hInstance; - hb_hPrevInstance = hPrevInstance; - hb_iCmdShow = iCmdShow; - - hb_strncpy( pArgs, lpCmdLine, strlen( lpCmdLine ) ); - - HB_TRACE(HB_TR_DEBUG, ("WinMain(%p, %p, %s, %d)", hInstance, hPrevInstance, lpCmdLine, iCmdShow)); - - HB_SYMBOL_UNUSED( hPrevInstance ); - HB_SYMBOL_UNUSED( iCmdShow ); - - hb_hInstance = hInstance; - hb_hPrevInstance = hPrevInstance; - hb_iCmdShow = iCmdShow; - - GetModuleFileName( hInstance, szAppName, 249 ); - argv[ 0 ] = szAppName; - - if( * pArgs != 0 ) - argv[ ++argc ] = pArgs; - - while( *pArg != 0 ) - { - if( *pArg == ' ' ) - { - *pArg++ = 0; - argc++; - - while( *pArg == ' ' ) - pArg++; - - if( *pArg != 0 ) - argv[ argc ] = pArg++; - else - argc--; - } - else - pArg++; - } - argc++; - - hb_cmdargInit( argc, argv ); - hb_vmInit( TRUE ); - hb_vmQuit(); - - LocalFree( pArgs ); /* QUESTION: It seems we never reach here, - so how may we free it ? */ - - /* NOTE: The exit value is set by exit() */ - /* NOTE: This point is never reached */ - - return 0; -} - -// don not use GetInstance(), because it is an API, which means something else +// don't not use GETINSTANCE(), because it is an API, which means something else HB_FUNC( HINSTANCE ) { - hb_retnl( (LONG) hb_hInstance ); + HANDLE hInstance; + + hb_winmainArgGet( &hInstance, NULL, NULL ); + + hb_retnl( ( LONG ) hInstance ); } HB_FUNC( HPREVINSTANCE ) { - hb_retnl( (LONG) hb_hPrevInstance ); + HANDLE hPrevInstance; + + hb_winmainArgGet( NULL, &hPrevInstance, NULL ); + + hb_retnl( ( LONG ) hPrevInstance ); } HB_FUNC( NCMDSHOW ) { - hb_retni( hb_iCmdShow ); + int iCmdShow; + + hb_winmainArgGet( NULL, NULL, &iCmdShow ); + + hb_retni( iCmdShow ); } - #endif diff --git a/harbour/source/vm/cmdarg.c b/harbour/source/vm/cmdarg.c index 892dfed510..6081bf3b1e 100644 --- a/harbour/source/vm/cmdarg.c +++ b/harbour/source/vm/cmdarg.c @@ -68,17 +68,17 @@ static char ** s_argv = NULL; HB_EXTERN_BEGIN -HANDLE hb_hInstance = 0; -HANDLE hb_hPrevInstance = 0; -int s_iCmdShow = 0; -BOOL s_WinMainParam = FALSE; +static HANDLE s_hInstance = 0; +static HANDLE s_hPrevInstance = 0; +static int s_iCmdShow = 0; +static BOOL s_WinMainParam = FALSE; HB_EXTERN_END HB_EXPORT void hb_winmainArgInit( HANDLE hInstance, HANDLE hPrevInstance, int iCmdShow ) { - hb_hInstance = hInstance; - hb_hPrevInstance = hPrevInstance; + s_hInstance = hInstance; + s_hPrevInstance = hPrevInstance; s_iCmdShow = iCmdShow; s_WinMainParam = TRUE; } @@ -86,9 +86,9 @@ HB_EXPORT void hb_winmainArgInit( HANDLE hInstance, HANDLE hPrevInstance, int iC HB_EXPORT BOOL hb_winmainArgGet( HANDLE * phInstance, HANDLE * phPrevInstance, int * piCmdShow ) { if( phInstance ) - *phInstance = hb_hInstance; + *phInstance = s_hInstance; if( phPrevInstance ) - *phPrevInstance = hb_hPrevInstance; + *phPrevInstance = s_hPrevInstance; if( piCmdShow ) *piCmdShow = s_iCmdShow;