packaging
authormkobetic
Sun, 15 Jan 2012 22:51:56 +0000
changeset 54 f904d4a57005
parent 53 3a3d798e73b5
child 55 e44717ae3e6c
packaging
substreams/Xtreams__LimitReadSubstream.st
substreams/Xtreams__LimitWriteSubstream.st
substreams/Xtreams__MatchReadSubstream.st
substreams/Xtreams__MatchWriteSubstream.st
substreams/Xtreams__PositionReadSubstream.st
substreams/Xtreams__PositionWriteSubstream.st
substreams/Xtreams__ReadSubstream.st
substreams/Xtreams__StitchReadStream.st
substreams/Xtreams__StitchWriteStream.st
substreams/Xtreams__TestReadSubstream.st
substreams/Xtreams__TestWriteSubstream.st
substreams/Xtreams__WriteSubstream.st
substreams/Xtreams__stx_goodies_xtreams_substreams.st
substreams/extensions.sav
substreams/stx_goodies_xtreams_substreams.st
substreams/tests/Xtreams__StitchingTest.st
substreams/tests/Xtreams__stx_goodies_xtreams_substreams_tests.st
substreams/tests/stx_goodies_xtreams_substreams_tests.st
--- a/substreams/Xtreams__LimitReadSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__LimitReadSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__LimitWriteSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__LimitWriteSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__MatchReadSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__MatchReadSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__MatchWriteSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__MatchWriteSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__PositionReadSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__PositionReadSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__PositionWriteSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__PositionWriteSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__ReadSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__ReadSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__StitchReadStream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__StitchReadStream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__StitchWriteStream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__StitchWriteStream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__TestReadSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__TestReadSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__TestWriteSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__TestWriteSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__WriteSubstream.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/Xtreams__WriteSubstream.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams' }"
 
--- a/substreams/Xtreams__stx_goodies_xtreams_substreams.st	Sun Jan 15 22:51:20 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:32:52 PM'                  !
-
-"{ Package: 'stx:goodies/xtreams/substreams' }"
-
-"{ NameSpace: Xtreams }"
-
-LibraryDefinition subclass:#stx_goodies_xtreams_substreams
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	category:'* Projects & Packages *'
-!
-
-!stx_goodies_xtreams_substreams class methodsFor:'documentation'!
-
-extensionsVersion_SVN
-    ^ '$Id: extensions.st 14 2011-11-21 06:01:55Z mkobetic $'
-! !
-
-!stx_goodies_xtreams_substreams class methodsFor:'description'!
-
-excludedFromPreRequisites
-    "list all packages which should be ignored in the automatic
-     preRequisites scan. See #preRequisites for more."
-
-    ^ #(
-    )
-!
-
-preRequisites
-    "list all required packages.
-     This list can be maintained manually or (better) generated and
-     updated by scanning the superclass hierarchies and looking for
-     global variable accesses. (the browser has a menu function for that)
-     Howevery, often too much is found, and you may want to explicitely
-     exclude individual packages in the #excludedFromPrerequisites method."
-
-    ^ #(
-        #'stx:goodies/xtreams/core'    "Xtreams::WriteStream - superclass of Xtreams::MatchWriteSubstream "
-        #'stx:libbasic'    "Object - superclass of Xtreams::MatchWriteSubstream "
-    )
-! !
-
-!stx_goodies_xtreams_substreams class methodsFor:'description - contents'!
-
-classNamesAndAttributes
-    "lists the classes which are to be included in the project.
-     Each entry in the list may be: a single class-name (symbol),
-     or an array-literal consisting of class name and attributes.
-     Attributes are: #autoload or #<os> where os is one of win32, unix,..."
-
-    ^ #(
-        "<className> or (<className> attributes...) in load order"
-        #'Xtreams::ReadSubstream'
-        #'Xtreams::StitchReadStream'
-        #'Xtreams::StitchWriteStream'
-        #'Xtreams::WriteSubstream'
-        #'Xtreams::stx_goodies_xtreams_substreams'
-        #'Xtreams::MatchReadSubstream'
-        #'Xtreams::MatchWriteSubstream'
-        #'Xtreams::PositionReadSubstream'
-        #'Xtreams::PositionWriteSubstream'
-        #'Xtreams::TestReadSubstream'
-        #'Xtreams::TestWriteSubstream'
-        #'Xtreams::LimitReadSubstream'
-        #'Xtreams::LimitWriteSubstream'
-    )
-!
-
-extensionMethodNames
-    "lists the extension methods which are to be included in the project.
-     Entries are 2-element array literals, consisting of class-name and selector."
-
-    ^ #(
-        Block streamingReadMatching:inclusive:
-        Block streamingWriteMatching:inclusive:
-        Object streamingReadMatching:inclusive:
-        Object streamingWriteMatching:inclusive:
-        SequenceableCollection streamingMatchPrefixFunction
-        SequenceableCollection streamingReadMatching:inclusive:
-        SequenceableCollection streamingWriteMatching:inclusive:
-        #'Xtreams::ReadStream' #','
-        #'Xtreams::ReadStream' closing:
-        #'Xtreams::ReadStream' ending:
-        #'Xtreams::ReadStream' ending:inclusive:
-        #'Xtreams::ReadStream' limiting:
-        #'Xtreams::ReadStream' slicing
-        #'Xtreams::ReadStream' stitching
-        #'Xtreams::WriteStream' closing:
-        #'Xtreams::WriteStream' ending:
-        #'Xtreams::WriteStream' ending:inclusive:
-        #'Xtreams::WriteStream' limiting:
-        #'Xtreams::WriteStream' slicing
-        #'Xtreams::WriteStream' stitching
-    )
-! !
-
-!stx_goodies_xtreams_substreams class methodsFor:'description - project information'!
-
-applicationIconFileName
-    "Return the name (without suffix) of an icon-file (the app's icon); will be included in the rc-resource file"
-
-    ^ nil
-    "/ ^ self applicationName
-!
-
-companyName
-    "Return a companyname which will appear in <lib>.rc"
-
-    ^ 'eXept Software AG'
-!
-
-description
-    "Return a description string which will appear in vc.def / bc.def"
-
-    ^ 'Smalltalk/X Class library'
-!
-
-legalCopyright
-    "Return a copyright string which will appear in <lib>.rc"
-
-    ^ 'Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011'
-!
-
-productName
-    "Return a product name which will appear in <lib>.rc"
-
-    ^ 'Smalltalk/X'
-! !
-
-!stx_goodies_xtreams_substreams class methodsFor:'description - svn'!
-
-svnRepositoryUrlString
-    "Return a SVN repository URL of myself.
-     (Generated since 2011-04-08)
-    "        
-
-    ^ '$URL: https://swing.fit.cvut.cz/svn/stx/goodies/xtreams/trunk/substreams/stx_goodies_xtreams_substreams.st $'
-!
-
-svnRevisionNr
-    "Return a SVN revision number of myself.
-     This number is updated after a commit"
-
-    ^ "$SVN-Revision:"'23'"$"
-! !
-
-!stx_goodies_xtreams_substreams class methodsFor:'documentation'!
-
-version_SVN
-    ^ '$Id: stx_goodies_xtreams_substreams.st 14 2011-11-21 06:01:55Z mkobetic $'
-! !
--- a/substreams/extensions.sav	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/extensions.sav	Sun Jan 15 22:51:56 2012 +0000
@@ -1,6 +1,190 @@
 "{ Encoding: utf8 }" !
 "{ Package: 'stx:goodies/xtreams/substreams' }" !
 
