From 16d730147da399583cc4e8f34130e66f8933dcff Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 12 Oct 2012 12:21:46 +0000 Subject: [PATCH] 2012-10-12 14:19 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbhttpd/core.prg * contrib/hbhttpd/widgets.prg * contrib/hbpgsql/tests/cache.prg * extras/hbxlsxml/xlsxml_s.prg * extras/hbxlsxml/xlsxml_y.prg * extras/hbxlsxml/xlsxml.prg * extras/httpsrv/cgifunc.prg * extras/httpsrv/cookie.prg * extras/httpsrv/session.prg * extras/httpsrv/uhttpd.prg * src/rtl/dirscan.prg % LTRIM(STR(x,y)) converted to hb_ntos() where y had no significance or just limited the width unnecessarily % ValType() usage converted to HB_IS*() or optimized by rearragement of code or using SWITCH/CASE --- harbour/ChangeLog | 17 ++++++++++++++++ harbour/contrib/hbhttpd/core.prg | 6 +++--- harbour/contrib/hbhttpd/widgets.prg | 26 +++++++++++++------------ harbour/contrib/hbpgsql/tests/cache.prg | 8 ++++---- harbour/extras/hbxlsxml/xlsxml.prg | 12 ++++++------ harbour/extras/hbxlsxml/xlsxml_s.prg | 16 +++++++-------- harbour/extras/hbxlsxml/xlsxml_y.prg | 4 ++-- harbour/extras/httpsrv/cgifunc.prg | 12 ++++++------ harbour/extras/httpsrv/cookie.prg | 2 +- harbour/extras/httpsrv/session.prg | 12 ++++++------ harbour/extras/httpsrv/uhttpd.prg | 11 ++++++----- harbour/src/rtl/dirscan.prg | 2 +- 12 files changed, 74 insertions(+), 54 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d6181daf2a..e31ef0d1bf 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,23 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-12 14:19 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbhttpd/core.prg + * contrib/hbhttpd/widgets.prg + * contrib/hbpgsql/tests/cache.prg + * extras/hbxlsxml/xlsxml_s.prg + * extras/hbxlsxml/xlsxml_y.prg + * extras/hbxlsxml/xlsxml.prg + * extras/httpsrv/cgifunc.prg + * extras/httpsrv/cookie.prg + * extras/httpsrv/session.prg + * extras/httpsrv/uhttpd.prg + * src/rtl/dirscan.prg + % LTRIM(STR(x,y)) converted to hb_ntos() where y had + no significance or just limited the width unnecessarily + % ValType() usage converted to HB_IS*() or optimized + by rearragement of code or using SWITCH/CASE + 2012-10-12 11:16 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbgd/gdbarcod.prg % AllTrim() removed from around Str( n, 1 ) diff --git a/harbour/contrib/hbhttpd/core.prg b/harbour/contrib/hbhttpd/core.prg index f891f899a2..4eb4f745c5 100644 --- a/harbour/contrib/hbhttpd/core.prg +++ b/harbour/contrib/hbhttpd/core.prg @@ -718,9 +718,9 @@ STATIC PROCEDURE ProcessRequest( oServer ) bEval := aMount[cMount] BEGIN SEQUENCE WITH {| oErr | UErrorHandler( oErr, oServer ) } xRet := Eval( bEval, cPath ) - IF ValType( xRet ) == "C" + IF HB_ISSTRING( xRet ) UWrite( xRet ) - ELSEIF ValType( xRet ) == "H" + ELSEIF HB_ISHASH( xRet ) UWrite( UParse( xRet ) ) ENDIF RECOVER @@ -1011,7 +1011,7 @@ STATIC FUNCTION GetErrorDesc( oErr ) NEXT cI += ")" nJ := Len( aPar ) - DO WHILE !( ValType( xI := __dbgvmVarLGet( nI, ++nJ ) ) == "S" ) + DO WHILE ! HB_ISSYMBOL( xI := __dbgvmVarLGet( nI, ++nJ ) ) cI += ", " + cvt2str( xI ) ENDDO xI := NIL diff --git a/harbour/contrib/hbhttpd/widgets.prg b/harbour/contrib/hbhttpd/widgets.prg index 6c16a1d7e6..c12a1014cc 100644 --- a/harbour/contrib/hbhttpd/widgets.prg +++ b/harbour/contrib/hbhttpd/widgets.prg @@ -380,16 +380,17 @@ METHOD Output() CLASS UWBrowse cRet += '' FOR nI := 1 TO Len( Self:aColumns ) xField := Self:aColumns[nI, 3] - IF ValType( xField ) == "C" + IF HB_ISSTRING( xField ) xI := FieldGet( FieldPos( xField ) ) - ELSEIF ValType( xField ) == "B" + ELSEIF HB_ISBLOCK( xField ) xI := Eval( xField ) ENDIF - IF ValType( xI ) == "C"; xI := RTrim( xI ) - ELSEIF ValType( xI ) == "N"; xI := Str( xI ) - ELSEIF ValType( xI ) == "D"; xI := DToC( xI ) - ELSE ; xI := "VALTYPE()==" + ValType( xI ) - ENDIF + SWITCH ValType( xI ) + CASE "C" ; xI := RTrim( xI ); EXIT + CASE "N" ; xI := Str( xI ); EXIT + CASE "D" ; xI := DToC( xI ); EXIT + OTHERWISE ; xI := "VALTYPE()==" + ValType( xI ) + ENDSWITCH IF ! Self:aColumns[nI, 4] xI := UHtmlEncode( xI ) ENDIF @@ -590,11 +591,12 @@ STATIC FUNCTION uhttpd_join( cSeparator, aData ) cRet += cSeparator ENDIF - IF ValType( aData[ nI ] ) $ "CM" ; cRet += aData[ nI ] - ELSEIF ValType( aData[ nI ] ) == "N" ; cRet += hb_ntos( aData[ nI ] ) - ELSEIF ValType( aData[ nI ] ) == "D" ; cRet += iif( Empty( aData[ nI ] ), "", DToC( aData[ nI ] ) ) - ELSE - ENDIF + SWITCH ValType( aData[ nI ] ) + CASE "C" + CASE "M" ; cRet += aData[ nI ]; EXIT + CASE "N" ; cRet += hb_ntos( aData[ nI ] ); EXIT + CASE "D" ; cRet += iif( Empty( aData[ nI ] ), "", DToC( aData[ nI ] ) ); EXIT + ENDSWITCH NEXT RETURN cRet diff --git a/harbour/contrib/hbpgsql/tests/cache.prg b/harbour/contrib/hbpgsql/tests/cache.prg index df8c37ec97..beadf5f274 100644 --- a/harbour/contrib/hbpgsql/tests/cache.prg +++ b/harbour/contrib/hbpgsql/tests/cache.prg @@ -422,16 +422,16 @@ FUNCTION SQLPrepare( cQuery, ... ) IF x != NIL .AND. Empty( x ) x := "null" - ELSEIF ValType( x ) == "N" + ELSEIF HB_ISNUMBER( x ) x := hb_ntos( x ) - ELSEIF ValType( x ) == "D" + ELSEIF HB_ISDATE( x ) x := DToQ( x ) - ELSEIF ValType( x ) == "L" + ELSEIF HB_ISLOGICAL( x ) x := iif( x, "'t'", "'f'" ) - ELSEIF ValType( x ) $ "CM" + ELSEIF HB_ISSTRING( x ) x := SToQ( RTrim( x ) ) ELSE diff --git a/harbour/extras/hbxlsxml/xlsxml.prg b/harbour/extras/hbxlsxml/xlsxml.prg index 6d49aa0eef..c73e4ca033 100644 --- a/harbour/extras/hbxlsxml/xlsxml.prg +++ b/harbour/extras/hbxlsxml/xlsxml.prg @@ -113,7 +113,7 @@ METHOD ExcelWriterXML:new( fileName ) METHOD ExcelWriterXML:setOverwriteFile( overwrite ) - IF ! ( ValType( overwrite ) == "L" ) + IF ! HB_ISLOGICAL( overwrite ) ::overwriteFile := .F. ELSE ::overwriteFile := overwrite @@ -123,7 +123,7 @@ METHOD ExcelWriterXML:setOverwriteFile( overwrite ) METHOD ExcelWriterXML:showErrorSheet( show ) - IF ! ( ValType( show ) == "L" ) + IF ! HB_ISLOGICAL( show ) ::lShowErrorSheet := .T. ELSE ::lShowErrorSheet := show @@ -157,12 +157,12 @@ METHOD ExcelWriterXML:addStyle( id ) ENDIF IF id == NIL - id := "CustomStyle" + AllTrim( Str( styleNum, 3 ) ) + id := "CustomStyle" + hb_ntos( styleNum ) styleNum++ ENDIF WHILE ! ::checkStyleID( id ) - id := "CustomStyle" + AllTrim( Str( styleNum, 3 ) ) + id := "CustomStyle" + hb_ntos( styleNum ) styleNum++ ENDDO @@ -178,12 +178,12 @@ METHOD ExcelWriterXML:addSheet( id ) STATIC sheetNum := 1 IF id == NIL - id := "Sheet" + AllTrim( Str( sheetNum, 3 ) ) + id := "Sheet" + hb_ntos( sheetNum ) sheetNum++ ENDIF WHILE ! ::checkSheetID( id ) - id := "Sheet" + AllTrim( Str( sheetNum, 3 ) ) + id := "Sheet" + hb_ntos( sheetNum ) sheetNum++ ENDDO diff --git a/harbour/extras/hbxlsxml/xlsxml_s.prg b/harbour/extras/hbxlsxml/xlsxml_s.prg index c8df49c52f..73aed64124 100644 --- a/harbour/extras/hbxlsxml/xlsxml_s.prg +++ b/harbour/extras/hbxlsxml/xlsxml_s.prg @@ -129,17 +129,17 @@ METHOD ExcelWriterXML_Sheet:writeString( row, column, xData, style ) METHOD ExcelWriterXML_Sheet:writeNumber( row, column, xData, style ) - IF !( ValType( xData ) == "N" ) + IF ! HB_ISNUMERIC( xData ) ::writeData( "String", row, column, xData, style ) ELSE - ::writeData( "Number", row , column, AllTrim( Str( xData, 18, 6 ) ), style ) + ::writeData( "Number", row, column, AllTrim( Str( xData, 18, 6 ) ), style ) ENDIF RETURN NIL METHOD ExcelWriterXML_Sheet:writeDateTime( row, column, xData, style ) - IF ValType( xData ) == "D" + IF HB_ISDATE( xData ) ::writeData( "DateTime", row, column, DToC( xData ), style ) ELSE ::writeData( "String", row, column, xData, style ) @@ -201,8 +201,8 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) FOR ic := 1 TO Len( ::colWidth ) colIndex := hb_HKeyAt( ::colWidth, ic ) colWidth := hb_HValueAt( ::colWidth, ic ) - colIndex := AllTrim( Str( colIndex, 10 ) ) - colWidth := AllTrim( Str( colWidth, 10 ) ) + colIndex := hb_ntos( colIndex ) + colWidth := hb_ntos( colWidth ) xml += ' ' + hb_eol() NEXT ENDIF @@ -221,7 +221,7 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) rowHeight := "" ENDIF - xml += ' " + hb_eol() + xml += ' " + hb_eol() FOR ic := 1 TO Len( rowData ) column := hb_HKeyAt( rowData, ic ) cell := hb_HValueAt( rowData, ic ) @@ -239,7 +239,7 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) mergeCell := "" IF hb_HPos( ::mergeCells, row ) > 0 IF hb_HPos( ::mergeCells[ row ], column ) > 0 - mergeCell := 'ss:MergeAcross="' + AllTrim( Str( ::mergeCells[ row ][ column ][ "width" ], 10 ) ) + '" ss:MergeDown="' + AllTrim( Str( ::mergeCells[ row ][ column ][ "height" ], 10 ) ) + '"' + mergeCell := 'ss:MergeAcross="' + hb_ntos( ::mergeCells[ row ][ column ][ "width" ] ) + '" ss:MergeDown="' + hb_ntos( ::mergeCells[ row ][ column ][ "height" ] ) + '"' ENDIF ENDIF comment := "" @@ -257,7 +257,7 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) type := cell[ "type" ] xData := cell[ "data" ] - xml += " " + hb_eol() + xml += " " + hb_eol() xml += ' ' xml += StrToHtmlEspecial( xData ) xml += "" + hb_eol() diff --git a/harbour/extras/hbxlsxml/xlsxml_y.prg b/harbour/extras/hbxlsxml/xlsxml_y.prg index 632d5409b1..401dec0369 100644 --- a/harbour/extras/hbxlsxml/xlsxml_y.prg +++ b/harbour/extras/hbxlsxml/xlsxml_y.prg @@ -225,7 +225,7 @@ METHOD ExcelWriterXML_Style:getStyleXML() fontFamily := 'x:Family="' + ::fontFamily + '"' ENDIF IF ! Empty( ::fontSize ) - fontSize := 'ss:Size="' + AllTrim( Str( ::fontSize, 10 ) ) + '"' + fontSize := 'ss:Size="' + hb_ntos( ::fontSize ) + '"' ENDIF ENDIF @@ -350,7 +350,7 @@ METHOD ExcelWriterXML_Style:alignRotate( rotate ) IF Abs( rotate ) > 90 rotate := rotate % 90 ENDIF - ::rotate := AllTrim( Str( rotate, 3 ) ) + ::rotate := hb_ntos( rotate ) ::useAlignment := .T. RETURN NIL diff --git a/harbour/extras/httpsrv/cgifunc.prg b/harbour/extras/httpsrv/cgifunc.prg index a804daea18..6b96896790 100644 --- a/harbour/extras/httpsrv/cgifunc.prg +++ b/harbour/extras/httpsrv/cgifunc.prg @@ -666,18 +666,18 @@ RETURN replicate( " ", n ) //" " STATIC FUNCTION FT_ELAPSED(dStart, dEnd, cTimeStart, cTimeEnd) LOCAL nTotalSec, nCtr, nConstant, nTemp, aRetVal[4,2] - IF ! ( VALTYPE(dStart) $ 'DC' ) - dStart := DATE() - ELSEIF VALTYPE(dStart) == 'C' + IF HB_ISSTRING( dStart ) cTimeStart := dStart dStart := DATE() + ELSEIF ! HB_ISDATE( dStart ) + dStart := DATE() ENDIF - IF ! ( VALTYPE(dEnd) $ 'DC' ) - dEnd := DATE() - ELSEIF VALTYPE(dEnd) == 'C' + IF HB_ISSTRING( dEnd ) cTimeEnd := dEnd dEnd := DATE() + ELSEIF ! HB_ISDATE( dEnd ) + dEnd := DATE() ENDIF iif( ! HB_ISSTRING( cTimeStart ), cTimeStart := '00:00:00', ) diff --git a/harbour/extras/httpsrv/cookie.prg b/harbour/extras/httpsrv/cookie.prg index e0a1dd6915..e9db894384 100644 --- a/harbour/extras/httpsrv/cookie.prg +++ b/harbour/extras/httpsrv/cookie.prg @@ -138,7 +138,7 @@ METHOD SetCookie( cCookieName, xValue, cDomain, cPath, cExpires, lSecure, lHttpO IF cExpires != NIL cStr += "; expires=" + cExpires ENDIF - IF ValType( lSecure ) == "L" .AND. lSecure + IF HB_ISLOGICAL( lSecure ) .AND. lSecure cStr += "; secure" ENDIF diff --git a/harbour/extras/httpsrv/session.prg b/harbour/extras/httpsrv/session.prg index d5d946d970..eea9f555a4 100644 --- a/harbour/extras/httpsrv/session.prg +++ b/harbour/extras/httpsrv/session.prg @@ -737,18 +737,18 @@ STATIC FUNCTION TimeDiffAsSeconds( dDateStart, dDateEnd, cTimeStart, cTimeEnd ) STATIC FUNCTION FT_ELAPSED(dStart, dEnd, cTimeStart, cTimeEnd) LOCAL nTotalSec, nCtr, nConstant, nTemp, aRetVal[4,2] - IF ! ( VALTYPE(dStart) $ 'DC' ) - dStart := DATE() - ELSEIF VALTYPE(dStart) == 'C' + IF HB_ISSTRING( dStart ) cTimeStart := dStart dStart := DATE() + ELSEIF ! HB_ISDATE( dStart ) + dStart := DATE() ENDIF - IF ! ( VALTYPE(dEnd) $ 'DC' ) - dEnd := DATE() - ELSEIF VALTYPE(dEnd) == 'C' + IF HB_ISSTRING( dEnd ) cTimeEnd := dEnd dEnd := DATE() + ELSEIF ! HB_ISDATE( dEnd ) + dEnd := DATE() ENDIF iif( ! HB_ISSTRING(cTimeStart), cTimeStart := '00:00:00', ) diff --git a/harbour/extras/httpsrv/uhttpd.prg b/harbour/extras/httpsrv/uhttpd.prg index 9d23b50f6c..5cb03357c4 100644 --- a/harbour/extras/httpsrv/uhttpd.prg +++ b/harbour/extras/httpsrv/uhttpd.prg @@ -1820,11 +1820,12 @@ FUNCTION uhttpd_join( cSeparator, aData ) FOR nI := 1 TO LEN( aData ) IF nI > 1; cRet += cSeparator ENDIF - IF VALTYPE(aData[ nI ]) $ "CM"; cRet += aData[ nI ] - ELSEIF VALTYPE(aData[ nI ]) == "N"; cRet += LTRIM(STR(aData[ nI ])) - ELSEIF VALTYPE(aData[ nI ]) == "D"; cRet += iif(!EMPTY(aData[ nI ]), DTOC(aData[ nI ]), "") - ELSE - ENDIF + SWITCH VALTYPE( aData[ nI ] ) + CASE "C" + CASE "M"; cRet += aData[ nI ]; EXIT + CASE "N"; cRet += LTRIM(STR(aData[ nI ])); EXIT + CASE "D"; cRet += iif(!EMPTY(aData[ nI ]), DTOC(aData[ nI ]), ""); EXIT + ENDSWITCH NEXT RETURN cRet diff --git a/harbour/src/rtl/dirscan.prg b/harbour/src/rtl/dirscan.prg index f89f2e8764..b1db9aab75 100644 --- a/harbour/src/rtl/dirscan.prg +++ b/harbour/src/rtl/dirscan.prg @@ -91,5 +91,5 @@ FUNCTION hb_DirScan( cPath, cFileMask, cAttr ) RETURN HB_DoScan( cFilePath, ; iif( Empty( cFileMask ), hb_osFileMask(), cFileMask ), ; - iif( ValType( cAttr ) $ "CM", cAttr, "" ), ; + iif( HB_ISSTRING( cAttr ), cAttr, "" ), ; hb_ps() )