--- a/PositionableStream.st Wed Oct 26 23:35:39 2016 +0100
+++ b/PositionableStream.st Fri Nov 18 20:48:04 2016 +0000
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -852,6 +850,53 @@
"
!
+nextLine
+ "return the characters upTo (but excluding) the next cr (carriage return)
+ character (i.e. read a single line of text).
+ If the previous-to-last character is a cr, this is also removed,
+ so it's possible to read alien (i.e. ms-dos) text as well.
+ Added for protocol compatibility with externalStreams."
+
+ |start "{ Class:SmallInteger }"
+ end "{ Class:SmallInteger }"|
+
+ collection isString ifTrue:[
+ position == readLimit ifTrue:[
+ ^ self pastEndRead
+ ].
+ start := position+1.
+ end := collection indexOf:Character cr startingAt:start.
+
+ (end == 0 or:[end > readLimit]) ifTrue:[
+ end := position := readLimit.
+ ] ifFalse:[
+ position := end.
+ end := end - 1. "skip lf"
+ ].
+ start > end ifTrue:[
+ ^ ''.
+ ].
+ (collection at:end) == Character return ifTrue:[
+ end := end - 1. "skip return"
+ ].
+ ^ collection copyFrom:start to:end.
+ ].
+ ^ super nextLine.
+
+ "
+ '12345678' readStream nextLine
+ '12345678' allBold readStream nextLine
+ '12\34\56\78' withCRs readStream nextLine
+ '12\34\56\78' withCRs readStream nextLine; nextLine
+ (ReadStream on:('12\34\56\78' withCRs) from:1 to:4) nextLine; nextLine
+ ('12\' withCRs, Character return, '34') readStream nextLine; nextLine
+ Character cr asString readStream nextLine
+ Character return asString readStream nextLine
+ (Character return, Character cr) asString readStream nextLine
+ Character return asString readStream nextLine; nextLine
+ "
+!
+
upToAll:aCollection
"read until a subcollection consisisting of the elements in aCollection is encountered.
Return everything read excluding the elements in aCollection.