[squeak-dev] The Trunk: Network-eem.186.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Feb 25 18:45:40 UTC 2017


Eliot Miranda uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-eem.186.mcz

==================== Summary ====================

Name: Network-eem.186
Author: eem
Time: 25 February 2017, 10:45:26.371668 am
UUID: cfa17471-ba85-4440-8aea-d24c0a5c3697
Ancestors: Network-tfel.185

Fix slip in upToAll:limit: that causes errors in the SocketStreamTests>>testUpToAllCrlf* tests.

=============== Diff against Network-tfel.185 ===============

Item was changed:
  ----- Method: SocketStream>>upToAll:limit: (in category 'stream in') -----
  upToAll: aStringOrByteArray limit: nBytes
  	"Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of aStringOrByteArray. If aCollection is not in the stream, or not found within nBytes answer the available contents of the stream"
  
  	| index sz result searchedSoFar target |
  	"Deal with ascii vs. binary"
+ 	target := self isBinary
+ 				ifTrue:[aStringOrByteArray asByteArray]
+ 				ifFalse:[aStringOrByteArray asString].
- 	self isBinary
- 		ifTrue:[target := aStringOrByteArray asByteArray]
- 		ifFalse:[target := aStringOrByteArray asString].
  
  	sz := target size.
  	"Look in the current inBuffer first"
  	index := inBuffer indexOfSubCollection: target
+ 						startingAt: (lastRead - sz + 2 max: 1).
- 						startingAt: lastRead - sz + 2.
  	(index > 0 and: [(index + sz) <= inNextToWrite]) ifTrue: ["found it"
  		result := self nextInBuffer: index - lastRead - 1.
  		self skip: sz.
  		^ result
  	].
  
  	[searchedSoFar :=  self inBufferSize.
  	"Receive more data"
  	self receiveData.
  	recentlyRead > 0] whileTrue:[
  
  		"Data begins at lastRead + 1, we add searchedSoFar as offset and 
  		backs up sz - 1 so that we can catch any borderline hits."
  
  		index := inBuffer indexOfSubCollection: target
  						startingAt: (lastRead + searchedSoFar - sz + 2 max: 1).
  		(index > 0 and: [(index + sz) <= inNextToWrite]) ifTrue: ["found it"
  			result := self nextInBuffer: index - lastRead - 1.
  			self skip: sz.
  			^ result
  		].
  		"Check if we've exceeded the max. amount"
  		(nBytes notNil and:[inNextToWrite - lastRead > nBytes]) 
  			ifTrue:[^self nextAllInBuffer].
  	].
  
  	"not found and (non-signaling) connection was closed"
  	^self nextAllInBuffer!



More information about the Squeak-dev mailing list