From 906ece32e2988279381d778ffde0b6559eb5abf4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 21 Mar 2013 13:10:30 +0100 Subject: [PATCH] fixed F_ERROR usage, unicode fix, #if 0, cleanups --- ChangeLog.txt | 17 +++++++++++++++++ contrib/hbmisc/hbedit.prg | 5 ++--- contrib/xhb/stream.prg | 6 +++--- contrib/xhb/tfile.prg | 4 ++-- doc/en/file.txt | 24 ++++++++++++------------ extras/gfspell/spell.prg | 4 ++-- extras/guestbk/cgi.prg | 6 +++--- extras/guestbk/inifiles.prg | 8 ++++---- extras/hbvpdf/core.prg | 4 ++-- extras/httpsrv/_cgifunc.prg | 2 +- src/rdd/usrrdd/rdds/logrdd.prg | 4 ++-- tests/inifiles.prg | 8 ++++---- tests/longdev.prg | 6 +++--- 13 files changed, 57 insertions(+), 41 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9ef3daa0f9..000f5cb68c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,23 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-03-21 13:08 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbmisc/hbedit.prg + * contrib/xhb/stream.prg + * contrib/xhb/tfile.prg + * doc/en/file.txt + * extras/gfspell/spell.prg + * extras/httpsrv/_cgifunc.prg + * src/rdd/usrrdd/rdds/logrdd.prg + * tests/inifiles.prg + ! fixed F_ERROR usage + + * extras/guestbk/cgi.prg + * extras/guestbk/inifiles.prg + * extras/hbvpdf/core.prg + * tests/longdev.prg + * unicode fix, #if 0, cleanups + 2013-03-21 12:40 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbtip/client.prg * contrib/hbtip/ftpcli.prg diff --git a/contrib/hbmisc/hbedit.prg b/contrib/hbmisc/hbedit.prg index 18314512e1..1e642cc445 100644 --- a/contrib/hbmisc/hbedit.prg +++ b/contrib/hbmisc/hbedit.prg @@ -476,13 +476,12 @@ STATIC FUNCTION EditorSave( oEdit ) ENDIF nHandle := FCreate( cFile, FC_NORMAL ) - IF nHandle > 0 + IF nHandle != F_ERROR FWrite( nHandle, EditorGetText( oEdit ) ) - FClose( nHandle ) ENDIF - RETURN nHandle > 0 + RETURN nHandle != F_ERROR FUNCTION SaveBox( top, left, bott, right, color, patt ) diff --git a/contrib/xhb/stream.prg b/contrib/xhb/stream.prg index 52586a1c93..061f8dacba 100644 --- a/contrib/xhb/stream.prg +++ b/contrib/xhb/stream.prg @@ -150,7 +150,7 @@ METHOD New( cFile, nMode ) CLASS TStreamFileReader ENDIF ::Handle := FOpen( cFile, nMode ) - IF ::Handle <= 0 + IF ::Handle == F_ERROR Throw( xhb_ErrorNew( "Stream", 0, 1004, ProcName(), "Open Error: " + Str( FError() ), hb_AParams() ) ) ENDIF @@ -221,7 +221,7 @@ METHOD New( cFile, nMode ) CLASS TStreamFileWriter __defaultNIL( @nMode, FO_READWRITE ) ::Handle := FOpen( cFile, nMode ) - IF ::Handle <= 0 + IF ::Handle == F_ERROR Throw( xhb_ErrorNew( "Stream", 0, 1004, ProcName(), "Open Error: " + Str( FError() ), hb_AParams() ) ) ENDIF @@ -231,7 +231,7 @@ METHOD New( cFile, nMode ) CLASS TStreamFileWriter __defaultNIL( @nMode, FC_NORMAL ) ::Handle := FCreate( cFile, nMode ) - IF ::Handle <= 0 + IF ::Handle == F_ERROR Throw( xhb_ErrorNew( "Stream", 0, 1004, ProcName(), "Create Error: " + Str( FError() ), hb_AParams() ) ) ENDIF diff --git a/contrib/xhb/tfile.prg b/contrib/xhb/tfile.prg index 4a907c94ae..d7195a5624 100644 --- a/contrib/xhb/tfile.prg +++ b/contrib/xhb/tfile.prg @@ -168,11 +168,11 @@ METHOD Open( nMode ) CLASS TCgiFile __defaultNIL( @nMode, FO_EXCLUSIVE ) ::Handle := FOpen( ::Name, nMode ) - IF ::Handle > 0 + IF ::Handle != F_ERROR ::Size() ENDIF - RETURN ::Handle > 0 + RETURN ::Handle != F_ERROR /* ** ::Create( [] ) --> lSuccess diff --git a/doc/en/file.txt b/doc/en/file.txt index 31f62a864c..33e9373ccc 100644 --- a/doc/en/file.txt +++ b/doc/en/file.txt @@ -65,7 +65,7 @@ possible reasons for the error. $EXAMPLES$ #include "fileio.ch" - IF ( nH := FOpen( "x.txt", FO_READWRITE + FO_DENYNONE ) ) == F_ERROR + IF ( nH := FOpen( "test.txt", FO_READWRITE + FO_DENYNONE ) ) == F_ERROR ? "File can't be opened" ENDIF $STATUS$ @@ -187,7 +187,7 @@ $EXAMPLES$ #include "fileio.ch" cBuffer := Space( 500 ) - IF ( nH := FOpen( "x.txt" ) ) == F_ERROR + IF ( nH := FOpen( "test.txt" ) ) == F_ERROR FRead( nH, @cBuffer, 500 ) ? cbuffer ENDIF @@ -245,7 +245,7 @@ to the file. To truncate a file, a call of FWrite( nHandle, "", 0 ) is needed. $EXAMPLES$ - nHandle := FCreate( "x.txt" ) + nHandle := FCreate( "test.txt" ) FOR X := 1 TO 10 FWrite( nHandle, Str( x ) ) NEXT @@ -309,7 +309,7 @@ of possibles values returned by the FError() function. $EXAMPLES$ #include "fileio.ch" - nHandle := FCreate( "temp.txt", FC_NORMAL ) + nHandle := FCreate( "test.txt", FC_NORMAL ) IF FError() != 0 ? "Cannot create file, OS error ", FError() ENDIF @@ -348,7 +348,7 @@ or FOpen() function. $EXAMPLES$ #include "fileio.ch" - nHandle := FOpen( "x.txt" ) + nHandle := FOpen( "test.txt" ) ? FSeek( nHandle, 0, FS_END ) FClose( nHandle ) $STATUS$ @@ -396,7 +396,7 @@ $EXAMPLES$ #include "fileio.ch" - IF FErase( "test.txt" ) != F_ERROR + IF FErase( "test.txt" ) == 0 ? "File successfully erased" ELSE ? "File can not be deleted" @@ -455,8 +455,8 @@ mation about any error found. $EXAMPLES$ #include "fileio.ch" - nResult := FRename( "x.txt", "x1.txt" ) - IF nResult == F_ERROR + nResult := FRename( "test.txt", "test1.txt" ) + IF nResult != 0 ? "File could not be renamed." ENDIF $STATUS$ @@ -632,7 +632,7 @@ function. $EXAMPLES$ #include "fileio.ch" - IF ( nH := FOpen( "x.txt" ) ) != F_ERROR + IF ( nH := FOpen( "test.txt" ) ) != F_ERROR cStr := FReadStr( nH, 100 ) ? cStr FClose( nH ) @@ -677,7 +677,7 @@ If id currently open or if it previously exists, this command will not perform the desired operation. $EXAMPLES$ - RENAME hello.txt TO hello.old + RENAME test.txt TO test.old $STATUS$ R $COMPLIANCE$ @@ -875,7 +875,7 @@ SET CONSOLE ON // display mytext.dat file on screen and into a file myreport.txt - TYPE mytext.dat TO FILE MyReport + TYPE mytext.dat TO FILE myreport $STATUS$ R $COMPLIANCE$ @@ -987,7 +987,7 @@ function returns .T. and sets the value returned by FError() to -1 (FS_ERROR) or a C-compiler dependent errno value (EBADF or EINVAL). $EXAMPLES$ - nH := FOpen( "file.txt" ) + nH := FOpen( "test.txt" ) ? FReadStr( nH, 80 ) IF hb_FEof( nH ) ? "End-of-file reached." diff --git a/extras/gfspell/spell.prg b/extras/gfspell/spell.prg index 9d84b08018..d1d267b988 100644 --- a/extras/gfspell/spell.prg +++ b/extras/gfspell/spell.prg @@ -113,7 +113,7 @@ FUNCTION Sp_Add( cWord ) ELSE nAuxHandle := FCreate( AUXILIARY_DICTIONARY ) ENDIF - IF nAuxHandle >= 0 + IF nAuxHandle != F_ERROR FSeek( nAuxHandle, 0, FS_END ) // Bottom of the file nWritten := FWrite( nAuxHandle, cWord + CRLF ) // Write word into file @@ -326,7 +326,7 @@ FUNCTION Sp_LoadAux( cFile ) ENDIF Sp_GetSet( 5, cFile ) - IF x > 0 + IF x != F_ERROR nSize := FSeek( x, 0, FS_END ) IF nSize < MAX_STRING cStr := Space( nSize ) diff --git a/extras/guestbk/cgi.prg b/extras/guestbk/cgi.prg index 967ea93805..10b7eba096 100644 --- a/extras/guestbk/cgi.prg +++ b/extras/guestbk/cgi.prg @@ -148,7 +148,7 @@ METHOD Generate() CLASS THTML cFile := Space( IF_BUFFER ) DO WHILE ( nPos := FRead( hFile, @cFile, IF_BUFFER ) ) > 0 - cFile := Left( cFile, nPos ) + cFile := hb_BLeft( cFile, nPos ) cRes += cFile cFile := Space( IF_BUFFER ) @@ -167,7 +167,7 @@ METHOD Generate() CLASS THTML ENDDO /* TODO: Clear remaining (not matched) tags */ - /* +#if 0 cRes := "" FOR i := 1 TO Len( ::cContent ) IF SubStr( ::cContent, i, 1 ) == "<" .AND. ; @@ -181,7 +181,7 @@ METHOD Generate() CLASS THTML NEXT ::cContent := cRes - */ +#endif ENDIF ENDIF diff --git a/extras/guestbk/inifiles.prg b/extras/guestbk/inifiles.prg index 5271a0758c..31b3db1672 100644 --- a/extras/guestbk/inifiles.prg +++ b/extras/guestbk/inifiles.prg @@ -26,7 +26,7 @@ END CLASS METHOD New( cFileName ) CLASS TIniFile - LOCAL Done, hFile, cFile, cLine, cIdent, nPos + LOCAL lDone, hFile, cFile, cLine, cIdent, nPos LOCAL CurrArray IF Empty( cFileName ) @@ -46,10 +46,10 @@ METHOD New( cFileName ) CLASS TIniFile ENDIF cLine := "" - Done := .F. - DO WHILE ! Done + lDone := .F. + DO WHILE ! lDone cFile := Space( 256 ) - Done := ( FRead( hFile, @cFile, 256 ) <= 0 ) + lDone := ( FRead( hFile, @cFile, 256 ) <= 0 ) cFile := StrTran( cFile, Chr( 13 ) ) // so we can just search for Chr( 10 ) diff --git a/extras/hbvpdf/core.prg b/extras/hbvpdf/core.prg index 0c55b0a79c..ce3ba3defe 100644 --- a/extras/hbvpdf/core.prg +++ b/extras/hbvpdf/core.prg @@ -531,11 +531,11 @@ FUNCTION pdfClose() hb_ntos( t_aReport[ DOCLEN ] ) + CRLF + ; "%%EOF" + CRLF FWrite( t_aReport[ HANDLE ], cTemp ) -/* +#if 0 IF t_aReport[ OPTIMIZE ] pdfOptimize( ) coming ! ENDIF -*/ +#endif FClose( t_aReport[ HANDLE ] ) t_aReport := nil diff --git a/extras/httpsrv/_cgifunc.prg b/extras/httpsrv/_cgifunc.prg index 2fd66c3a31..fdbd3671fa 100644 --- a/extras/httpsrv/_cgifunc.prg +++ b/extras/httpsrv/_cgifunc.prg @@ -592,7 +592,7 @@ PROCEDURE uhttpd_WriteToLogFile( cString, cLog, lCreate ) // cString := "PROCEDURE: " + ProcName( -2 ) + " " + cString - IF nHandle > 0 + IF nHandle != F_ERROR FSeek( nHandle, 0, FS_END ) FWrite( nHandle, cString ) FWrite( nHandle, CRLF ) diff --git a/src/rdd/usrrdd/rdds/logrdd.prg b/src/rdd/usrrdd/rdds/logrdd.prg index 05decb5102..29044733bc 100644 --- a/src/rdd/usrrdd/rdds/logrdd.prg +++ b/src/rdd/usrrdd/rdds/logrdd.prg @@ -385,12 +385,12 @@ STATIC PROCEDURE OpenLogFile( nWA ) ELSE nHandle := FCreate( cFileName ) /* Close and reopen in shared mode */ - IF FError() == 0 .AND. nHandle > 0 + IF FError() == 0 .AND. nHandle != F_ERROR FClose( nHandle ) nHandle := FOpen( cFileName, FO_READWRITE + FO_SHARED ) ENDIF ENDIF - IF FError() == 0 .AND. nHandle > 0 + IF FError() == 0 .AND. nHandle != F_ERROR /* Move to end of file */ FSeek( nHandle, 0, FS_END ) ELSE diff --git a/tests/inifiles.prg b/tests/inifiles.prg index 6af15893ec..85c83d18c9 100644 --- a/tests/inifiles.prg +++ b/tests/inifiles.prg @@ -55,7 +55,7 @@ END CLASS METHOD New( cFileName ) CLASS TIniFile - LOCAL Done, hFile, cFile, cLine, cIdent, nPos + LOCAL lDone, hFile, cFile, cLine, cIdent, nPos LOCAL CurrArray IF Empty( cFileName ) @@ -75,10 +75,10 @@ METHOD New( cFileName ) CLASS TIniFile ENDIF cLine := "" - Done := .F. - DO WHILE ! Done + lDone := .F. + DO WHILE ! lDone cFile := Space( 256 ) - Done := ( FRead( hFile, @cFile, 256 ) <= 0 ) + lDone := ( FRead( hFile, @cFile, 256 ) <= 0 ) cFile := StrTran( cFile, Chr( 13 ) ) // so we can just search for Chr( 10 ) diff --git a/tests/longdev.prg b/tests/longdev.prg index 96c2f71d46..21ea167a0d 100644 --- a/tests/longdev.prg +++ b/tests/longdev.prg @@ -16,8 +16,8 @@ PROCEDURE Main() cLong += cLong NEXT - // Write the long string to file long_str.prn - SET PRINTER TO long_str + // Write the long string to file longdev.prn + SET PRINTER TO longdev SET DEVICE TO PRINTER DevOut( cLong ) SET PRINTER OFF @@ -30,7 +30,7 @@ PROCEDURE Main() ? "The copy of the long string is", iif( cLong == cBuffer, "equal", "not equal" ), "to the long string" // Read the string back in and compare it to the original. - nHandle := FOpen( "long_str.prn" ) + nHandle := FOpen( "longdev.prn" ) cBuffer := FReadStr( nHandle, 90000 ) ? "Original:", Len( cLong ) ? "From file:", Len( cBuffer )