+!Block methodsFor:'private'!
+
+streamingReadMatching: aStream inclusive: tail
+	^TestReadSubstream on: aStream test: self inclusive: tail
+! !
+
+!Block methodsFor:'private'!
+
+streamingWriteMatching: aStream inclusive: tail
+	^TestWriteSubstream on: aStream test: self inclusive: tail
+! !
+
+!SequenceableCollection methodsFor:'private'!
+
+streamingMatchPrefixFunction
+	"Compute the array that tells us how far we need to back up when a match fails. This is using the Knuth-Morris-Pratt matching algorithm"
+
+	| backtrack partialMatch |
+	backtrack := Array new: self size + 1. 
+	backtrack at: 1 put: 1; at: 2 put: 1.
+	partialMatch := 1.
+
+	2 to: self size do: [:index |
+		| current |
+		current := self at: index.
+
+		"If there's a mismatch, back up to the previous partial match and see if the match can continue from there. If not, repeat until we find a match or hit the beginning"
+		[partialMatch > 1 and: [(self at: partialMatch) ~= current]]
+			whileTrue: [partialMatch := backtrack at: partialMatch - 1].
+
+		(self at: partialMatch) = current
+			ifTrue: [partialMatch := partialMatch + 1].
+		backtrack at: index put: partialMatch].
+
+	^backtrack
+! !
+
+!SequenceableCollection methodsFor:'private'!
+
+streamingReadMatching: aStream inclusive: tail
+	"Return a stream that produces substreams that separate by @pattern and include the pattern in the result if @tail is true.
+	 It uses the Knuth-Morris-Pratt algorithm, from Cormen et al.'s Algorithms, page 871. See also Gusfield's Alorithms on Strings, Trees and Sequences, page 23. This algorithm has the advantage in stream matching that it reads every character in the the text to be matched against exactly once, and never backtracks."
+
+	| backtrack |
+	backtrack := self streamingMatchPrefixFunction.
+	^MatchReadSubstream on: aStream pattern: self backtrack: backtrack inclusive: tail
+! !
+
+!SequenceableCollection methodsFor:'private'!
+
+streamingWriteMatching: aStream inclusive: tail
+	"Return a stream that produces substreams that separate by @pattern and include the pattern in the result if @tail is true.
+	 It uses the Knuth-Morris-Pratt algorithm, from Cormen et al.'s Algorithms, page 871. See also Gusfield's Alorithms on Strings, Trees and Sequences, page 23. This algorithm has the advantage in stream matching that it reads every character in the the text to be matched against exactly once, and never backtracks."
+
+	| backtrack |
+	backtrack := self streamingMatchPrefixFunction.
+	^MatchWriteSubstream on: aStream pattern: self backtrack: backtrack inclusive: tail
+! !
+
+!Xtreams::WriteStream methodsFor:'substreaming'!
+
+closing: aBlock
+	^(PositionWriteSubstream on: self)
+		closeBlock: aBlock;
+		yourself
+! !
+
+!Xtreams::WriteStream methodsFor:'substreaming'!
+
+ending: aMatchable
+	"Creates a substream that will end when aMatchable finds a match in the content passing through. aMatchable is either
+		* a block that is evaluated with each element - the stream ends when the block returns true
+		* a collection that is matched against the last elements written - the stream ends when the collection matches
+		* any other object - the stream ends when an equal object is written into the stream"
+	"	aMatchable	<BlockClosure | Collection | Object> the substream ending criteria
+		^<TransformWriteStream>
+	""	
+		| stream slice |
+		stream := String new writing.
+		slice := stream ending: $j.
+		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
+		stream conclusion
+	""
+		| stream slice |
+		stream := String new writing.
+		slice := stream ending: 'mno'.
+		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
+		stream conclusion
+	""
+		| stream slice |
+		stream := String new writing.
+		slice := stream ending: [ :e | 'gmt' includes: e ].
+		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
+		stream conclusion
+	"
+	^self ending: aMatchable inclusive: false
+! !
+
+!Xtreams::WriteStream methodsFor:'substreaming'!
+
+ending: aMatchable inclusive: inclusive
+	"Creates a substream that will end when aMatchable finds a match in the content passing through. aMatchable is either
+		* a block that is evaluated with each element - the stream ends when the block returns true
+		* a collection that is matched against the last elements written - the stream ends when the collection matches
+		* any other object - the stream ends when an equal object is written into the stream"
+	"	aMatchable	<BlockClosure | Collection | Object> the substream ending criteria
+		inclusive <Boolean> should the matched elements be included in the stream contents or not
+		^<TransformWriteStream>
+	""
+		| stream slice |
+		stream := String new writing.
+		slice := stream ending: $j inclusive: true.
+		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
+		stream conclusion
+	""
+		| stream slice |
+		stream := String new writing.
+		slice := stream ending: 'mno' inclusive: true.
+		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
+		stream conclusion
+	""
+		| stream slice |
+		stream := String new writing.
+		slice := stream ending: [ :e | 'gmt' includes: e ] inclusive: true.
+		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
+		stream conclusion
+	"
+	^aMatchable streamingWriteMatching: self inclusive: inclusive
+! !
+
+!Xtreams::WriteStream methodsFor:'substreaming'!
+
+limiting: limit
+	"Create a substream that will allow at most @limit number of elements written into the destination."
+	"	limit	<Integer>	maximum number of elements that can be written into destination
+		^<LimitWriteStream>"
+	"
+		| stream slice |
+		stream := String new writing.
+		slice := stream limiting: 5.
+		[ slice write: 'abcdefghi' ] on: Incomplete do: [].
+		stream conclusion
+	"
+
+	^LimitWriteSubstream on: self limit: limit
+! !
+
+!Xtreams::WriteStream methodsFor:'substreaming'!
+
+slicing
+	"From a writable stream, return a readable stream that acts as a prototype factory for the writable stream."
+	"	^<ReadStream>"
+	"(destination limiting: 10) slicing"
+
+	| substream |
+	substream := nil.
+	^[substream == nil ifFalse:
+		[substream substreamClosed ifFalse: [substream close].
+		substream subseekend.
+		substream destinationAtEnd ifTrue: [Incomplete zero raise]].
+		substream := self copy]
+		reading
+			closeBlock: [destination close];
+			yourself
+! !
+
+!Xtreams::WriteStream methodsFor:'substreaming'!
+
+stitching
+	^self error: 'You can only stitch a read stream, however that read stream can return write streams and in so doing, you will create a stitching write stream.'
+! !
+
+!Object methodsFor:'private'!
+
+streamingReadMatching: aStream inclusive: tail
+	^[:each | each == self] streamingReadMatching: aStream inclusive: tail
+! !
+
+!Object methodsFor:'private'!
+
+streamingWriteMatching: aStream inclusive: tail
+	^[:each | each == self] streamingWriteMatching: aStream inclusive: tail
+! !
+
 !Xtreams::ReadStream methodsFor:'substreaming'!
 
 , aReadStream
