diff -r fefb47dc71f6 -r cab81d17f2d9 ReadStream.st --- a/ReadStream.st Mon Jul 11 09:18:21 2016 +0100 +++ b/ReadStream.st Mon Jul 11 09:20:09 2016 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - " COPYRIGHT (c) 1988 by Claus Gittinger All Rights Reserved @@ -99,6 +97,7 @@ "Modified: / 12-09-2010 / 13:06:09 / Jan Vrany " ! ! + !ReadStream methodsFor:'converting'! readStream @@ -561,23 +560,18 @@ - tuned for speed on String-Streams for faster scanning" %{ /* NOCONTEXT */ - OBJ coll, l, p; - - coll = __INST(collection); - p = __INST(position); - l = __INST(readLimit); + OBJ coll = __INST(collection); + OBJ p = __INST(position); + OBJ l = __INST(readLimit); if (__isStringLike(coll) && __bothSmallInteger(p, l)) { - REGISTER INT pos; - unsigned ch; + REGISTER INT pos = __intVal(p) + 1; - pos = __intVal(p); - pos++; - if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) { - ch = __stringVal(coll)[pos]; - __INST(position) = __mkSmallInteger(pos); - RETURN ( __MKCHARACTER(ch) ); - } + if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) { + unsigned int ch = __stringVal(coll)[pos]; + __INST(position) = __mkSmallInteger(pos); + RETURN ( __MKCHARACTER(ch) ); + } } %}. (position >= readLimit) ifTrue:[^ self pastEndRead]. @@ -586,6 +580,32 @@ ^ collection at:(position + 1) ! +nextPeekOrNil + "advance read pointer return the peek element. + this is equivalent to (self next; peekOrNil). + - tuned for speed on String-Streams for faster scanning" + +%{ /* NOCONTEXT */ + OBJ coll = __INST(collection); + OBJ p = __INST(position); + OBJ l = __INST(readLimit); + + if (__isStringLike(coll) && __bothSmallInteger(p, l)) { + REGISTER INT pos = __intVal(p) + 1; + + if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) { + unsigned int ch = __stringVal(coll)[pos]; + __INST(position) = __mkSmallInteger(pos); + RETURN ( __MKCHARACTER(ch) ); + } + } +%}. + (position >= readLimit) ifTrue:[^ nil]. + position := position + 1. + (position >= readLimit) ifTrue:[^ nil]. + ^ collection at:(position + 1) +! + nextUnicode16CharacterMSB:msb ^ Character value:(self nextUnsignedInt16MSB:msb)