From 5c1b1da3ab398f563d49707bca526bb203dab106 Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Sun, 13 Aug 2000 05:00:21 +0000 Subject: [PATCH] 20000813-06:55 GMT+1 --- harbour/ChangeLog | 23 ++++++++++++-------- harbour/source/vm/mainwin.c | 42 +++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 99515798b9..d1105ca7ce 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,8 @@ +2000-08-13 06:55 GMT + 1 Antonio Linares + * source/vm/mainwin.c + Enhanced so it now process command line arguments. + (bug reported by Patrick Mast) + 2000-08-12 20:20 GMT -3 Luiz Rafael Culik *doc/en/compiler.txt doc/en/harbext.txt @@ -37,16 +42,16 @@ Changelog: 2000-08-12 20:00 UTC+0500 April White *source/pp/ppcode.c * fixed '\`' into '`' to stop warning in GCC - + *source/compiler/harbour.l - * fixed handling of TEXT/ENDTEXT - it is not active now + * fixed handling of TEXT/ENDTEXT - it is not active now 'if( 0 )' since it requires more support from the preprocessor. The preprocessor have to set some flag when text block is - processed to suppres errorneous compilation if normal + processed to suppres errorneous compilation if normal (not preprocessed) code in case of: QOUT([some]) ; QOUT([string]) * added support for nested '[]' string delimiters that can - be created by the preprocessor + be created by the preprocessor * fixed handling of 'FOR(' syntax - it is now fully Clipper compatible. @@ -54,7 +59,7 @@ Changelog: 2000-08-12 20:00 UTC+0500 April White * fixed handling of FOR (expression):=... TO ... syntax ( Clipper compiles: FOR (a:=1,b:=2,i):=1 TO 10 ) although it needs some more work. - + 2000-07-29 03:00 UTC+0500 April White + doc/en/ + (re)added hbvm.txt, hbapiitm.txt, hbapirdd.txt, hbmacro.txt, @@ -76,9 +81,9 @@ Changelog: 2000-08-12 20:00 UTC+0500 April White QOUT("...") or QOUT([...]) - with no spaces. [] string delimiters are used if any combination + with no spaces. [] string delimiters are used if any combination of "'[] are used inside a text. - Notice that during preprocessing of normal code when [] string + Notice that during preprocessing of normal code when [] string delimiters are used then Clipper uses the first closing ] character as a string terminator. @@ -92,12 +97,12 @@ Changelog: 2000-08-12 20:00 UTC+0500 April White *source/compiler/harbour.l * fixed DO DECLARE syntax - + 2000-08-10 11:50 UTC+0100 Ryszard Glab *source/compiler/harbour.l * fixed handling of while[] and case[] - * YY_USER_ACTION placed into a comment (the resulting + * YY_USER_ACTION placed into a comment (the resulting object file is 20kB smaller) 2000-08-09 20:00 UTC+0800 Ron Pinkas diff --git a/harbour/source/vm/mainwin.c b/harbour/source/vm/mainwin.c index 61929cfc82..06642cc143 100644 --- a/harbour/source/vm/mainwin.c +++ b/harbour/source/vm/mainwin.c @@ -40,6 +40,9 @@ #if defined(HB_OS_WIN_32) +int argc = 0; +char * argv[ 20 ]; + HANDLE hb_hInstance = 0; HANDLE hb_hPrevInstance = 0; @@ -48,21 +51,49 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ LPSTR lpCmdLine, /* pointer to command line */ int iCmdShow ) /* show state of window */ { - char * argv[ 1 ]; /* TODO: parse lpCmdLine and generate the proper values */ + LPSTR pArgs = LocalAlloc( LMEM_FIXED, strlen( lpCmdLine ) + 1 ), pArg = pArgs; + BYTE bAppName[ 250 ]; + + strcpy( pArgs, lpCmdLine ); HB_TRACE(HB_TR_DEBUG, ("WinMain(%p, %p, %s, %d)", hInstance, hPrevInstance, lpCmdLine, iCmdShow)); - HB_SYMBOL_UNUSED( hInstance ); HB_SYMBOL_UNUSED( hPrevInstance ); - HB_SYMBOL_UNUSED( lpCmdLine ); HB_SYMBOL_UNUSED( iCmdShow ); - argv[ 0 ] = NULL; /* TOFIX: Generate argv/argc from commandline */ + GetModuleFileName( hInstance, bAppName, 249 ); + argv[ 0 ] = bAppName; - hb_cmdargInit( 0, argv ); + 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 */ @@ -70,4 +101,3 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ } #endif -