@@ -115,187 +299,3 @@
 	^self error: 'Cannot read or write to this stream, what is it?'
 ! !
 
-!Xtreams::WriteStream methodsFor:'substreaming'!
-
-closing: aBlock
-	^(PositionWriteSubstream on: self)
-		closeBlock: aBlock;
-		yourself
-! !
-
-!Xtreams::WriteStream methodsFor:'substreaming'!
-
-ending: aMatchable
-	"Creates a substream that will end when aMatchable finds a match in the content passing through. aMatchable is either
-		* a block that is evaluated with each element - the stream ends when the block returns true
-		* a collection that is matched against the last elements written - the stream ends when the collection matches
-		* any other object - the stream ends when an equal object is written into the stream"
-	"	aMatchable	<BlockClosure | Collection | Object> the substream ending criteria
-		^<TransformWriteStream>
-	""	
-		| stream slice |
-		stream := String new writing.
-		slice := stream ending: $j.
-		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
-		stream conclusion
-	""
-		| stream slice |
-		stream := String new writing.
-		slice := stream ending: 'mno'.
-		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
-		stream conclusion
-	""
-		| stream slice |
-		stream := String new writing.
-		slice := stream ending: [ :e | 'gmt' includes: e ].
-		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
-		stream conclusion
-	"
-	^self ending: aMatchable inclusive: false
-! !
-
-!Xtreams::WriteStream methodsFor:'substreaming'!
-
-ending: aMatchable inclusive: inclusive
-	"Creates a substream that will end when aMatchable finds a match in the content passing through. aMatchable is either
-		* a block that is evaluated with each element - the stream ends when the block returns true
-		* a collection that is matched against the last elements written - the stream ends when the collection matches
-		* any other object - the stream ends when an equal object is written into the stream"
-	"	aMatchable	<BlockClosure | Collection | Object> the substream ending criteria
-		inclusive <Boolean> should the matched elements be included in the stream contents or not
-		^<TransformWriteStream>
-	""
-		| stream slice |
-		stream := String new writing.
-		slice := stream ending: $j inclusive: true.
-		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
-		stream conclusion
-	""
-		| stream slice |
-		stream := String new writing.
-		slice := stream ending: 'mno' inclusive: true.
-		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
-		stream conclusion
-	""
-		| stream slice |
-		stream := String new writing.
-		slice := stream ending: [ :e | 'gmt' includes: e ] inclusive: true.
-		[ slice write: 'abcdefghijklmnopqrstuvxyz' ] on: Incomplete do: [].
-		stream conclusion
-	"
-	^aMatchable streamingWriteMatching: self inclusive: inclusive
-! !
-
-!Xtreams::WriteStream methodsFor:'substreaming'!
-
-limiting: limit
-	"Create a substream that will allow at most @limit number of elements written into the destination."
-	"	limit	<Integer>	maximum number of elements that can be written into destination
-		^<LimitWriteStream>"
-	"
-		| stream slice |
-		stream := String new writing.
-		slice := stream limiting: 5.
-		[ slice write: 'abcdefghi' ] on: Incomplete do: [].
-		stream conclusion
-	"
-
-	^LimitWriteSubstream on: self limit: limit
-! !
-
-!Xtreams::WriteStream methodsFor:'substreaming'!
-
-slicing
-	"From a writable stream, return a readable stream that acts as a prototype factory for the writable stream."
-	"	^<ReadStream>"
-	"(destination limiting: 10) slicing"
-
-	| substream |
-	substream := nil.
-	^[substream == nil ifFalse:
-		[substream substreamClosed ifFalse: [substream close].
-		substream subseekend.
-		substream destinationAtEnd ifTrue: [Incomplete zero raise]].
-		substream := self copy]
-		reading
-			closeBlock: [destination close];
-			yourself
-! !
-
-!Xtreams::WriteStream methodsFor:'substreaming'!
-
-stitching
-	^self error: 'You can only stitch a read stream, however that read stream can return write streams and in so doing, you will create a stitching write stream.'
-! !
-
-!Block methodsFor:'private'!
-
-streamingReadMatching: aStream inclusive: tail
-	^TestReadSubstream on: aStream test: self inclusive: tail
-! !
-
-!Block methodsFor:'private'!
-
-streamingWriteMatching: aStream inclusive: tail
-	^TestWriteSubstream on: aStream test: self inclusive: tail
-! !
-
-!SequenceableCollection methodsFor:'private'!
-
-streamingMatchPrefixFunction
-	"Compute the array that tells us how far we need to back up when a match fails. This is using the Knuth-Morris-Pratt matching algorithm"
-
-	| backtrack partialMatch |
-	backtrack := Array new: self size + 1. 
-	backtrack at: 1 put: 1; at: 2 put: 1.
-	partialMatch := 1.
-
-	2 to: self size do: [:index |
-		| current |
-		current := self at: index.
-
-		"If there's a mismatch, back up to the previous partial match and see if the match can continue from there. If not, repeat until we find a match or hit the beginning"
-		[partialMatch > 1 and: [(self at: partialMatch) ~= current]]
-			whileTrue: [partialMatch := backtrack at: partialMatch - 1].
-
-		(self at: partialMatch) = current
-			ifTrue: [partialMatch := partialMatch + 1].
-		backtrack at: index put: partialMatch].
-
-	^backtrack
-! !
-
-!SequenceableCollection methodsFor:'private'!
-
-streamingReadMatching: aStream inclusive: tail
-	"Return a stream that produces substreams that separate by @pattern and include the pattern in the result if @tail is true.
-	 It uses the Knuth-Morris-Pratt algorithm, from Cormen et al.'s Algorithms, page 871. See also Gusfield's Alorithms on Strings, Trees and Sequences, page 23. This algorithm has the advantage in stream matching that it reads every character in the the text to be matched against exactly once, and never backtracks."
-
-	| backtrack |
-	backtrack := self streamingMatchPrefixFunction.
-	^MatchReadSubstream on: aStream pattern: self backtrack: backtrack inclusive: tail
-! !
-
-!SequenceableCollection methodsFor:'private'!
-
-streamingWriteMatching: aStream inclusive: tail
-	"Return a stream that produces substreams that separate by @pattern and include the pattern in the result if @tail is true.
-	 It uses the Knuth-Morris-Pratt algorithm, from Cormen et al.'s Algorithms, page 871. See also Gusfield's Alorithms on Strings, Trees and Sequences, page 23. This algorithm has the advantage in stream matching that it reads every character in the the text to be matched against exactly once, and never backtracks."
-
-	| backtrack |
-	backtrack := self streamingMatchPrefixFunction.
-	^MatchWriteSubstream on: aStream pattern: self backtrack: backtrack inclusive: tail
-! !
-
-!Object methodsFor:'private'!
-
-streamingReadMatching: aStream inclusive: tail
-	^[:each | each == self] streamingReadMatching: aStream inclusive: tail
-! !
-
-!Object methodsFor:'private'!
-
-streamingWriteMatching: aStream inclusive: tail
-	^[:each | each == self] streamingWriteMatching: aStream inclusive: tail
-! !
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/substreams/stx_goodies_xtreams_substreams.st	Sun Jan 15 22:51:56 2012 +0000
@@ -0,0 +1,150 @@
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:21 PM'                  !
+
+"{ Package: 'stx:goodies/xtreams/substreams' }"
+
+LibraryDefinition subclass:#stx_goodies_xtreams_substreams
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'* Projects & Packages *'
+!
+
+!stx_goodies_xtreams_substreams class methodsFor:'documentation'!
+
+extensionsVersion_SVN
+    ^ '$Id: extensions.st 14 2011-11-21 06:01:55Z mkobetic $'
+! !
+
+!stx_goodies_xtreams_substreams class methodsFor:'description'!
+
+excludedFromPreRequisites
+    "list all packages which should be ignored in the automatic
+     preRequisites scan. See #preRequisites for more."
+
+    ^ #(
+    )
+!
+
+preRequisites
+    "list all required packages.
+     This list can be maintained manually or (better) generated and
+     updated by scanning the superclass hierarchies and looking for
+     global variable accesses. (the browser has a menu function for that)
+     Howevery, often too much is found, and you may want to explicitely
+     exclude individual packages in the #excludedFromPrerequisites method."
+
+    ^ #(
+        #'stx:goodies/xtreams/core'    "Xtreams::WriteStream - superclass of Xtreams::MatchWriteSubstream "
+        #'stx:libbasic'    "Object - superclass of Xtreams::MatchWriteSubstream "
+    )
+! !
+
+!stx_goodies_xtreams_substreams class methodsFor:'description - contents'!
+
+classNamesAndAttributes
+    "lists the classes which are to be included in the project.
+     Each entry in the list may be: a single class-name (symbol),
+     or an array-literal consisting of class name and attributes.
+     Attributes are: #autoload or #<os> where os is one of win32, unix,..."
+
+    ^ #(
+        "<className> or (<className> attributes...) in load order"
+        #'Xtreams::ReadSubstream'
+        #'Xtreams::StitchReadStream'
+        #'Xtreams::StitchWriteStream'
+        #'Xtreams::WriteSubstream'
+        #'Xtreams::stx_goodies_xtreams_substreams'
+        #'Xtreams::MatchReadSubstream'
+        #'Xtreams::MatchWriteSubstream'
+        #'Xtreams::PositionReadSubstream'
+        #'Xtreams::PositionWriteSubstream'
+        #'Xtreams::TestReadSubstream'
+        #'Xtreams::TestWriteSubstream'
+        #'Xtreams::LimitReadSubstream'
+        #'Xtreams::LimitWriteSubstream'
+    )
+!
+
+extensionMethodNames
+    "lists the extension methods which are to be included in the project.
+     Entries are 2-element array literals, consisting of class-name and selector."
+
+    ^ #(
+        Block streamingReadMatching:inclusive:
+        Block streamingWriteMatching:inclusive:
+        Object streamingReadMatching:inclusive:
+        Object streamingWriteMatching:inclusive:
+        SequenceableCollection streamingMatchPrefixFunction
+        SequenceableCollection streamingReadMatching:inclusive:
+        SequenceableCollection streamingWriteMatching:inclusive:
+        #'Xtreams::ReadStream' #','
+        #'Xtreams::ReadStream' closing:
+        #'Xtreams::ReadStream' ending:
+        #'Xtreams::ReadStream' ending:inclusive:
+        #'Xtreams::ReadStream' limiting:
+        #'Xtreams::ReadStream' slicing
+        #'Xtreams::ReadStream' stitching
+        #'Xtreams::WriteStream' closing:
+        #'Xtreams::WriteStream' ending:
+        #'Xtreams::WriteStream' ending:inclusive:
+        #'Xtreams::WriteStream' limiting:
+        #'Xtreams::WriteStream' slicing
+        #'Xtreams::WriteStream' stitching
+    )
+! !
+
+!stx_goodies_xtreams_substreams class methodsFor:'description - project information'!
+
+applicationIconFileName
+    "Return the name (without suffix) of an icon-file (the app's icon); will be included in the rc-resource file"
+
+    ^ nil
+    "/ ^ self applicationName
+!
+
+companyName
+    "Return a companyname which will appear in <lib>.rc"
+
+    ^ 'eXept Software AG'
+!
+
+description
+    "Return a description string which will appear in vc.def / bc.def"
+
+    ^ 'Smalltalk/X Class library'
+!
+
+legalCopyright
+    "Return a copyright string which will appear in <lib>.rc"
+
+    ^ 'Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011'
+!
+
+productName
+    "Return a product name which will appear in <lib>.rc"
+
+    ^ 'Smalltalk/X'
+! !
+
+!stx_goodies_xtreams_substreams class methodsFor:'description - svn'!
+
+svnRepositoryUrlString
+    "Return a SVN repository URL of myself.
+     (Generated since 2011-04-08)
+    "        
+
+    ^ '$URL: https://swing.fit.cvut.cz/svn/stx/goodies/xtreams/trunk/substreams/stx_goodies_xtreams_substreams.st $'
+!
+
+svnRevisionNr
+    "Return a SVN revision number of myself.
+     This number is updated after a commit"
+
+    ^ "$SVN-Revision:"'23'"$"
+! !
+
+!stx_goodies_xtreams_substreams class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: stx_goodies_xtreams_substreams.st 14 2011-11-21 06:01:55Z mkobetic $'
+! !
--- a/substreams/tests/Xtreams__StitchingTest.st	Sun Jan 15 22:51:20 2012 +0000
+++ b/substreams/tests/Xtreams__StitchingTest.st	Sun Jan 15 22:51:56 2012 +0000
@@ -1,4 +1,4 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:33:53 PM'                  !
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:54 PM'                  !
 
 "{ Package: 'stx:goodies/xtreams/substreams/tests' }"
 
