Redefine #skipThroughAll: to not use #position.
--- a/NPExtStr.st Fri Jan 16 00:29:30 1998 +0100
+++ b/NPExtStr.st Fri Jan 16 00:30:40 1998 +0100
@@ -139,6 +139,57 @@
^ self error:'stream is not positionable'
].
numberToSkip timesRepeat:self next
+!
+
+skipThroughAll:aCollection
+ "skip for and through the sequence given by the argument, aCollection;
+ return nil if not found, the receiver otherwise.
+ On a successful match, the next read will return elements after aCollection;
+ if no match was found, the receiver will be positioned at the end.
+ Redefined to be the same as Stream>>#skipThroughAll, to undo
+ the redefinition from PositionableStream"
+
+ |buffer l first idx|
+
+ l := aCollection size.
+ first := aCollection at:1.
+ [self atEnd] whileFalse:[
+ buffer isNil ifTrue:[
+ buffer := self nextAvailable:l.
+ ].
+ buffer = aCollection ifTrue:[
+ ^ self
+ ].
+ idx := buffer indexOf:first startingAt:2.
+ idx == 0 ifTrue:[
+ buffer := nil
+ ] ifFalse:[
+ buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1))
+ ]
+ ].
+ ^ nil
+
+ "
+ |s|
+ s := ReadStream on:'12345678901234567890'.
+ s skipThroughAll:'901'.
+ s upToEnd
+ "
+ "
+ |s|
+ s := ReadStream on:'12345678901234567890'.
+ s skipThroughAll:'1234'.
+ s upToEnd
+ "
+ "
+ |s|
+ s := ReadStream on:'12345678901234567890'.
+ s skipThroughAll:'999'.
+ s atEnd
+ "
+
+ "Modified: / 11.1.1997 / 19:09:06 / cg"
+ "Created: / 15.1.1998 / 23:33:37 / stefan"
! !
!NonPositionableExternalStream methodsFor:'printing & storing'!
@@ -256,5 +307,5 @@
!NonPositionableExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/NPExtStr.st,v 1.30 1997-09-22 19:04:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/NPExtStr.st,v 1.31 1998-01-15 23:30:40 stefan Exp $'
! !
--- a/NonPositionableExternalStream.st Fri Jan 16 00:29:30 1998 +0100
+++ b/NonPositionableExternalStream.st Fri Jan 16 00:30:40 1998 +0100
@@ -139,6 +139,57 @@
^ self error:'stream is not positionable'
].
numberToSkip timesRepeat:self next
+!
+
+skipThroughAll:aCollection
+ "skip for and through the sequence given by the argument, aCollection;
+ return nil if not found, the receiver otherwise.
+ On a successful match, the next read will return elements after aCollection;
+ if no match was found, the receiver will be positioned at the end.
+ Redefined to be the same as Stream>>#skipThroughAll, to undo
+ the redefinition from PositionableStream"
+
+ |buffer l first idx|
+
+ l := aCollection size.
+ first := aCollection at:1.
+ [self atEnd] whileFalse:[
+ buffer isNil ifTrue:[
+ buffer := self nextAvailable:l.
+ ].
+ buffer = aCollection ifTrue:[
+ ^ self
+ ].
+ idx := buffer indexOf:first startingAt:2.
+ idx == 0 ifTrue:[
+ buffer := nil
+ ] ifFalse:[
+ buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1))
+ ]
+ ].
+ ^ nil
+
+ "
+ |s|
+ s := ReadStream on:'12345678901234567890'.
+ s skipThroughAll:'901'.
+ s upToEnd
+ "
+ "
+ |s|
+ s := ReadStream on:'12345678901234567890'.
+ s skipThroughAll:'1234'.
+ s upToEnd
+ "
+ "
+ |s|
+ s := ReadStream on:'12345678901234567890'.
+ s skipThroughAll:'999'.
+ s atEnd
+ "
+
+ "Modified: / 11.1.1997 / 19:09:06 / cg"
+ "Created: / 15.1.1998 / 23:33:37 / stefan"
! !
!NonPositionableExternalStream methodsFor:'printing & storing'!
@@ -256,5 +307,5 @@
!NonPositionableExternalStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.30 1997-09-22 19:04:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.31 1998-01-15 23:30:40 stefan Exp $'
! !