fixed F_ERROR usage, unicode fix, #if 0, cleanups

This commit is contained in:
Viktor Szakats
2013-03-21 13:10:30 +01:00
parent dd733c3806
commit 906ece32e2
13 changed files with 57 additions and 41 deletions

View File

@@ -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

View File

@@ -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 )

View File

@@ -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

View File

@@ -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( [<nAttrib>] ) --> lSuccess

View File

@@ -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 <cNewFile> 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."

View File

@@ -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 )

View File

@@ -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

View File

@@ -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 )

View File

@@ -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

View File

@@ -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 )

View File

@@ -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

View File

@@ -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 )

View File

@@ -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 )