From 5a1ec7b3a53467bb62f42d68b13453a87ddccc69 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 31 Jan 2013 23:26:33 +0000 Subject: [PATCH] 2013-02-01 00:26 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/include/hbwinuni.h + added HB_WINAPI_SYSTEM() macro * harbour/src/rtl/run.c * harbour/src/rtl/hbrunfun.c ! use MSCRTL system call in desktop MS-Windows builds of __RUN() and HB_RUN() functions. It restores Clipper compatible __RUN() behavior and now both functions work in the same way on all platforms except WinCE/Mobile which does not have shell system. --- harbour/ChangeLog.txt | 12 ++++++++++++ harbour/include/hbwinuni.h | 2 ++ harbour/src/rtl/hbrunfun.c | 13 ++++++++++++- harbour/src/rtl/run.c | 15 +++++++++++++-- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog.txt b/harbour/ChangeLog.txt index d38b8c1b6f..66f104d293 100644 --- a/harbour/ChangeLog.txt +++ b/harbour/ChangeLog.txt @@ -10,6 +10,18 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-02-01 00:26 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/include/hbwinuni.h + + added HB_WINAPI_SYSTEM() macro + + * harbour/src/rtl/run.c + * harbour/src/rtl/hbrunfun.c + ! use MSCRTL system call in desktop MS-Windows builds of __RUN() + and HB_RUN() functions. + It restores Clipper compatible __RUN() behavior and now both + functions work in the same way on all platforms except WinCE/Mobile + which does not have shell system. + 2013-02-01 00:05 UTC+0100 Viktor Szakats (harbour syenar.net) * ChangeLog.txt + added encoding information to the header, which is UTF-8 diff --git a/harbour/include/hbwinuni.h b/harbour/include/hbwinuni.h index 3e5347a652..53f5811fb6 100644 --- a/harbour/include/hbwinuni.h +++ b/harbour/include/hbwinuni.h @@ -89,6 +89,7 @@ #define HB_CHARDUPN( str, len ) hb_osStrU16EncodeN( str, len ) #define HB_OSSTRDUP( str ) hb_osStrU16Decode( str ) #define HB_OSSTRDUP2( str, buf, len ) hb_osStrU16Decode2( str, buf, len ) + #define HB_WINAPI_SYSTEM( cmd ) _wsystem( cmd ) #define HB_WINAPI_FUNCTION_NAME( a ) ( a "W" ) #define HB_WINAPI_KERNEL32_DLL() ( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ) #else @@ -121,6 +122,7 @@ #define HB_CHARDUPN( str, len ) hb_osStrEncodeN( str, len ) #define HB_OSSTRDUP( str ) hb_osStrDecode( str ) #define HB_OSSTRDUP2( str, buf, len ) hb_osStrDecode2( str, buf, len ) + #define HB_WINAPI_SYSTEM( cmd ) system( cmd ) #define HB_WINAPI_FUNCTION_NAME( a ) ( a "A" ) #define HB_WINAPI_KERNEL32_DLL() ( TEXT( "kernel32.dll" ) ) #endif diff --git a/harbour/src/rtl/hbrunfun.c b/harbour/src/rtl/hbrunfun.c index acae8188f9..ca4ef14e55 100644 --- a/harbour/src/rtl/hbrunfun.c +++ b/harbour/src/rtl/hbrunfun.c @@ -56,6 +56,11 @@ #include "hbapiitm.h" #include "hbapifs.h" +#if defined( HB_OS_WIN ) + #include "hbwinuni.h" + #include +#endif + HB_FUNC( HB_RUN ) { const char * pszCommand = hb_parc( 1 ); @@ -66,9 +71,15 @@ HB_FUNC( HB_RUN ) if( hb_gtSuspend() == HB_SUCCESS ) { -#if defined( HB_OS_WIN ) +#if defined( HB_OS_WIN_CE ) iResult = hb_fsProcessRun( pszCommand, NULL, 0, NULL, NULL, NULL, NULL, HB_FALSE ); +#elif defined( HB_OS_WIN ) + LPTSTR lpCommand; + + lpCommand = HB_CHARDUP( pszCommand ); + iResult = HB_WINAPI_SYSTEM( lpCommand ); + hb_xfree( lpCommand ); #else char * pszFree = NULL; diff --git a/harbour/src/rtl/run.c b/harbour/src/rtl/run.c index 861e8d3d16..fb9f1e1862 100644 --- a/harbour/src/rtl/run.c +++ b/harbour/src/rtl/run.c @@ -56,6 +56,11 @@ #include "hbapiitm.h" #include "hbapifs.h" +#if defined( HB_OS_WIN ) + #include "hbwinuni.h" + #include +#endif + /* TOFIX: The screen buffer handling is not right for all platforms (Windows) The output of the launched (MS-DOS?) app is not visible. */ @@ -65,12 +70,18 @@ HB_FUNC( __RUN ) if( pszCommand && hb_gtSuspend() == HB_SUCCESS ) { -#if defined( HB_OS_WIN ) +#if defined( HB_OS_WIN_CE ) hb_fsProcessRun( pszCommand, NULL, 0, NULL, NULL, NULL, NULL, HB_FALSE ); +#elif defined( HB_OS_WIN ) + LPTSTR lpCommand; + + lpCommand = HB_CHARDUP( pszCommand ); + ( void ) HB_WINAPI_SYSTEM( lpCommand ); + hb_xfree( lpCommand ); #else char * pszFree = NULL; - if( system( hb_osEncodeCP( pszCommand, &pszFree, NULL ) ) != 0 ) {} + ( void ) system( hb_osEncodeCP( pszCommand, &pszFree, NULL ) ); if( pszFree ) hb_xfree( pszFree );