* utils/hbmk2/hbmk2.*.po
* utils/hbmk2/hbmk2.prg
+ do not share plugin variables (hbmk[ "vars" ])
between different plugins. It avoids potentially nasty
issues with plugins stepping onto each other's toes.
[INCOMPATIBLE - though it's unlikely anyone is
affected. If you must communicate between plugins,
use public function or variable.]
+ clarified in help that -icon might not work on all
platforms/compilers and detailed Windows implementation
(in particular it's disabled on bcc/bcc64 and on
mingw it won't work when a manual .rc is specified,
also on some (old?) msvc versions. Consult your
C compiler's Windows resource handling limitations.)
+ clarified in help the syntax of filters
+ clarified in help that .hbp references are handled as
sub-projects
+ clarification to command substitution macro
+ clarification to filter syntax note
! strict parameter checks in all public shell APIs to
avoid RTEs inside hbmk2 due to faulty API usage by scripts
* utils/hbmk2/examples/plug_bis.hb
* updated according to latest plugin changes
* include/harbour.hbx
* include/hbapi.h
* src/vm/debug.c
* src/vm/hvm.c
+ added internal function hb_vmInternalsEnabled()
to query whether potentially sensitive internals
are allowed to be accessed by public Harbour APIs
+ added .prg level function __vmNoInternals()
to disable potentially sensitive internals
by default accessible via public APIs.
Intentionally a one-way function: once disabled,
it cannot be reenabled from .prg or .c level.
NOTE: It will break Harbour debug functionality,
so it'd will be useful for hbrun scripts and
release (non-debug) builds.
+ modified internal __dbg*() functions to return
dummy values when internals are disabled via
__vmNoInternals() functions. While the function
return types are kept, apps relying on their
specific values and certain relationships between
them might break.
; NOTE: In the future, some more internals might
be protected by this setting (f.e. low-level
object and class functions and some API from
hbdebug lib)
; Please review
* tests/debugtst.prg
! fixed to compile warning-free without lowering
warning level
! fixed to run RTE-free with internals disabled
* bin/3rdpatch.hb
* bin/commit.hb
* config/postinst.hb
* contrib/make.hb
* contrib/hbtest/hbtest.ch
* src/debug/*.prg
* src/rtl/tclass.prg
* utils/hbmk2/examples/plug_bis.hb
* utils/hbmk2/examples/plug_tpl.hb
* use short form #pragmas (the ones identical
to Harbour options)
; NOTE: Except -l which works reversed compared
to cmdline -l option. TOFIX? (I tried and failed)
* src/rtl/hbi18n2.prg
* contrib/xhb/tfile.prg
* use F_ERROR instead of -1 literal
* contrib/xhb/xhbtedit.prg
! replaced dirty xhb extension with std SubStr() call
Reported by Tony Quick
[pls report such bugs on Harbour devl list]
* contrib/hbodbc/todbc.prg
! Don't continue ::Open() when SQLExecDir() have error
Fix from xhb via Vicente Guerra, with cleanups.
* tests/multifnc/multifnc.hbp
+ added comment
+ support for watcom
* tests/multifnc/t1.prg
! missing file ending EOL
* tests/*.prg
* extras/gtwvw/tests/wvwtest9.prg
* formatting
239 lines
5.8 KiB
Plaintext
239 lines
5.8 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
#include "fileio.ch"
|
|
#include "hbclass.ch"
|
|
|
|
//
|
|
// The Harbour stripping command
|
|
//
|
|
// Usage : Strip( FileFrom, FileTo )
|
|
//
|
|
// The output from FileFrom is copied to FileTo except for the empty lines
|
|
//
|
|
// Default files : From = strip.prg To = strip.out
|
|
//
|
|
|
|
/*
|
|
* Written by Eddie Runia <eddie@runia.com>
|
|
* www - http://harbour-project.org
|
|
*
|
|
* Placed in the public domain
|
|
*/
|
|
|
|
PROCEDURE Main( cFrom, cTo )
|
|
|
|
LOCAL oFrom
|
|
LOCAL oTo
|
|
LOCAL cOut
|
|
|
|
hb_default( @cFrom, __FILE__ )
|
|
hb_default( @cTo, "strip.out" )
|
|
|
|
oFrom := TTextFile()
|
|
// ? hb_ValToExp( __objGetMethodList( oFrom ) )
|
|
oFrom:New( cFrom, "R" )
|
|
oTo := TTextFile()
|
|
// ? hb_ValToExp( __objGetMethodList( oTo ) )
|
|
oTo:New( cTo, "W" )
|
|
|
|
DO WHILE ! oFrom:Eof()
|
|
cOut := oFrom:Run()
|
|
IF ! Empty( cOut )
|
|
oTo:Run( cOut )
|
|
ENDIF
|
|
ENDDO
|
|
? "Number of lines", oTo:nLine
|
|
oFrom:Dispose()
|
|
oTo:Dispose()
|
|
|
|
RETURN
|
|
|
|
//
|
|
// Generic file handler
|
|
//
|
|
|
|
CREATE CLASS TTextFile
|
|
|
|
VAR cFileName // Filename spec. by user
|
|
VAR hFile // File handle
|
|
VAR nLine // Current linenumber
|
|
VAR nError // Last error
|
|
VAR lEoF // End of file
|
|
VAR cBlock // Storage block
|
|
VAR nBlockSize // Size of read-ahead buffer
|
|
VAR cMode // Mode of file use R = read, W = write
|
|
|
|
METHOD New( cFileName, cMode, nBlock ) // Constructor
|
|
METHOD Dispose() // Clean up code
|
|
METHOD Read() // Read line
|
|
METHOD WriteLn( xTxt, lCRLF ) // Write line
|
|
METHOD Goto( nLine ) // Go to line
|
|
|
|
METHOD Run( xTxt, lCRLF ) INLINE iif( ::cMode == "R", ::Read(), ::WriteLn( xTxt, lCRLF ) )
|
|
METHOD Write( xTxt ) INLINE ::WriteLn( xTxt, .F. ) // Write without CR
|
|
METHOD Eof() INLINE ::lEoF
|
|
|
|
END CLASS
|
|
|
|
//
|
|
// Method TextFile:New -> Create a new text file
|
|
//
|
|
// <cFile> file name. No wild characters
|
|
// <cMode> mode for opening. Default "R"
|
|
// <nBlockSize> Optional maximum blocksize
|
|
//
|
|
|
|
METHOD New( cFileName, cMode, nBlock ) CLASS TTextFile
|
|
|
|
hb_default( @cMode, "R" )
|
|
hb_default( @nBlock, 4096 )
|
|
|
|
::nLine := 0
|
|
::lEoF := .F.
|
|
::cBlock := ""
|
|
::cFileName := cFileName
|
|
::cMode := cMode
|
|
|
|
IF ::cMode == "R"
|
|
::hFile := FOpen( cFileName )
|
|
ELSEIF ::cMode == "W"
|
|
::hFile := FCreate( cFileName )
|
|
ELSE
|
|
? "File Init: Unknown file mode:", ::cMode
|
|
ENDIF
|
|
|
|
::nError := FError()
|
|
IF ::nError != 0
|
|
::lEoF := .T.
|
|
? "Error ", ::nError
|
|
ENDIF
|
|
::nBlockSize := nBlock
|
|
|
|
RETURN self
|
|
|
|
//
|
|
// Dispose -> Close the file handle
|
|
//
|
|
|
|
METHOD Dispose() CLASS TTextFile
|
|
|
|
::cBlock := NIL
|
|
IF ::hFile != F_ERROR
|
|
IF ! FClose( ::hFile )
|
|
::nError := FError()
|
|
? "OS Error closing ", ::cFileName, " Code ", ::nError
|
|
ENDIF
|
|
ENDIF
|
|
|
|
RETURN self
|
|
|
|
//
|
|
// Read a single line
|
|
//
|
|
|
|
METHOD Read() CLASS TTextFile
|
|
|
|
LOCAL cRet := ""
|
|
LOCAL cBlock
|
|
LOCAL nCrPos
|
|
LOCAL nEoFPos
|
|
|
|
IF ::hFile == F_ERROR
|
|
? "File:Read : No file open"
|
|
ELSEIF !( ::cMode == "R" )
|
|
? "File ", ::cFileName, " not open for reading"
|
|
ELSEIF ! ::lEoF
|
|
|
|
IF Len( ::cBlock ) == 0 // Read new block
|
|
cBlock := FReadStr( ::hFile, ::nBlockSize )
|
|
IF Len( cBlock ) == 0
|
|
::nError := FError() // Error or EOF
|
|
::lEoF := .T.
|
|
ELSE
|
|
::cBlock := cBlock
|
|
ENDIF
|
|
ENDIF
|
|
|
|
IF ! ::lEoF
|
|
::nLine++
|
|
nCRPos := At( Chr( 10 ), ::cBlock )
|
|
IF nCRPos != 0 // More than one line read
|
|
cRet := SubStr( ::cBlock, 1, nCRPos - 1 )
|
|
::cBlock := SubStr( ::cBlock, nCRPos + 1 )
|
|
ELSE // No complete line
|
|
cRet := ::cBlock
|
|
::cBlock := ""
|
|
cRet += ::Read() // Read the rest
|
|
IF ! ::lEoF
|
|
::nLine-- // Adjust erroneous line count
|
|
ENDIF
|
|
ENDIF
|
|
nEoFPos := hb_BAt( Chr( 26 ), cRet )
|
|
IF nEoFPos != 0 // End of file read
|
|
cRet := hb_BSubStr( cRet, 1, nEoFPos - 1 )
|
|
::lEoF := .T.
|
|
ENDIF
|
|
cRet := StrTran( cRet, Chr( 13 ) ) // Remove CR
|
|
ENDIF
|
|
ENDIF
|
|
|
|
RETURN cRet
|
|
|
|
//
|
|
// WriteLn -> Write a line to a file
|
|
//
|
|
// <xTxt> Text to write. May be any type. May also be an array containing
|
|
// one or more strings
|
|
// <lCRLF> End with Carriage Return/Line Feed (Default == TRUE)
|
|
//
|
|
|
|
METHOD WriteLn( xTxt, lCRLF ) CLASS TTextFile
|
|
|
|
LOCAL cBlock
|
|
|
|
IF ::hFile == F_ERROR
|
|
? "File:Write : No file open"
|
|
ELSEIF !( ::cMode == "W" )
|
|
? "File ", ::cFileName, " not opened for writing"
|
|
ELSE
|
|
hb_default( @lCRLF, .T. )
|
|
cBlock := hb_ValToExp( xTxt ) // Convert to string
|
|
IF lCRLF
|
|
cBlock += hb_eol()
|
|
ENDIF
|
|
FWrite( ::hFile, cBlock, Len( cBlock ) )
|
|
IF FError() != 0
|
|
::nError := FError() // Not completely written !
|
|
ENDIF
|
|
::nLine := ::nLine + 1
|
|
ENDIF
|
|
|
|
RETURN self
|
|
|
|
//
|
|
// Go to a specified line number
|
|
//
|
|
|
|
METHOD Goto( nLine ) CLASS TTextFile
|
|
|
|
LOCAL nWhere := 1
|
|
|
|
IF Empty( ::hFile )
|
|
? "File:Goto : No file open"
|
|
ELSEIF !( ::cMode == "R" )
|
|
? "File ", ::cFileName, " not open for reading"
|
|
ELSE
|
|
::lEoF := .F. // Clear (old) End of file
|
|
::nLine := 0 // Start at beginning
|
|
::cBlock := ""
|
|
FSeek( ::hFile, 0 ) // Go top
|
|
DO WHILE ! ::lEoF .AND. nWhere < nLine
|
|
nWhere++
|
|
::Run()
|
|
ENDDO
|
|
ENDIF
|
|
|
|
RETURN ! ::lEoF
|