--- a/FilteringLineStream.st Fri Feb 18 15:40:57 2000 +0100
+++ b/FilteringLineStream.st Thu Mar 02 15:15:13 2000 +0100
@@ -1,6 +1,8 @@
+"{ Package: 'stx:goodies' }"
+
"
COPYRIGHT (c) 1996 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -24,7 +26,7 @@
copyright
"
COPYRIGHT (c) 1996 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -53,10 +55,10 @@
[author:]
- Claus Gittinger
+ Claus Gittinger
[See also:]
- FilteringStream ReadStream WriteStream
+ FilteringStream ReadStream WriteStream
"
@@ -67,17 +69,17 @@
pushing the contents of a stream onto another stream
(here, the Transcript) without a need to read everyting into a
buffer or to reinvent the read-loop:
- [exBegin]
+ [exBegin]
|in pusher|
in := 'Makefile' asFilename readStream.
pusher := FilteringLineStream readingFrom:in writingTo:Transcript.
pusher filterUpToEnd
- [exEnd]
+ [exEnd]
filter all comments (starting with '#') from a Makefile:
- [exBegin]
+ [exBegin]
|in filter|
in := 'Makefile' asFilename readStream.
@@ -88,11 +90,11 @@
filter outputStream:Transcript.
filter filterUpToEnd
- [exEnd]
+ [exEnd]
the inverse - remove all comments from the Makefile:
- [exBegin]
+ [exBegin]
|in filter|
in := 'Makefile' asFilename readStream.
@@ -103,12 +105,12 @@
filter outputStream:Transcript.
filter filterUpToEnd
- [exEnd]
+ [exEnd]
feed a second filter from the first filters output;
(the remains are all lines starting with '#' and ending with '-'):
- [exBegin]
+ [exBegin]
|in filter1 filter2|
in := 'Makefile' asFilename readStream.
@@ -122,7 +124,7 @@
filter2 outputStream:Transcript.
filter2 filterUpToEnd
- [exEnd]
+ [exEnd]
"
! !
@@ -134,7 +136,7 @@
push it filtered into the outputStream."
[inputStream atEnd] whileFalse:[
- self nextPutLine:(inputStream nextLine)
+ self nextPutLine:(inputStream nextLine)
].
"Created: 11.1.1997 / 16:09:05 / cg"
@@ -148,18 +150,18 @@
|output|
lineFilter isNil ifTrue:[
- lineBuffer notNil ifTrue:[
- outputStream nextPutAll:lineBuffer
- ].
- outputStream cr
+ lineBuffer notNil ifTrue:[
+ outputStream nextPutAll:lineBuffer
+ ].
+ outputStream cr
] ifFalse:[
- lineBuffer isNil ifTrue:[lineBuffer := ''].
+ lineBuffer isNil ifTrue:[lineBuffer := ''].
- output := lineFilter value:lineBuffer.
- output notNil ifTrue:[
- outputStream nextPutAll:output.
- outputStream cr.
- ]
+ output := lineFilter value:lineBuffer.
+ output notNil ifTrue:[
+ outputStream nextPutAll:output.
+ outputStream cr.
+ ]
].
lineBuffer := ''.
@@ -170,10 +172,10 @@
"collect a line and push it when a cr arrives"
something == Character cr ifTrue:[
- self cr
+ self cr
] ifFalse:[
- lineBuffer isNil ifTrue:[lineBuffer := ''].
- lineBuffer := lineBuffer copyWith:something.
+ lineBuffer isNil ifTrue:[lineBuffer := ''].
+ lineBuffer := lineBuffer copyWith:something.
]
"Created: 2.7.1996 / 20:54:38 / cg"
@@ -184,9 +186,9 @@
"collect a line and push it when a cr arrives"
lineBuffer isNil ifTrue:[
- lineBuffer := something
+ lineBuffer := something
] ifFalse:[
- lineBuffer := lineBuffer , something.
+ lineBuffer := lineBuffer , something.
]
"Modified: 11.1.1997 / 16:31:28 / cg"
@@ -213,5 +215,5 @@
!FilteringLineStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.4 1997-01-11 15:51:18 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.5 2000-03-02 14:15:07 cg Exp $'
! !