From dd03d682f3161546da5a686d9f51d21402c41f3f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 1 Jul 2010 15:35:07 +0000 Subject: [PATCH] 2010-07-01 17:32 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/memvarhb.prg + Added file signature and version no. to .hbv files. ; Patch by Tamas Tevesz with a few modifications: - added high byte at 1st pos is signature - deleted RTEs in case of invalid file content on load (to mimic original __MVRESTORE() which is also silent) - minor optimization on signature checking. ; INCOMPATIBLE: The file format has changed so you won't be able to interchange it with previous versions of Harbour. Anyhow it's very new format, so this shouldn't affect many users. * utils/hbmk2/hbmk2.prg * utils/hbrun/hbrun.prg + Shows .hbs as support input file format (where applicable) ! Little fix in displaying options w/o description on help screen. * utils/hbrun/hbrun.prg + Added clipboard paste support with Alt+V key. * contrib/hbide/hbide.prg - Temply disabled reference to new-style embedded resources. --- harbour/ChangeLog | 25 +++++++++++++ harbour/contrib/hbide/hbide.prg | 2 +- harbour/src/rtl/memvarhb.prg | 65 +++++++++++++++++++++------------ harbour/utils/hbmk2/hbmk2.prg | 16 ++++---- harbour/utils/hbrun/hbrun.prg | 6 ++- 5 files changed, 79 insertions(+), 35 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 31b0254299..4357a0af83 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,31 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-01 17:32 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/memvarhb.prg + + Added file signature and version no. to .hbv files. + ; Patch by Tamas Tevesz with a few modifications: + - added high byte at 1st pos is signature + - deleted RTEs in case of invalid file content on load + (to mimic original __MVRESTORE() which is also silent) + - minor optimization on signature checking. + ; INCOMPATIBLE: The file format has changed so you won't be + able to interchange it with previous + versions of Harbour. Anyhow it's very new + format, so this shouldn't affect many users. + + * utils/hbmk2/hbmk2.prg + * utils/hbrun/hbrun.prg + + Shows .hbs as support input file format (where applicable) + ! Little fix in displaying options w/o description on help + screen. + + * utils/hbrun/hbrun.prg + + Added clipboard paste support with Alt+V key. + + * contrib/hbide/hbide.prg + - Temply disabled reference to new-style embedded resources. + 2010-07-01 10:05 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/gtsln/kbsln.c * public variable hb_DeadKey made static and renamed to diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 6a8433b71a..6568066273 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -111,7 +111,7 @@ PROCEDURE Main( ... ) SET CENTURY ON SET EPOCH TO 1970 - /* TODO: activate */ hbqtres_HbIde() + /* TODO: activate */ /* hbqtres_HbIde() */ oIde := HbIde():new( hb_aParams() ):create() oIde:destroy() diff --git a/harbour/src/rtl/memvarhb.prg b/harbour/src/rtl/memvarhb.prg index 149a9ab1e6..61f925adeb 100644 --- a/harbour/src/rtl/memvarhb.prg +++ b/harbour/src/rtl/memvarhb.prg @@ -55,7 +55,18 @@ #include "error.ch" #include "fileio.ch" -#define _HBMEM_EXT ".hbv" +/* + * 'H', 'B', 'V' followed two-byte version number in network byte order (BE). + * Corresponding magic(5) rule: + * 0 string \xC0HBV + * 0x04 beshort x Harbour memory file version %d + * Until such time that the serialized format changes, and handling of + * previously-saved files is required, only a naive approach of using + * version 0 is taken. + */ +#define _HBMEM_SIGNATURE e"\xC0HBV" + Chr( 0 ) + Chr( 0 ) + +#define _HBMEM_EXT ".hbv" FUNCTION HB_MVSAVE( cFileName, cMask, lIncludeMask ) LOCAL nCount @@ -133,6 +144,7 @@ FUNCTION HB_MVSAVE( cFileName, cMask, lIncludeMask ) ENDDO IF fhnd != F_ERROR + FWrite( fhnd, _HBMEM_SIGNATURE ) FWrite( fhnd, hb_serialize( aVars ) ) FClose( fhnd ) ENDIF @@ -223,33 +235,40 @@ FUNCTION HB_MVRESTORE( cFileName, lAdditive, cMask, lIncludeMask ) RETURN .F. ENDIF - cBuffer := Space( FSeek( fhnd, 0, FS_END ) ) - FSeek( fhnd, 0, FS_SET ) - FRead( fhnd, @cBuffer, Len( cBuffer ) ) - FClose( fhnd ) - - aVars := hb_deserialize( cBuffer ) - cBuffer := NIL - xValue := NIL - IF ISARRAY( aVars ) - FOR EACH item IN aVars - IF ISARRAY( item ) .AND. Len( item ) == 2 .AND. ; - ISCHARACTER( item[ 1 ] ) .AND. ; - ! Empty( item[ 1 ] ) + cBuffer := Space( Len( _HBMEM_SIGNATURE ) ) + FRead( fhnd, @cBuffer, Len( cBuffer ) ) + IF cBuffer == _HBMEM_SIGNATURE - cName := item[ 1 ] - lMatch := hb_WildMatchI( cMask, cName ) - IF iif( lIncludeMask, lMatch, ! lMatch ) - IF xValue == NIL - xValue := item[ 2 ] + cBuffer := Space( FSeek( fhnd, 0, FS_END ) - Len( _HBMEM_SIGNATURE ) ) + FSeek( fhnd, Len( _HBMEM_SIGNATURE ), FS_SET ) + FRead( fhnd, @cBuffer, Len( cBuffer ) ) + FClose( fhnd ) + + aVars := hb_deserialize( cBuffer ) + cBuffer := NIL + + IF ISARRAY( aVars ) + FOR EACH item IN aVars + IF ISARRAY( item ) .AND. Len( item ) == 2 .AND. ; + ISCHARACTER( item[ 1 ] ) .AND. ; + ! Empty( item[ 1 ] ) + + cName := item[ 1 ] + lMatch := hb_WildMatchI( cMask, cName ) + IF iif( lIncludeMask, lMatch, ! lMatch ) + IF xValue == NIL + xValue := item[ 2 ] + ENDIF + &cName := item[ 2 ] ENDIF - &cName := item[ 2 ] ENDIF - ENDIF - NEXT - __MVSETBASE() + NEXT + __MVSETBASE() + ENDIF + ELSE + FClose( fhnd ) ENDIF RETURN xValue diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 72080c9132..6e29a7a404 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -9944,9 +9944,9 @@ STATIC PROCEDURE ShowHelp( hbmk, lLong ) { "-depincpath=" , I_( " is the name of the dependency. Add to the header detection path list" ) },; { "-depincpathlocal= " , I_( " is the name of the dependency. Add to the header detection path list, where is pointing to a directory local to the project and containing an embedded (or locally hosted) dependency." ) },; NIL,; - { "-plugin=<.prg|.hrb>", I_( "add plugin (EXPERIMENTAL)" ) },; - { "-pi=" , I_( "pass input file to plugins (EXPERIMENTAL)" ) },; - { "-pflag=" , I_( "pass flag to plugins (EXPERIMENTAL)" ) },; + { "-plugin= <.prg|.hbs|.hrb>", I_( "add plugin" ) },; + { "-pi=" , I_( "pass input file to plugins" ) },; + { "-pflag=" , I_( "pass flag to plugins" ) },; NIL,; { "Options below are available on command line only:" },; NIL,; @@ -10022,19 +10022,17 @@ STATIC PROCEDURE ShowHelp( hbmk, lLong ) STATIC PROCEDURE OutOpt( hbmk, aOpt ) LOCAL nLine LOCAL nLines - LOCAL tmp IF Empty( aOpt ) OutStd( _OUT_EOL ) ELSE IF Len( aOpt ) > 1 aOpt[ 2 ] := StrTran( aOpt[ 2 ], "\n", hb_osNewLine() ) - nLines := MLCount( aOpt[ 2 ], hbmk[ _HBMK_nMaxCol ] - _OPT_WIDTH ) + nLines := Max( MLCount( aOpt[ 2 ], hbmk[ _HBMK_nMaxCol ] - _OPT_WIDTH ),; + MLCount( aOpt[ 1 ], _OPT_WIDTH ) ) FOR nLine := 1 TO nLines - IF ! Empty( tmp := RTrim( MemoLine( aOpt[ 2 ], hbmk[ _HBMK_nMaxCol ] - _OPT_WIDTH, nLine ) ) ) - OutStd( PadR( Space( 2 ) + MemoLine( aOpt[ 1 ], _OPT_WIDTH, nLine ), _OPT_WIDTH ) ) - OutStd( tmp + _OUT_EOL ) - ENDIF + OutStd( PadR( Space( 2 ) + MemoLine( aOpt[ 1 ], _OPT_WIDTH, nLine ), _OPT_WIDTH ) ) + OutStd( RTrim( MemoLine( aOpt[ 2 ], hbmk[ _HBMK_nMaxCol ] - _OPT_WIDTH, nLine ) ) + _OUT_EOL ) NEXT ELSE OutStd( Space( 2 ) + aOpt[ 1 ] + _OUT_EOL ) diff --git a/harbour/utils/hbrun/hbrun.prg b/harbour/utils/hbrun/hbrun.prg index 900df2e726..9906a8732f 100644 --- a/harbour/utils/hbrun/hbrun.prg +++ b/harbour/utils/hbrun/hbrun.prg @@ -201,6 +201,8 @@ STATIC PROCEDURE hbrun_Prompt( cCommand ) hb_gtInfo( HB_GTI_RESIZEMODE, HB_GTI_RESIZEMODE_ROWS ) + SetKey( K_ALT_V, {|| hb_gtInfo( HB_GTI_CLIPBOARDPASTE ) } ) + Set( _SET_EVENTMASK, hb_bitOr( INKEY_KEYBOARD, HB_INKEY_GTEVENT ) ) DO WHILE .T. @@ -240,7 +242,7 @@ STATIC PROCEDURE hbrun_Prompt( cCommand ) SetKey( HB_K_RESIZE, bKeyResize ) IF LastKey() == K_ESC .OR. EMPTY( cLine ) .OR. ; - ( lResize .AND. LastKey() == K_ENTER ) + ( lResize .AND. LastKey() == K_ENTER ) IF lResize lResize := .F. ELSE @@ -286,7 +288,7 @@ STATIC PROCEDURE hbrun_Usage() "Copyright (c) 1999-2010, Przemyslaw Czerpak" + HB_OSNewLine() + ; "http://harbour-project.org/" + HB_OSNewLine() +; HB_OSNewLine() +; - "Syntax: hbrun [ []]" + HB_OSNewLine() ) + "Syntax: hbrun [ []]" + HB_OSNewLine() ) RETURN