From 4fd0cafdd2ad120fdc3dc56da50ee4aecdd41beb Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 18 Feb 2009 09:20:39 +0000 Subject: [PATCH] 2009-02-18 10:25 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapi.h * harbour/source/vm/cmdarg.c * harbour/source/vm/hvm.c * added hb_cmdargUpdate() function which makes final argc/argv updating (code moved from hb_cmdargInit()) ! use hb_cmdargUpdate() - it fixes GPF in MT mode when some fs* functions were called before allocating HVM stack ; TOFIX: change some hb_setGet*() functions to work without HVM stack. * harbour/source/rtl/hbtoken.c * formatting --- harbour/ChangeLog | 13 +++++++++++++ harbour/include/hbapi.h | 1 + harbour/source/rtl/hbtoken.c | 2 +- harbour/source/vm/cmdarg.c | 35 ++++++++++++++++++++--------------- harbour/source/vm/hvm.c | 6 ++++++ 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 74e5824fc5..d232bb50e4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-18 10:25 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapi.h + * harbour/source/vm/cmdarg.c + * harbour/source/vm/hvm.c + * added hb_cmdargUpdate() function which makes final argc/argv updating + (code moved from hb_cmdargInit()) + ! use hb_cmdargUpdate() - it fixes GPF in MT mode when some fs* functions + were called before allocating HVM stack + ; TOFIX: change some hb_setGet*() functions to work without HVM stack. + + * harbour/source/rtl/hbtoken.c + * formatting + 2009-02-18 02:03 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk/hbmk2.prg ! Fixed not recognising hbp lines if the filter was at BOL. diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index edde25e237..dfdaf7c5f5 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -908,6 +908,7 @@ extern HB_EXPORT PHB_SYMB hb_symbolNew( const char * szName ); /* create a new /* Command line and environment argument management */ extern HB_EXPORT void hb_cmdargInit( int argc, char * argv[] ); /* initialize command line argument API's */ +extern void hb_cmdargUpdate( void ); /* update arguments after HVM initialization */ extern int hb_cmdargARGC( void ); /* retrieve command line argument count */ extern char ** hb_cmdargARGV( void ); /* retrieve command line argument buffer pointer */ extern const char * hb_cmdargARGVN( int argc ); /* retrieve given command line argument */ diff --git a/harbour/source/rtl/hbtoken.c b/harbour/source/rtl/hbtoken.c index d2bddcce39..292b27e142 100644 --- a/harbour/source/rtl/hbtoken.c +++ b/harbour/source/rtl/hbtoken.c @@ -146,7 +146,7 @@ static PHB_ITEM hb_tokenArray( const char * szLine, ULONG ulLen, { ULONG ul, ulStart, ulToken; char cQuote = 0; - + for( ul = ulStart = ulToken = 0; ul < ulLen; ++ul ) { if( cQuote ) diff --git a/harbour/source/vm/cmdarg.c b/harbour/source/vm/cmdarg.c index 9e865051eb..1131e1a42d 100644 --- a/harbour/source/vm/cmdarg.c +++ b/harbour/source/vm/cmdarg.c @@ -104,6 +104,26 @@ void hb_cmdargInit( int argc, char * argv[] ) s_argc = argc; s_argv = argv; +} + +int hb_cmdargARGC( void ) +{ + return s_argc; +} + +char ** hb_cmdargARGV( void ) +{ + return s_argv; +} + +const char * hb_cmdargARGVN( int argc ) +{ + return argc >= 0 && argc < s_argc ? s_argv[ argc ] : NULL; +} + +void hb_cmdargUpdate( void ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_cmdargUpdate()")); #if defined( HB_OS_WIN ) @@ -188,21 +208,6 @@ void hb_cmdargInit( int argc, char * argv[] ) #endif } -int hb_cmdargARGC( void ) -{ - return s_argc; -} - -char ** hb_cmdargARGV( void ) -{ - return s_argv; -} - -const char * hb_cmdargARGVN( int argc ) -{ - return argc >= 0 && argc < s_argc ? s_argv[ argc ] : NULL; -} - BOOL hb_cmdargIsInternal( const char * szArg, int * piLen ) { HB_TRACE(HB_TR_DEBUG, ("hb_cmdargIsInternal(%s, %p)", szArg, piLen)); diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 4c26451f0e..641b2e7645 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -681,6 +681,10 @@ static void hb_vmStackRelease( void ) HB_VM_UNLOCK + /* NOTE: releasing pThItm may force pState freeing if parent + * thread does not keep thread pointer item. So it's + * important to not access it later. [druzus] + */ if( pThItm ) hb_itemRelease( pThItm ); @@ -871,6 +875,8 @@ void hb_vmInit( BOOL bStartMainProc ) hb_setInitialize( hb_stackSetStruct() ); } + hb_cmdargUpdate(); + hb_clsInit(); /* initialize Classy/OO system */ hb_errInit();