--- a/substreams/tests/Xtreams__stx_goodies_xtreams_substreams_tests.st	Sun Jan 15 22:51:20 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:33:53 PM'                  !
-
-"{ Package: 'stx:goodies/xtreams/substreams/tests' }"
-
-"{ NameSpace: Xtreams }"
-
-LibraryDefinition subclass:#stx_goodies_xtreams_substreams_tests
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	category:'* Projects & Packages *'
-!
-
-!stx_goodies_xtreams_substreams_tests class methodsFor:'documentation'!
-
-extensionsVersion_SVN
-    ^ '$Id: extensions.st 15 2011-11-21 06:02:13Z mkobetic $'
-! !
-
-!stx_goodies_xtreams_substreams_tests class methodsFor:'description'!
-
-excludedFromPreRequisites
-    "list all packages which should be ignored in the automatic
-     preRequisites scan. See #preRequisites for more."
-
-    ^ #(
-    )
-!
-
-preRequisites
-    "list all required packages.
-     This list can be maintained manually or (better) generated and
-     updated by scanning the superclass hierarchies and looking for
-     global variable accesses. (the browser has a menu function for that)
-     Howevery, often too much is found, and you may want to explicitely
-     exclude individual packages in the #excludedFromPrerequisites method."
-
-    ^ #(
-        #'stx:goodies/sunit'    "TestCase - superclass of Xtreams::StitchingTest "
-        #'stx:goodies/xtreams/core'    "Xtreams::RingBuffer - referenced by Xtreams::FiniteReadingWritingTests>>testWriteStitchingChunks "
-        #'stx:goodies/xtreams/core/tests'    "Xtreams::ReadingWritingTest - superclass of extended Xtreams::FiniteReadingWritingTests "
-        #'stx:goodies/xtreams/substreams'
-        #'stx:libbasic'    "ProjectDefinition - superclass of stx_goodies_xtreams_substreams_tests "
-    )
-! !
-
-!stx_goodies_xtreams_substreams_tests class methodsFor:'description - contents'!
-
-classNamesAndAttributes
-    "lists the classes which are to be included in the project.
-     Each entry in the list may be: a single class-name (symbol),
-     or an array-literal consisting of class name and attributes.
-     Attributes are: #autoload or #<os> where os is one of win32, unix,..."
-
-    ^ #(
-        "<className> or (<className> attributes...) in load order"
-        (#'Xtreams::StitchingTest' autoload)
-        #'stx_goodies_xtreams_substreams_tests'
-    )
-!
-
-extensionMethodNames
-    "lists the extension methods which are to be included in the project.
-     Entries are 2-element array literals, consisting of class-name and selector."
-
-    ^ #(
-        #'Xtreams::FiniteReadingWritingTests' testReadClosing
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingBlock
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingBlockPositioning
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingBlockTail
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingCollection
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingCollectionPositioning
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingCollectionTail
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingObject
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingObjectPositioning
-        #'Xtreams::FiniteReadingWritingTests' testReadEndingObjectTail
-        #'Xtreams::FiniteReadingWritingTests' testReadLimiting
-        #'Xtreams::FiniteReadingWritingTests' testReadLimitingPositioning
-        #'Xtreams::FiniteReadingWritingTests' testReadStitchLimiting
-        #'Xtreams::FiniteReadingWritingTests' testReadStitchingChunks
-        #'Xtreams::FiniteReadingWritingTests' testWriteClosing
-        #'Xtreams::FiniteReadingWritingTests' testWriteClosingPositioning
-        #'Xtreams::FiniteReadingWritingTests' testWriteEndingBlock
-        #'Xtreams::FiniteReadingWritingTests' testWriteEndingBlockTail
-        #'Xtreams::FiniteReadingWritingTests' testWriteEndingCollection
-        #'Xtreams::FiniteReadingWritingTests' testWriteEndingCollectionTail
-        #'Xtreams::FiniteReadingWritingTests' testWriteEndingObject
-        #'Xtreams::FiniteReadingWritingTests' testWriteEndingObjectTail
-        #'Xtreams::FiniteReadingWritingTests' testWriteLimiting
-        #'Xtreams::FiniteReadingWritingTests' testWriteLimitingPositioning
-        #'Xtreams::FiniteReadingWritingTests' testWriteStitchLimiting
-        #'Xtreams::FiniteReadingWritingTests' testWriteStitchingChunks
-    )
-! !
-
-!stx_goodies_xtreams_substreams_tests class methodsFor:'description - project information'!
-
-applicationIconFileName
-    "Return the name (without suffix) of an icon-file (the app's icon); will be included in the rc-resource file"
-
-    ^ nil
-    "/ ^ self applicationName
-!
-
-companyName
-    "Return a companyname which will appear in <lib>.rc"
-
-    ^ 'eXept Software AG'
-!
-
-description
-    "Return a description string which will appear in vc.def / bc.def"
-
-    ^ 'Smalltalk/X Class library'
-!
-
-legalCopyright
-    "Return a copyright string which will appear in <lib>.rc"
-
-    ^ 'Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011'
-!
-
-productName
-    "Return a product name which will appear in <lib>.rc"
-
-    ^ 'Smalltalk/X'
-! !
-
-!stx_goodies_xtreams_substreams_tests class methodsFor:'description - svn'!
-
-svnRepositoryUrlString
-    "Return a SVN repository URL of myself.
-     (Generated since 2011-04-08)
-    "        
-
-    ^ '$URL: https://swing.fit.cvut.cz/svn/stx/goodies/xtreams/trunk/substreams/tests/stx_goodies_xtreams_substreams_tests.st $'
-!
-
-svnRevisionNr
-    "Return a SVN revision number of myself.
-     This number is updated after a commit"
-
-    ^ "$SVN-Revision:"'24'"$"
-! !
-
-!stx_goodies_xtreams_substreams_tests class methodsFor:'documentation'!
-
-version_SVN
-    ^ '$Id: stx_goodies_xtreams_substreams_tests.st 15 2011-11-21 06:02:13Z mkobetic $'
-! !
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/substreams/tests/stx_goodies_xtreams_substreams_tests.st	Sun Jan 15 22:51:56 2012 +0000
@@ -0,0 +1,148 @@
+'From Smalltalk/X, Version:6.2.1 on 15-01-2012 at 05:49:54 PM'                  !
+
+"{ Package: 'stx:goodies/xtreams/substreams/tests' }"
+
+LibraryDefinition subclass:#stx_goodies_xtreams_substreams_tests
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'* Projects & Packages *'
+!
+
+!stx_goodies_xtreams_substreams_tests class methodsFor:'documentation'!
+
+extensionsVersion_SVN
+    ^ '$Id: extensions.st 15 2011-11-21 06:02:13Z mkobetic $'
+! !
+
+!stx_goodies_xtreams_substreams_tests class methodsFor:'description'!
+
+excludedFromPreRequisites
+    "list all packages which should be ignored in the automatic
+     preRequisites scan. See #preRequisites for more."
+
+    ^ #(
+    )
+!
+
+preRequisites
+    "list all required packages.
+     This list can be maintained manually or (better) generated and
+     updated by scanning the superclass hierarchies and looking for
+     global variable accesses. (the browser has a menu function for that)
+     Howevery, often too much is found, and you may want to explicitely
+     exclude individual packages in the #excludedFromPrerequisites method."
+
+    ^ #(
+        #'stx:goodies/sunit'    "TestCase - superclass of Xtreams::StitchingTest "
+        #'stx:goodies/xtreams/core'    "Xtreams::RingBuffer - referenced by Xtreams::FiniteReadingWritingTests>>testWriteStitchingChunks "
+        #'stx:goodies/xtreams/core/tests'    "Xtreams::ReadingWritingTest - superclass of extended Xtreams::FiniteReadingWritingTests "
+        #'stx:goodies/xtreams/substreams'
+        #'stx:libbasic'    "ProjectDefinition - superclass of stx_goodies_xtreams_substreams_tests "
+    )
+! !
+
+!stx_goodies_xtreams_substreams_tests class methodsFor:'description - contents'!
+
+classNamesAndAttributes
+    "lists the classes which are to be included in the project.
+     Each entry in the list may be: a single class-name (symbol),
+     or an array-literal consisting of class name and attributes.
+     Attributes are: #autoload or #<os> where os is one of win32, unix,..."
+
+    ^ #(
+        "<className> or (<className> attributes...) in load order"
+        (#'Xtreams::StitchingTest' autoload)
+        #'stx_goodies_xtreams_substreams_tests'
+    )
+!
+
+extensionMethodNames
+    "lists the extension methods which are to be included in the project.
+     Entries are 2-element array literals, consisting of class-name and selector."
+
+    ^ #(
+        #'Xtreams::FiniteReadingWritingTests' testReadClosing
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingBlock
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingBlockPositioning
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingBlockTail
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingCollection
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingCollectionPositioning
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingCollectionTail
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingObject
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingObjectPositioning
+        #'Xtreams::FiniteReadingWritingTests' testReadEndingObjectTail
+        #'Xtreams::FiniteReadingWritingTests' testReadLimiting
+        #'Xtreams::FiniteReadingWritingTests' testReadLimitingPositioning
+        #'Xtreams::FiniteReadingWritingTests' testReadStitchLimiting
+        #'Xtreams::FiniteReadingWritingTests' testReadStitchingChunks
+        #'Xtreams::FiniteReadingWritingTests' testWriteClosing
+        #'Xtreams::FiniteReadingWritingTests' testWriteClosingPositioning
+        #'Xtreams::FiniteReadingWritingTests' testWriteEndingBlock
+        #'Xtreams::FiniteReadingWritingTests' testWriteEndingBlockTail
+        #'Xtreams::FiniteReadingWritingTests' testWriteEndingCollection
+        #'Xtreams::FiniteReadingWritingTests' testWriteEndingCollectionTail
+        #'Xtreams::FiniteReadingWritingTests' testWriteEndingObject
+        #'Xtreams::FiniteReadingWritingTests' testWriteEndingObjectTail
+        #'Xtreams::FiniteReadingWritingTests' testWriteLimiting
+        #'Xtreams::FiniteReadingWritingTests' testWriteLimitingPositioning
+        #'Xtreams::FiniteReadingWritingTests' testWriteStitchLimiting
+        #'Xtreams::FiniteReadingWritingTests' testWriteStitchingChunks
+    )
+! !
+
+!stx_goodies_xtreams_substreams_tests class methodsFor:'description - project information'!
+
+applicationIconFileName
+    "Return the name (without suffix) of an icon-file (the app's icon); will be included in the rc-resource file"
+
+    ^ nil
+    "/ ^ self applicationName
+!
+
+companyName
+    "Return a companyname which will appear in <lib>.rc"
+
+    ^ 'eXept Software AG'
+!
+
+description
+    "Return a description string which will appear in vc.def / bc.def"
+
+    ^ 'Smalltalk/X Class library'
+!
+
+legalCopyright
+    "Return a copyright string which will appear in <lib>.rc"
+
+    ^ 'Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011'
+!
+
+productName
+    "Return a product name which will appear in <lib>.rc"
+
+    ^ 'Smalltalk/X'
+! !
+
+!stx_goodies_xtreams_substreams_tests class methodsFor:'description - svn'!
+
+svnRepositoryUrlString
+    "Return a SVN repository URL of myself.
+     (Generated since 2011-04-08)
+    "        
+
+    ^ '$URL: https://swing.fit.cvut.cz/svn/stx/goodies/xtreams/trunk/substreams/tests/stx_goodies_xtreams_substreams_tests.st $'
+!
+
+svnRevisionNr
+    "Return a SVN revision number of myself.
+     This number is updated after a commit"
+
+    ^ "$SVN-Revision:"'24'"$"
+! !
+
+!stx_goodies_xtreams_substreams_tests class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: stx_goodies_xtreams_substreams_tests.st 15 2011-11-21 06:02:13Z mkobetic $'
+! !