diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0f87a7ebbe..66fc60c89d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,21 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-05 22:10 UTC+0200 Viktor Szakats (vszakats syenar.net) + * contrib/xhb/hterrsys.prg + * contrib/xhb/htmutil.prg + * contrib/xhb/tfile.prg + * contrib/xhb/xhberr.prg + * doc/en/file.txt + * extras/gfspell/spell.prg + * extras/guestbk/testcgi.prg + * extras/httpsrv/cgifunc.prg + * extras/httpsrv/uhttpd.prg + * tests/inifiles.prg + * utils/hbmk2/hbmk2.prg + ! TCgiFile():Tell() fixed to return correct value + * use fileio.ch constants instead of literals + 2012-10-05 21:31 UTC+0200 Viktor Szakats (vszakats syenar.net) * extras/hbvpdf/hbvpdf.prg ! s&r typo in recent mods diff --git a/harbour/contrib/xhb/hterrsys.prg b/harbour/contrib/xhb/hterrsys.prg index 1fd85f8620..d1046c48c6 100644 --- a/harbour/contrib/xhb/hterrsys.prg +++ b/harbour/contrib/xhb/hterrsys.prg @@ -66,7 +66,7 @@ STATIC s_cErrFooter := " " #if 0 -STATIC FUNC xhb_cgi_DefError( e ) +STATIC FUNCTION xhb_cgi_DefError( e ) LOCAL i LOCAL cMessage := "" diff --git a/harbour/contrib/xhb/htmutil.prg b/harbour/contrib/xhb/htmutil.prg index e0612d25f2..c922bba5f3 100644 --- a/harbour/contrib/xhb/htmutil.prg +++ b/harbour/contrib/xhb/htmutil.prg @@ -143,7 +143,7 @@ FUNCTION PutCounter( oHtm, nNumber, cDir, nDigits, nWidth, bgColor, nBorder ) RETURN Nil -PROC htmlBrowse( oHtm, cAction, lUseLinks ) +PROCEDURE htmlBrowse( oHtm, cAction, lUseLinks ) LOCAL i LOCAL n := 0 @@ -214,7 +214,7 @@ oHtm:endTable() #ifdef MYSQL -PROC htmlBrowseSql( oHtm, cAction, lUseLinks, cTarget, oServer, oQuery ) +PROCEDURE htmlBrowseSql( oHtm, cAction, lUseLinks, cTarget, oServer, oQuery ) LOCAL i LOCAL p diff --git a/harbour/contrib/xhb/tfile.prg b/harbour/contrib/xhb/tfile.prg index c2efa902b5..02e84cf4d2 100644 --- a/harbour/contrib/xhb/tfile.prg +++ b/harbour/contrib/xhb/tfile.prg @@ -78,7 +78,7 @@ CLASS TCgiFile METHOD Error() INLINE FError() != 0 - METHOD Tell() INLINE FSeek( ::handle, FS_RELATIVE, 0 ) + METHOD Tell() INLINE FSeek( ::handle, 0, FS_RELATIVE ) METHOD Pointer() INLINE FPOS( ::handle ) @@ -249,12 +249,12 @@ METHOD Readline( nSize ) CLASS TCgiFile RETURN "" ENDIF - nCurrent := FSeek( ::Handle, 0, 1 ) + nCurrent := FSeek( ::Handle, 0, FS_RELATIVE ) cString := FReadStr( ::Handle, nSize ) nCr := At( Chr( 13 ), cString ) - FSeek( ::Handle, nCurrent, 0 ) - FSeek( ::Handle, nCr + 1, 1 ) + FSeek( ::Handle, nCurrent, FS_SET ) + FSeek( ::Handle, nCr + 1, FS_RELATIVE ) ::Buffer := SubStr( cString, 1, nCr - 1 ) ::nRecord++ diff --git a/harbour/contrib/xhb/xhberr.prg b/harbour/contrib/xhb/xhberr.prg index 0a975f3db6..8a1b0ec90b 100644 --- a/harbour/contrib/xhb/xhberr.prg +++ b/harbour/contrib/xhb/xhberr.prg @@ -576,7 +576,7 @@ STATIC FUNCTION LogError( oerr ) nMemLength := FSeek( nMemHandle, 0, FS_END ) FSeek( nMemHandle, 0 ) nCount := 1 - WHILE FSeek( nMemHandle, 0, 1 ) + 1 < nMemLength + WHILE FSeek( nMemHandle, 0, FS_RELATIVE ) + 1 < nMemLength nMemWidth := Space( 18 ) FRead( nMemHandle, @nMemWidth, 18 ) cVarName := Left( nMemWidth, At( Chr( 0 ), nMemWidth ) - 1 ) diff --git a/harbour/doc/en/file.txt b/harbour/doc/en/file.txt index 2e8915fc1e..6e3466488f 100644 --- a/harbour/doc/en/file.txt +++ b/harbour/doc/en/file.txt @@ -69,7 +69,7 @@ * possible reasons for the error. * $EXAMPLES$ * #include "fileio.ch" - * IF ( nH := FOpen( "x.txt", 66 ) ) == F_ERROR + * IF ( nH := FOpen( "x.txt", FO_READWRITE + FO_DENYNONE ) ) == F_ERROR * ? "File can't be opened" * ENDIF * $STATUS$ diff --git a/harbour/extras/gfspell/spell.prg b/harbour/extras/gfspell/spell.prg index 93149db60a..ec8d5f765f 100644 --- a/harbour/extras/gfspell/spell.prg +++ b/harbour/extras/gfspell/spell.prg @@ -26,6 +26,7 @@ * **************************************************************************** +#include "fileio.ch" #xtranslate StoreWord() => Xform() #xtranslate ExtractWord() => Xunform() @@ -125,13 +126,13 @@ if SP_Init() .and. !empty( AUXILIARY_DICTIONARY ) // if file( AUXILIARY_DICTIONARY ) - nAuxHandle := fopen( AUXILIARY_DICTIONARY,2+32 ) + nAuxHandle := fopen( AUXILIARY_DICTIONARY, FO_READWRITE + FO_DENYWRITE ) else nAuxHandle := fcreate( AUXILIARY_DICTIONARY ) endif if nAuxHandle >= 0 - Fseek(nAuxHandle,0,2) // Bottom of the file + Fseek(nAuxHandle,0,FS_END) // Bottom of the file nWritten := Fwrite(nAuxHandle,; // Write word into file cWord+CRLF,len(cWord)+2) @@ -233,7 +234,7 @@ if sp_init() #ifdef REDUCE_MEMORY_NEEDS cOffsets := space(6) - fseek(nHandle,((nRow-1)*156)+((nCol-1)*6+1)+5,0) + fseek(nHandle,((nRow-1)*156)+((nCol-1)*6+1)+5,FS_SET) fread(nHandle,@cOffsets,6) x := bin2l(substr(cOffsets,1,4)) y := bin2w(substr(cOffsets,5,2)) @@ -248,7 +249,7 @@ if sp_init() if !empty(x) if !(cLast==substr(cLookup,1,2)) cBuf := space(y) - fseek(nHandle,x,0) + fseek(nHandle,x,FS_SET) fread(nHandle,@cBuf,y) nDicCount++ else @@ -314,7 +315,7 @@ if (nRow>0 .and. nRow<=26) .and. (nCol>0 .and. nCol<=26) if !empty(x) y := bin2w(substr(cOffsets,((nRow-1)*156)+((nCol-1)*EACH_WORD+5),2)) cBuf := space(y) - fseek(nHandle,x+4,0) + fseek(nHandle,x+4,FS_SET) fread(nHandle,@cBuf,y-4) endif endif @@ -388,17 +389,17 @@ LOCAL nSize if !empty(cFile) if file(cFile) - x := fopen(cFile,64) + x := fopen(cFile, FO_READ + FO_DENYNONE ) else x := fcreate(cFile) endif SP_GetSet(5,cFile) if x > 0 - nSize := fseek(x,0,2) + nSize := fseek(x,0,FS_END) if nSize < MAX_STRING cStr := space(nSize) - fseek(x,0,0) + fseek(x,0,FS_SET) fread(x,@cStr,nSize) cStr := "|"+strtran(cStr,CRLF,"|") CACHE_WORDS += upper(cStr) @@ -1082,7 +1083,7 @@ LOCAL nFileSize if cOffsets == NIL isok := .F. - nHandle := fopen(DICTIONARY_PATH+DICTIONARY_NAME,32) + nHandle := fopen(DICTIONARY_PATH+DICTIONARY_NAME, FO_READ + FO_DENYWRITE ) if nHandle > 0 #ifdef REDUCE_MEMORY_NEEDS @@ -1106,10 +1107,10 @@ if cOffsets == NIL #endif - nFileSize := fseek(nHandle,0,2) + nFileSize := fseek(nHandle,0,FS_END) if nFileSize-nOther > 0 cOther := space(nFileSize-nOther) - fseek(nHandle,nOther,0) + fseek(nHandle,nOther,FS_SET) fread(nHandle,@cOther,(nFileSize-nOther)) endif aGlobal[2] += cOther @@ -1271,21 +1272,21 @@ if nH >= 0 enddo if !empty(temp) .or. cBits != FOUR_BYTES - nWhere := fseek(nH,0,2) + nWhere := fseek(nH,0,FS_END) Fseek(nH,((i-1)*26*EACH_WORD)+((j-1)*EACH_WORD)+6) Fwrite(nH,l2bin(nWhere)+i2bin(len(temp)+4),EACH_WORD) - Fseek(nH,0,2) + Fseek(nH,0,FS_END) Fwrite(nH,cBits+temp,len(temp)+4) endif next enddo next - j := fseek(nH,0,2) - fseek(nH,2,0) + j := fseek(nH,0,FS_END) + fseek(nH,2,FS_SET) fwrite(nH,l2bin(j),4) if !empty(cOther) - fseek(nH,j,0) + fseek(nH,j,FS_SET) cOther += "|" fwrite(nH,cOther,len(cOther)) endif @@ -1410,7 +1411,7 @@ for i := 1 to 26 endif cBuf := space(y) - fseek(nHandle,x,0) + fseek(nHandle,x,FS_SET) fread(nHandle,@cBuf,y) for z := 1 to 26 if bit(cBuf,z) diff --git a/harbour/extras/guestbk/testcgi.prg b/harbour/extras/guestbk/testcgi.prg index bc8c6db205..f11452562f 100644 --- a/harbour/extras/guestbk/testcgi.prg +++ b/harbour/extras/guestbk/testcgi.prg @@ -21,6 +21,8 @@ * **/ +#include "fileio.ch" + #include "cgi.ch" #define IF_BUFFER 65535 @@ -195,7 +197,7 @@ STATIC FUNCTION Generate() ::cHTMLFile ELSE // Read from file - hFile := FOpen( ::cHTMLFile, 0 ) + hFile := FOpen( ::cHTMLFile, FO_READ ) cFile := Space( IF_BUFFER ) DO WHILE ( nPos := FRead( hFile, @cFile, IF_BUFFER ) ) > 0 diff --git a/harbour/extras/httpsrv/cgifunc.prg b/harbour/extras/httpsrv/cgifunc.prg index ac52661f86..22d0e68432 100644 --- a/harbour/extras/httpsrv/cgifunc.prg +++ b/harbour/extras/httpsrv/cgifunc.prg @@ -725,7 +725,7 @@ PROCEDURE uhttpd_WriteToLogFile( cString, cLog, lCreate ) //cString := "PROCEDURE: " + ProcName( -2 ) + " " + cString IF nHandle > 0 - FSeek( nHandle, 0, 2 ) + FSeek( nHandle, 0, FS_END ) FWrite( nHandle, cString ) FWrite( nHandle, CRLF ) FClose( nHandle ) diff --git a/harbour/extras/httpsrv/uhttpd.prg b/harbour/extras/httpsrv/uhttpd.prg index f622ee5d17..4d51c4fd80 100644 --- a/harbour/extras/httpsrv/uhttpd.prg +++ b/harbour/extras/httpsrv/uhttpd.prg @@ -497,7 +497,7 @@ PROCEDURE Main( ... ) // --------------------- Open log files ------------------------------------- - IF ( s_hfileLogAccess := FOPEN( cLogAccess, FO_CREAT + FO_WRITE ) ) == -1 + IF ( s_hfileLogAccess := FOPEN( cLogAccess, FO_CREAT + FO_WRITE ) ) == F_ERROR ? "Can't open access log file" WAIT ErrorLevel( 1 ) @@ -505,7 +505,7 @@ PROCEDURE Main( ... ) ENDIF FSEEK( s_hfileLogAccess, 0, FS_END ) - IF ( s_hfileLogError := FOPEN( cLogError, FO_CREAT + FO_WRITE ) ) == -1 + IF ( s_hfileLogError := FOPEN( cLogError, FO_CREAT + FO_WRITE ) ) == F_ERROR ? "Can't open error log file" WAIT ErrorLevel( 1 ) @@ -2175,7 +2175,7 @@ STATIC FUNCTION Exe_Path() IF nPos == 0 cPath := "" ELSE - cPath := SubStr( cPath, 1, nPos-1 ) + cPath := SubStr( cPath, 1, nPos - 1 ) ENDIF RETURN cPath diff --git a/harbour/tests/inifiles.prg b/harbour/tests/inifiles.prg index d0a39f1c49..5e10fde0f8 100644 --- a/harbour/tests/inifiles.prg +++ b/harbour/tests/inifiles.prg @@ -2,6 +2,8 @@ * $Id$ */ +#include "fileio.ch" + PROCEDURE Main( cFilename, cSection ) LOCAL oIni := TIniFile():New( Default( cFilename, "harbour.ini" ) ) @@ -72,7 +74,7 @@ STATIC FUNCTION New( cFileName ) CurrArray := ::Contents IF File( cFileName ) - hFile := FOpen( cFilename, 0 ) + hFile := FOpen( cFilename, FO_READ ) ELSE hFile := FCreate( cFilename ) ENDIF diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 8ad27df375..3bc015dfa6 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -10949,7 +10949,7 @@ STATIC FUNCTION rtlnk_read( cFileName, aPrevFiles ) /* protection against recursive calls */ IF AScan( aPrevFiles, {| x | x == cFileName } ) == 0 - IF ( hFile := FOpen( cFileName ) ) != -1 + IF ( hFile := FOpen( cFileName ) ) != F_ERROR cFileBody := Space( FSeek( hFile, 0, FS_END ) ) FSeek( hFile, 0, FS_SET ) IF FRead( hFile, @cFileBody, hb_BLen( cFileBody ) ) != hb_BLen( cFileBody )