--- a/Stream.st Fri Jan 24 11:33:07 1997 +0100
+++ b/Stream.st Fri Jan 24 14:10:21 1997 +0100
@@ -1012,6 +1012,53 @@
"Modified: 15.5.1996 / 17:58:57 / cg"
!
+nextUpTo:anObject
+ "read a collection of all objects up-to anObject and return these
+ elements, but excluding anObject.
+ The next read operation will return anObject.
+ If anObject is not encountered, all elements up to the end are read
+ and returned, and the stream is positioned at the end.
+ Compare this with #upTo: which positions behind anObject"
+
+ |answerStream element|
+
+ answerStream := WriteStream on:(self contentsSpecies new).
+ [self atEnd] whileFalse:[
+ element := self peek.
+ (element = anObject) ifTrue: [
+ ^ answerStream contents
+ ].
+ answerStream nextPut:element.
+ self next.
+ ].
+ ^ answerStream contents
+
+ "
+ |s|
+ s := ReadStream on:#(1 2 3 4 5 6 7 8).
+ Transcript showCR:(s nextUpTo:4).
+ Transcript showCR:s next
+
+ |s|
+ s := ReadStream on:#(1 2 3 4 5 6 7 8).
+ Transcript showCR:(s upTo:4).
+ Transcript showCR:s next
+
+ |s|
+ s := ReadStream on:#(1 2 3 4 5 6 7 8).
+ Transcript showCR:(s nextUpTo:9).
+ Transcript showCR:s next
+
+ |s|
+ s := ReadStream on:#(1 2 3 4 5 6 7 8).
+ Transcript showCR:(s upTo:9).
+ Transcript showCR:s next
+ "
+
+ "Created: 24.1.1997 / 14:08:35 / cg"
+ "Modified: 24.1.1997 / 14:09:49 / cg"
+!
+
skip:count
"skip count objects, return the receiver"
@@ -1574,6 +1621,6 @@
!Stream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.53 1997-01-11 18:11:04 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.54 1997-01-24 13:10:21 cg Exp $'
! !
Stream initialize!