From bd6343a4d321727ff7649f8c79d5b0c333cf2d6a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 13 Jun 2012 23:13:24 +0000 Subject: [PATCH] 2012-06-14 01:09 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbrun/hbrun.prg * utils/hbmk2/hbmk2.prg % minor optimization to not try to create ~/.harbour directory on each __hbrun_ConfigDir() call, only when saving there. --- harbour/ChangeLog | 6 ++++++ harbour/contrib/hbrun/hbrun.prg | 27 +++++++++++++-------------- harbour/utils/hbmk2/hbmk2.prg | 29 ++++++++++++----------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 11f4ce7ad0..c0fec7dd32 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,12 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-14 01:09 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbrun/hbrun.prg + * utils/hbmk2/hbmk2.prg + % minor optimization to not try to create ~/.harbour directory + on each __hbrun_ConfigDir() call, only when saving there. + 2012-06-14 00:55 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/include/hbset.h * harbour/src/vm/set.c diff --git a/harbour/contrib/hbrun/hbrun.prg b/harbour/contrib/hbrun/hbrun.prg index ad282e4820..a325adbbda 100644 --- a/harbour/contrib/hbrun/hbrun.prg +++ b/harbour/contrib/hbrun/hbrun.prg @@ -701,7 +701,7 @@ STATIC PROCEDURE hbrun_Exec( cCommand ) LOCAL pHRB, cHRB, cFunc, bBlock, cEol, nRowMin cEol := hb_eol() - cFunc := "STATIC FUNC __HBDOT()" + cEol + ; + cFunc := "STATIC FUNCTION __HBDOT()" + cEol + ; "RETURN {||" + cEol + ; " " + cCommand + cEol + ; " RETURN __MVSETBASE()" + cEol + ; @@ -740,6 +740,12 @@ STATIC FUNCTION HBRawVersion() #define _HISTORY_DISABLE_LINE "no" +#if defined( __PLATFORM__DOS ) +# define _FNAME_HISTORY_ "hbhist.ini" +#else +# define _FNAME_HISTORY_ ".hb_history" +#endif + STATIC PROCEDURE hbrun_HistoryLoad() LOCAL cHistory LOCAL cLine @@ -747,7 +753,7 @@ STATIC PROCEDURE hbrun_HistoryLoad() s_lWasLoad := .T. IF s_lPreserveHistory - cHistory := StrTran( MemoRead( hbrun_HistoryFileName() ), Chr( 13 ) ) + cHistory := StrTran( MemoRead( __hbrun_ConfigDir() + _FNAME_HISTORY_ ), Chr( 13 ) ) IF Left( cHistory, Len( _HISTORY_DISABLE_LINE + Chr( 10 ) ) ) == _HISTORY_DISABLE_LINE + Chr( 10 ) s_lPreserveHistory := .F. ELSE @@ -764,6 +770,7 @@ STATIC PROCEDURE hbrun_HistoryLoad() STATIC PROCEDURE hbrun_HistorySave() LOCAL cHistory LOCAL cLine + LOCAL cDir IF s_lWasLoad .AND. s_lPreserveHistory cHistory := "" @@ -772,22 +779,14 @@ STATIC PROCEDURE hbrun_HistorySave() cHistory += AllTrim( cLine ) + hb_eol() ENDIF NEXT - hb_MemoWrit( hbrun_HistoryFileName(), cHistory ) + IF ! hb_DirExists( cDir := __hbrun_ConfigDir() ) + hb_DirCreate( cDir ) + ENDIF + hb_MemoWrit( cDir + _FNAME_HISTORY_, cHistory ) ENDIF RETURN -STATIC FUNCTION hbrun_HistoryFileName() - LOCAL cFileName - -#if defined( __PLATFORM__DOS ) - cFileName := "hbhist.ini" -#else - cFileName := ".hb_history" -#endif - - RETURN __hbrun_ConfigDir() + cFileName - FUNCTION __hbrun_FindInPath( cFileName, xPath ) LOCAL cDir LOCAL cName diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 71e5e39116..e589d1709e 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -12305,10 +12305,6 @@ STATIC FUNCTION __hbrun_ConfigDir() cDir := hb_DirBase() ENDIF - IF ! hb_DirExists( cDir ) - hb_DirCreate( cDir ) - ENDIF - RETURN cDir + hb_ps() STATIC PROCEDURE __hbrun_LoadExtDynamicFromFile( aDynamic, cFileName ) @@ -12820,6 +12816,12 @@ STATIC PROCEDURE __hbrun_Exec( cCommand ) #define _HISTORY_DISABLE_LINE "no" +#if defined( __PLATFORM__DOS ) +# define _FNAME_HISTORY_ "hbhist.ini" +#else +# define _FNAME_HISTORY_ ".hb_history" +#endif + EXIT PROCEDURE __hbrun_exit() __hbrun_HistorySave() @@ -12833,7 +12835,7 @@ STATIC PROCEDURE __hbrun_HistoryLoad() s_lWasLoad := .T. IF s_lPreserveHistory - cHistory := StrTran( MemoRead( __hbrun_HistoryFileName() ), Chr( 13 ) ) + cHistory := StrTran( MemoRead( __hbrun_ConfigDir() + _FNAME_HISTORY_ ), Chr( 13 ) ) IF Left( cHistory, Len( _HISTORY_DISABLE_LINE + Chr( 10 ) ) ) == _HISTORY_DISABLE_LINE + Chr( 10 ) s_lPreserveHistory := .F. ELSE @@ -12850,6 +12852,7 @@ STATIC PROCEDURE __hbrun_HistoryLoad() STATIC PROCEDURE __hbrun_HistorySave() LOCAL cHistory LOCAL cLine + LOCAL cDir IF s_lWasLoad .AND. s_lPreserveHistory cHistory := "" @@ -12858,22 +12861,14 @@ STATIC PROCEDURE __hbrun_HistorySave() cHistory += AllTrim( cLine ) + hb_eol() ENDIF NEXT - hb_MemoWrit( __hbrun_HistoryFileName(), cHistory ) + IF ! hb_DirExists( cDir := __hbrun_ConfigDir() ) + hb_DirCreate( cDir ) + ENDIF + hb_MemoWrit( cDir + _FNAME_HISTORY_, cHistory ) ENDIF RETURN -STATIC FUNCTION __hbrun_HistoryFileName() - LOCAL cFileName - -#if defined( __PLATFORM__DOS ) - cFileName := "hbhist.ini" -#else - cFileName := ".hb_history" -#endif - - RETURN __hbrun_ConfigDir() + cFileName - #if defined( __PLATFORM__WINDOWS ) /* NOTE: Using an optional contrib component. Relying on it dynamically. */