From 96a0d522c28a865147d5a0d1c6af5a4f8d4530b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Thu, 17 Sep 2015 15:52:17 +0200 Subject: [PATCH] 2015-09-17 15:52 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/fscopy.c * pacified BCC warning * src/rtl/hbproces.c * added HB_PROCESS_USEFILES macro which enable child process standard IO handles redirection to files instead of pipes in hb_fsProcessRun() function. It's enabled by default in DOS and WinCE builds * enable HB_PROCESS_USEFILES for tests in OS2 builds --- ChangeLog.txt | 11 ++++++ src/rtl/fscopy.c | 2 +- src/rtl/hbproces.c | 87 +++++++++++++++++++++++++--------------------- 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0a13ed08bd..9ed56e99a5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,17 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-09-17 15:52 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/fscopy.c + * pacified BCC warning + + * src/rtl/hbproces.c + * added HB_PROCESS_USEFILES macro which enable child process + standard IO handles redirection to files instead of pipes + in hb_fsProcessRun() function. It's enabled by default in + DOS and WinCE builds + * enable HB_PROCESS_USEFILES for tests in OS2 builds + 2015-09-17 12:23 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/hbapicls.h * src/vm/classes.c diff --git a/src/rtl/fscopy.c b/src/rtl/fscopy.c index 7adfe87570..301e15cd92 100644 --- a/src/rtl/fscopy.c +++ b/src/rtl/fscopy.c @@ -59,7 +59,7 @@ HB_BOOL hb_fsCopy( const char * pszSource, const char * pszDest ) if( ( pSrcFile = hb_fileExtOpen( pszSource, NULL, FO_READ | FO_SHARED | FXO_SHARELOCK, NULL, NULL ) ) != NULL ) { - HB_ERRCODE errCode = 0; + HB_ERRCODE errCode; if( ( pDstFile = hb_fileExtOpen( pszDest, NULL, FXO_TRUNCATE | FO_READWRITE | FO_EXCLUSIVE | FXO_SHARELOCK, NULL, NULL ) ) != NULL ) { diff --git a/src/rtl/hbproces.c b/src/rtl/hbproces.c index 8635af5304..c09860e802 100644 --- a/src/rtl/hbproces.c +++ b/src/rtl/hbproces.c @@ -88,6 +88,12 @@ # endif #endif +#ifndef HB_PROCESS_USEFILES +# if defined( HB_OS_DOS ) || defined( HB_OS_WIN_CE ) || defined( HB_OS_OS2 ) +# define HB_PROCESS_USEFILES +# endif +#endif + #if defined( HB_OS_OS2 ) static char * hb_buildArgsOS2( const char *pszFileName ) @@ -131,7 +137,45 @@ static char * hb_buildArgsOS2( const char *pszFileName ) #endif -#if defined( HB_OS_DOS ) || defined( HB_OS_UNIX ) +#if defined( HB_OS_WIN_CE ) && defined( HB_PROCESS_USEFILES ) + +static void hb_getCommand( const char * pszFileName, + LPTSTR * lpAppName, LPTSTR * lpParams ) +{ + const char * src, * params; + char cQuote = 0; + + while( HB_ISSPACE( *pszFileName ) ) + ++pszFileName; + + params = NULL; + src = pszFileName; + while( *src ) + { + if( *src == cQuote ) + cQuote = 0; + else if( cQuote == 0 ) + { + if( *src == '"' ) + cQuote = *src; + else if( HB_ISSPACE( *src ) ) + { + params = src; + while( HB_ISSPACE( *params ) ) + ++params; + if( *params == 0 ) + params = NULL; + break; + } + } + ++src; + } + + *lpParams = params ? HB_CHARDUP( params ) : NULL; + *lpAppName = HB_CHARDUPN( pszFileName, src - pszFileName ); +} + +#elif defined( HB_PROCESS_USEFILES ) || defined( HB_OS_UNIX ) /* convert command to argument list using standard bourne shell encoding: * "" and '' can be used to group parameters with blank characters, @@ -237,46 +281,9 @@ static void hb_freeArgs( char ** argv ) hb_xfree( argv ); } -#elif defined( HB_OS_WIN_CE ) - -static void hb_getCommand( const char * pszFileName, - LPTSTR * lpAppName, LPTSTR * lpParams ) -{ - const char * src, * params; - char cQuote = 0; - - while( HB_ISSPACE( *pszFileName ) ) - ++pszFileName; - - params = NULL; - src = pszFileName; - while( *src ) - { - if( *src == cQuote ) - cQuote = 0; - else if( cQuote == 0 ) - { - if( *src == '"' ) - cQuote = *src; - else if( HB_ISSPACE( *src ) ) - { - params = src; - while( HB_ISSPACE( *params ) ) - ++params; - if( *params == 0 ) - params = NULL; - break; - } - } - ++src; - } - - *lpParams = params ? HB_CHARDUP( params ) : NULL; - *lpAppName = HB_CHARDUPN( pszFileName, src - pszFileName ); -} #endif -#if defined( HB_OS_DOS ) || defined( HB_OS_WIN_CE ) +#if defined( HB_PROCESS_USEFILES ) static int hb_fsProcessExec( const char * pszFileName, HB_FHANDLE hStdin, HB_FHANDLE hStdout, HB_FHANDLE hStderr ) @@ -1059,7 +1066,7 @@ int hb_fsProcessRun( const char * pszFileName, phStderr = pStdErrPtr && pulStdErr ? ( pStdOutPtr == pStdErrPtr ? phStdout : &hStderr ) : NULL; -#if defined( HB_OS_DOS ) || defined( HB_OS_WIN_CE ) +#if defined( HB_PROCESS_USEFILES ) { #if defined( HB_OS_WIN_CE )