On Thu, Sep 6, 2012 at 10:44 AM, Sven Van Caekenberghe <[email protected]> wrote:
> Mariano, > > What would be wrong with something more elegant, like > > consumeWhitespace > "Strip whitespaces from the input stream." > > [ readStream atEnd not and: [ readStream peek isSeparator ] ] > whileTrue: [ > readStream next ] > > ? > > In my book #peek, which means a one-element pushback buffer, is a whole > lot less of a requirement that a general #position[:] interface which > actually assumes that all contents is in memory, a contradiction to the > concept of streaming. > Well, that seems to work also :) > > Maybe these uglier versions are more efficient, but who can say for sure > they are correct ? > > I have no idea. I would like to fix it with any of the 2 possibilities. Everything is better than being broken. So any other opinion? > ;-) > > Sven > > On 06 Sep 2012, at 10:26, Mariano Martinez Peck <[email protected]> > wrote: > > > Hi guys. I found a problem when exporting/importing chunks with > MultiByteBinaryOrTextStream and I think #skipSeparators is wrong. > > The code is: > > > > MultiByteBinaryOrTextStream >> skipSeparators > > > > [self atEnd] whileFalse: [ > > self basicNext isSeparator ifFalse: [ > > ^ self position: self position - 1]] > > > > Problem is that the position is not save, as it is done in > > > > MultiByteFileStream >> skipSeparators > > > > | state character | > > [ > > state := converter saveStateOf: self. > > (character := self next) > > ifNil: [ false ] > > ifNotNil: [ character isSeparator ] ] whileTrue. > > character ifNotNil: [ > > converter restoreStateOf: self with: state ] > > > > > > If I copy the implementation from MultiByteFileStream to > MultiByteBinaryOrTextStream, my tests work as expected. > > But I am not a stream expert. So, what do you think? is this change > correct? > > > > Thanks, > > > > -- > > Mariano > > http://marianopeck.wordpress.com > > -- > Sven Van Caekenberghe > http://stfx.eu > Smalltalk is the Red Pill > > > > > -- Mariano http://marianopeck.wordpress.com
