From 9c50617dbe175e483537b56441238da95ff994f7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 21 Nov 2012 00:16:52 +0000 Subject: [PATCH] 2012-11-21 01:07 UTC+0100 Viktor Szakats (harbour syenar.net) * utils/hbmk2/hbmk2.prg + implemented theoretically correct solution to extract linker output _while_ displaying it. It means that missing function hinting feature doesn't require a second pass to the linker anymore. ; Please test on all platforms. ; For those two people interested, it will create output like this: --- hbmk2: Hint: Add option 'hbct.hbc' for missing function(s): CharMirr() hbmk2: Hint: Add option 'hbusb.hbc' for missing function(s): libusb_exit() hbmk2: Hint: Add option 'hbsms.hbc' for missing function(s): smsctx_PIN() hbmk2: Error: Referenced, missing, but unknown function(s): NOTANYWHERE() --- * extras/httpsrv/uhttpd.prg ! fixed some code for unicode % fixed to not call FCLOSE() on a HB_PROCESSOPEN() handle * use F_ERROR instead of -1 literal * commented code converted to #if 0/#endif guarded one * src/rtl/hbprocfn.c * formatting * tests/fixcase.hb * new extension exceptions --- harbour/ChangeLog | 27 +++++++++++++++ harbour/extras/httpsrv/uhttpd.prg | 15 ++++----- harbour/src/rtl/hbprocfn.c | 2 +- harbour/tests/fixcase.hb | 5 ++- harbour/utils/hbmk2/hbmk2.prg | 55 ++++++++++++++++++++----------- 5 files changed, 74 insertions(+), 30 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8c31d54c02..d3a33b134f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -10,6 +10,33 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2012-11-21 01:07 UTC+0100 Viktor Szakats (harbour syenar.net) + * utils/hbmk2/hbmk2.prg + + implemented theoretically correct solution to extract + linker output _while_ displaying it. It means that + missing function hinting feature doesn't require + a second pass to the linker anymore. + ; Please test on all platforms. + ; For those two people interested, it will create output like this: + --- + hbmk2: Hint: Add option 'hbct.hbc' for missing function(s): CharMirr() + hbmk2: Hint: Add option 'hbusb.hbc' for missing function(s): libusb_exit() + hbmk2: Hint: Add option 'hbsms.hbc' for missing function(s): smsctx_PIN() + hbmk2: Error: Referenced, missing, but unknown function(s): NOTANYWHERE() + --- + + * extras/httpsrv/uhttpd.prg + ! fixed some code for unicode + % fixed to not call FCLOSE() on a HB_PROCESSOPEN() handle + * use F_ERROR instead of -1 literal + * commented code converted to #if 0/#endif guarded one + + * src/rtl/hbprocfn.c + * formatting + + * tests/fixcase.hb + * new extension exceptions + 2012-11-21 00:14 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/gtwvg/gtwgud.c * contrib/gtwvg/gtwvgd.c diff --git a/harbour/extras/httpsrv/uhttpd.prg b/harbour/extras/httpsrv/uhttpd.prg index bd6ec07f1d..f316093aea 100644 --- a/harbour/extras/httpsrv/uhttpd.prg +++ b/harbour/extras/httpsrv/uhttpd.prg @@ -1517,7 +1517,7 @@ STATIC FUNCTION CGIExec( cProc, /*@*/ cOutPut ) // hb_ToOutDebug( "New 2 Path: %s\n\r", hb_CurDrive() + hb_osDriveSeparator() + hb_ps() + CurDir() ) - IF hProc > -1 + IF hProc != F_ERROR // hb_ToOutDebug( "Process handler: %s\n\r", hProc ) // hb_ToOutDebug( "Error: %s\n\r", FError() ) @@ -1536,21 +1536,21 @@ STATIC FUNCTION CGIExec( cProc, /*@*/ cOutPut ) // hb_ToOutDebug( "Reading output\n\r" ) cData := Space( 1000 ) cOutPut := "" - DO WHILE ( nLen := FRead( hOut, @cData, Len( cData ) ) ) > 0 - cOutPut += SubStr( cData, 1, nLen ) + DO WHILE ( nLen := FRead( hOut, @cData, hb_BLen( cData ) ) ) > 0 + cOutPut += hb_BLeft( cData, nLen ) cData := Space( 1000 ) ENDDO - /* + #if 0 cData := Space( 1000 ) cError := "" - DO WHILE ( nLen := FRead( hErr, @cData, Len( cData ) ) ) > 0 - cError += SubStr( cData, 1, nLen ) + DO WHILE ( nLen := FRead( hErr, @cData, hb_BLen( cData ) ) ) > 0 + cError += hb_BLeft( cData, nLen ) cData := Space( 1000 ) ENDDO cOutPut += cError - */ + #endif // hb_ToOutDebug( "Received: cOutPut = %s\n\r", cOutPut ) @@ -1570,7 +1570,6 @@ STATIC FUNCTION CGIExec( cProc, /*@*/ cOutPut ) nErrorLevel := nKillExit ENDIF - FClose( hProc ) FClose( hIn ) FClose( hOut ) // FClose( hErr ) diff --git a/harbour/src/rtl/hbprocfn.c b/harbour/src/rtl/hbprocfn.c index b24959fee4..4806221cd4 100644 --- a/harbour/src/rtl/hbprocfn.c +++ b/harbour/src/rtl/hbprocfn.c @@ -59,7 +59,7 @@ HB_FUNC( HB_PROCESSOPEN ) { - const char *szName = hb_parc( 1 ); + const char * szName = hb_parc( 1 ); PHB_ITEM pStdIn = hb_param( 2, HB_IT_BYREF ); PHB_ITEM pStdOut = hb_param( 3, HB_IT_BYREF ); PHB_ITEM pStdErr = hb_param( 4, HB_IT_BYREF ); diff --git a/harbour/tests/fixcase.hb b/harbour/tests/fixcase.hb index 2d6c6a726e..9165d6cdb3 100644 --- a/harbour/tests/fixcase.hb +++ b/harbour/tests/fixcase.hb @@ -29,6 +29,8 @@ PROCEDURE Main() LOCAL hExtExceptions := { ; hb_libExt() => NIL, ; ".zip" => NIL, ; + ".7z" => NIL, ; + ".exe" => NIL, ; ".o" => NIL, ; ".js" => NIL, ; ".dif" => NIL, ; @@ -102,7 +104,8 @@ PROCEDURE Main() FOR EACH aFile IN hb_DirScan( "", hb_osFileMask() ) cExt := hb_FNameExt( aFile[ F_NAME ] ) - IF !( hb_FNameExt( aFile[ F_NAME ] ) $ hExtExceptions ) .AND. ; + IF ! Empty( hb_FNameExt( aFile[ F_NAME ] ) ) .AND. ; + !( hb_FNameExt( aFile[ F_NAME ] ) $ hExtExceptions ) .AND. ; !( hb_FNameNameExt( aFile[ F_NAME ] ) $ hFileExceptions ) .AND. ; AScan( aMaskExceptions, {| tmp | hb_FileMatch( StrTran( aFile[ F_NAME ], "\", "/" ), tmp ) } ) == 0 ProcFile( hAll, aFile[ F_NAME ] ) diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index c4c75fcd8e..65b4dcece9 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -134,8 +134,6 @@ On IA64 Windows: msvcia64, msvc, msvc64, mingw, mingw64, ... */ -#define _HBMK_LIB_HINTS_ - #ifndef _HBMK_EMBEDDED_ #include "hbextcdp.ch" @@ -1331,9 +1329,7 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) LOCAL lHBMAINDLLP -#ifdef _HBMK_LIB_HINTS_ - LOCAL cStdOut, cStdErr -#endif + LOCAL cStdOutErr IF s_cSecToken == NIL s_cSecToken := StrZero( hb_rand32(), 10, 0 ) @@ -6611,7 +6607,7 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) ENDIF ENDIF - IF ! hbmk[ _HBMK_lDONTEXEC ] .AND. ( tmp := hb_processRun( cCommand ) ) != 0 + IF ! hbmk[ _HBMK_lDONTEXEC ] .AND. ( tmp := hbmk_hb_processRunCatch( cCommand, @cStdOutErr ) ) != 0 _hbmk_OutErr( hbmk, hb_StrFormat( I_( "Error: Running linker. %1$d" ), tmp ) ) IF ! hbmk[ _HBMK_lQuiet ] OutErr( cCommand + _OUT_EOL ) @@ -6620,14 +6616,11 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) hbmk[ _HBMK_nErrorLevel ] := _ERRLEV_RUNLINKER ENDIF -#ifdef _HBMK_LIB_HINTS_ /* Run failed linker command again to analyze its output and present hints */ - IF ! hbmk[ _HBMK_lQuiet ] .AND. ! hbmk[ _HBMK_lIGNOREERROR ] - hb_processRun( cCommand,, @cStdOut, @cStdErr ) - AdviseMissingLibs( hbmk, cStdOut + hb_eol() + cStdErr ) + IF ! hbmk[ _HBMK_lQuiet ] + AdviseMissingLibs( hbmk, cStdOutErr ) ENDIF -#endif ENDIF IF ! Empty( cScriptFile ) @@ -6733,7 +6726,7 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) ENDIF ENDIF - IF ! hbmk[ _HBMK_lDONTEXEC ] .AND. ( tmp := hb_processRun( cCommand ) ) != 0 + IF ! hbmk[ _HBMK_lDONTEXEC ] .AND. ( tmp := hbmk_hb_processRunCatch( cCommand, @cStdOutErr ) ) != 0 _hbmk_OutErr( hbmk, hb_StrFormat( I_( "Error: Running dynamic lib link command. %1$d" ), tmp ) ) IF ! hbmk[ _HBMK_lQuiet ] OutErr( cCommand + _OUT_EOL ) @@ -6742,14 +6735,11 @@ FUNCTION hbmk( aArgs, nArgTarget, /* @ */ lPause, nLevel ) hbmk[ _HBMK_nErrorLevel ] := _ERRLEV_RUNLINKER ENDIF -#ifdef _HBMK_LIB_HINTS_ /* Run failed linker command again to analyze its output and present hints */ - IF ! hbmk[ _HBMK_lQuiet ] .AND. ! hbmk[ _HBMK_lIGNOREERROR ] - hb_processRun( cCommand,, @cStdOut, @cStdErr ) - AdviseMissingLibs( hbmk, cStdOut + hb_eol() + cStdErr ) + IF ! hbmk[ _HBMK_lQuiet ] + AdviseMissingLibs( hbmk, cStdOutErr ) ENDIF -#endif ENDIF IF ! Empty( cScriptFile ) @@ -12249,7 +12239,34 @@ STATIC FUNCTION Apple_App_Template_Info_plist() #pragma __endtext -#ifdef _HBMK_LIB_HINTS_ +STATIC FUNCTION hbmk_hb_processRunCatch( cCommand, /* @ */ cStdOutErr ) + LOCAL hProc + LOCAL hOutErr + + LOCAL cData + LOCAL cChunk + LOCAL nLen + + LOCAL nErrorLevel + + cStdOutErr := "" + + IF ( hProc := hb_processOpen( cCommand,, @hOutErr, @hOutErr ) ) != F_ERROR + + cData := Space( 1024 ) + DO WHILE ( nLen := FRead( hOutErr, @cData, hb_BLen( cData ) ) ) > 0 + OutStd( cChunk := hb_BLeft( cData, nLen ) ) + cStdOutErr += cChunk + ENDDO + + nErrorLevel := hb_processValue( hProc ) + + FClose( hOutErr ) + ELSE + nErrorLevel := -999 + ENDIF + + RETURN nErrorLevel STATIC PROCEDURE AdviseMissingLibs( hbmk, cOutput ) @@ -12407,8 +12424,6 @@ STATIC FUNCTION GetListOfFunctionsKnownLoadHBX( cFileName, cRoot, hAll ) RETURN aDynamic -#endif - STATIC FUNCTION mk_extern( hbmk, cInputName, cBin_LibHBX, cOpt_LibHBX, cLibHBX_Regex, cOutputName ) LOCAL aExtern