From bd3dbbac9fd5cf83ba1b37f907ab0638da0ace44 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 23 Nov 2012 16:47:47 +0000 Subject: [PATCH] 2012-11-23 17:46 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbnf/aredit.prg * contrib/hbnf/popadder.prg % eliminated NextKey() calls Please review me % use HB_KEYSETLAST() * contrib/xhb/tcgi.prg * contrib/xhb/thtm.prg * contrib/xhb/traceprg.prg * cleanups --- harbour/ChangeLog | 12 ++++++++++++ harbour/contrib/hbnf/aredit.prg | 7 ++++--- harbour/contrib/hbnf/popadder.prg | 10 +++++----- harbour/contrib/xhb/tcgi.prg | 5 ++--- harbour/contrib/xhb/thtm.prg | 22 +++++++++++----------- harbour/contrib/xhb/traceprg.prg | 14 ++++++-------- 6 files changed, 40 insertions(+), 30 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c3547cc5e1..d3123a9982 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -10,6 +10,18 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2012-11-23 17:46 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbnf/aredit.prg + * contrib/hbnf/popadder.prg + % eliminated NextKey() calls + Please review me + % use HB_KEYSETLAST() + + * contrib/xhb/tcgi.prg + * contrib/xhb/thtm.prg + * contrib/xhb/traceprg.prg + * cleanups + 2012-11-23 17:14 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/contrib/xhb/xhbtedit.prg * harbour/contrib/hbmysql/tsqlbrw.prg diff --git a/harbour/contrib/hbnf/aredit.prg b/harbour/contrib/hbnf/aredit.prg index 67759eccca..d2976dbe99 100644 --- a/harbour/contrib/hbnf/aredit.prg +++ b/harbour/contrib/hbnf/aredit.prg @@ -102,11 +102,12 @@ FUNCTION ft_ArEdit( nTop, nLeft, nBot, nRight, ; exit_requested := .F. DO WHILE ! exit_requested - /* TODO: avoid NextKey() */ - DO WHILE NextKey() == 0 .AND. ! b:stabilize() + DO WHILE ( nKey := Inkey() ) == 0 .AND. ! b:stabilize() ENDDO - nKey := Inkey( 0 ) + IF nKey == 0 + nKey := Inkey( 0 ) + ENDIF meth_no := AScan( tb_methods, {| elem | nKey == elem[ KEY_ELEM ] } ) IF meth_no != 0 diff --git a/harbour/contrib/hbnf/popadder.prg b/harbour/contrib/hbnf/popadder.prg index 27d97b60d1..f7aade65f0 100644 --- a/harbour/contrib/hbnf/popadder.prg +++ b/harbour/contrib/hbnf/popadder.prg @@ -788,8 +788,7 @@ STATIC FUNCTION _ftDisplayTape( aAdder, nKey ) STATIC FUNCTION _ftSetLastKey( nLastKey ) _ftPushKeys() - hb_keyPut( nLastKey ) - Inkey() + hb_keySetLast( nLastKey ) _ftPopKeys() RETURN NIL @@ -800,9 +799,10 @@ STATIC FUNCTION _ftSetLastKey( nLastKey ) STATIC FUNCTION _ftPushKeys() - /* TODO: avoid NextKey() */ - DO WHILE NextKey() != 0 - AAdd( t_aKeys, Inkey() ) + LOCAL nKey + + DO WHILE ( nKey := Inkey() ) != 0 + AAdd( t_aKeys, nKey ) ENDDO RETURN NIL diff --git a/harbour/contrib/xhb/tcgi.prg b/harbour/contrib/xhb/tcgi.prg index e6ec8088b1..6858d7cb6a 100644 --- a/harbour/contrib/xhb/tcgi.prg +++ b/harbour/contrib/xhb/tcgi.prg @@ -154,15 +154,14 @@ METHOD New( cInBuffer ) CLASS TCgi METHOD ToObject() CLASS TCgi LOCAL i - LOCAL nScope := 1 + LOCAL nScope := 1 LOCAL aDb LOCAL oNew STATIC s_n := 0 // --> create new oObject class from this one... - s_n++ - aDb := HBClass():New( "NewCgi" + StrZero( s_n, 3 ), { "TCgi" } ) + aDb := HBClass():New( "NewCgi" + StrZero( ++s_n, 3 ), { "TCgi" } ) FOR i := 1 TO Len( ::aQueryFields ) diff --git a/harbour/contrib/xhb/thtm.prg b/harbour/contrib/xhb/thtm.prg index 9934c5549e..9785d4fa3f 100644 --- a/harbour/contrib/xhb/thtm.prg +++ b/harbour/contrib/xhb/thtm.prg @@ -47,9 +47,9 @@ #include "hbclass.ch" #include "cgi.ch" -STATIC s_nHtm := NIL -STATIC s_cForm := 0 -STATIC s_oPage := 0 +THREAD STATIC t_nHtm := NIL +THREAD STATIC t_cForm := 0 +THREAD STATIC t_oPage := 0 /**** * @@ -499,9 +499,9 @@ METHOD New( cTitle, cLinkTitle, cCharSet, aScriptSRC, ; ::cStr += CRLF() - s_nHtm := ::nH + t_nHtm := ::nH - s_oPage := Self + t_oPage := Self RETURN self @@ -510,9 +510,9 @@ METHOD NewAlt( cType ) CLASS THtml ::nH := STD_OUT ::cStr += 'Content-Type: ' + cType + CRLF() + CRLF() - s_nHtm := ::nH + t_nHtm := ::nH - s_oPage := Self + t_oPage := Self RETURN self @@ -1603,7 +1603,7 @@ METHOD NewForm( cMethod, cAction, cName ) CLASS THtml ::cStr += '>' + CRLF() - s_cForm := cName + t_cForm := cName RETURN Self @@ -2093,7 +2093,7 @@ METHOD PutLinkName( cName ) CLASS THtml FUNCTION HtmlPageHandle() - RETURN s_nHtm + RETURN t_nHtm /**** * @@ -2105,7 +2105,7 @@ FUNCTION HtmlPageHandle() FUNCTION HtmlFormName() - RETURN s_cForm + RETURN t_cForm /**** * HtmlPageObject() @@ -2116,7 +2116,7 @@ FUNCTION HtmlFormName() FUNCTION HtmlPageObject() - RETURN s_oPage + RETURN t_oPage /**** * diff --git a/harbour/contrib/xhb/traceprg.prg b/harbour/contrib/xhb/traceprg.prg index 2222a46e68..35e3c43a07 100644 --- a/harbour/contrib/xhb/traceprg.prg +++ b/harbour/contrib/xhb/traceprg.prg @@ -56,8 +56,6 @@ #define HB_SET_TRACESTACK_CURRENT 1 #define HB_SET_TRACESTACK_ALL 2 -#xtranslate Write( ) => FWrite( FileHandle, ) - STATIC s_lSET_TRACE := .T. STATIC s_cSET_TRACEFILE := "trace.log" STATIC s_nSET_TRACESTACK := HB_SET_TRACESTACK_ALL @@ -147,24 +145,24 @@ FUNCTION TraceLog( ... ) FSeek( FileHandle, 0, FS_END ) IF nLevel > 0 - Write( "[" + ProcFile( 1 ) + "->" + ProcName( 1 ) + "] (" + hb_ntos( ProcLine( 1 ) ) + ")" ) + FWrite( FileHandle, "[" + ProcFile( 1 ) + "->" + ProcName( 1 ) + "] (" + hb_ntos( ProcLine( 1 ) ) + ")" ) ENDIF IF nLevel > 1 .AND. ! ( ProcName( 2 ) == "" ) - Write( " Called from: " + hb_eol() ) + FWrite( FileHandle, " Called from: " + hb_eol() ) nLevel := 1 DO WHILE ! ( ( ProcName := ProcName( ++nLevel ) ) == "" ) - Write( Space( 30 ) + ProcFile( nLevel ) + "->" + ProcName + "(" + hb_ntos( ProcLine( nLevel ) ) + ")" + hb_eol() ) + FWrite( FileHandle, Space( 30 ) + ProcFile( nLevel ) + "->" + ProcName + "(" + hb_ntos( ProcLine( nLevel ) ) + ")" + hb_eol() ) ENDDO ELSE - Write( hb_eol() ) + FWrite( FileHandle, hb_eol() ) ENDIF FOR EACH xParam IN hb_AParams() - Write( "Type: " + ValType( xParam ) + " >>>" + hb_CStr( xParam ) + "<<<" + hb_eol() ) + FWrite( FileHandle, "Type: " + ValType( xParam ) + " >>>" + hb_CStr( xParam ) + "<<<" + hb_eol() ) NEXT - Write( hb_eol() ) + FWrite( FileHandle, hb_eol() ) FClose( FileHandle )