ReadStream.st
branchjv
changeset 18060 3708e12e9aa8
parent 18040 a11a12546f23
parent 15262 5047292c9107
child 18066 89d51443ba6f
--- a/ReadStream.st	Tue May 21 21:58:09 2013 +0100
+++ b/ReadStream.st	Fri May 24 18:52:05 2013 +0100
@@ -36,7 +36,7 @@
 
 documentation
 "
-    ReadStream defines protocol for reading streamwise over collections. 
+    ReadStream defines protocol for reading streamwise over collections.
 
     [author:]
 	Claus Gittinger
@@ -47,7 +47,7 @@
 !ReadStream class methodsFor:'blocked instance creation'!
 
 with:aCollection
-    "with on readStream makes no sense 
+    "with on readStream makes no sense
      - what do you want to read from the end of a collection?"
     <resource:#obsolete>
 
@@ -57,20 +57,20 @@
 
 !ReadStream methodsFor:'Compatibility-Dolphin'!
 
-skipWhile:aBlock 
+skipWhile:aBlock
     "skip all elements for which aBlock returns true. Return true if more elements can be read,
      false if eof has been reached."
 
     [self atEnd] whileFalse:[
-        (aBlock value: self peek) ifFalse:[^ true].
-        self next
+	(aBlock value: self peek) ifFalse:[^ true].
+	self next
     ].
     ^ false
 
     "
      #(1 2 3 4 5 6 7 8 9 10) readStream
-        skipWhile:[:el | el <= 5];
-        next
+	skipWhile:[:el | el <= 5];
+	next
     "
 
     "Created: / 23-09-2011 / 13:32:40 / cg"
@@ -100,7 +100,7 @@
 emphasis
     "return the emphasis of the current (i.e. next returned by #next)
      element. Streams on a string will return nil for all elements.
-     Streams on collections which nothing at all about emphasises, 
+     Streams on collections which nothing at all about emphasises,
      will report an error."
 
     ^ collection emphasisAt:(position - ZeroPosition + 1).
@@ -109,13 +109,13 @@
      |t s|
 
      t := 'hello world' asText
-                emphasizeFrom:1 to:5 with:#bold;
-                emphasizeFrom:7 to:11 with:#italic.
+		emphasizeFrom:1 to:5 with:#bold;
+		emphasizeFrom:7 to:11 with:#italic.
 
      s := t readStream.
      [s atEnd] whileFalse:[
-        Transcript show:(s emphasis); show:' '.
-        Transcript show:''''; show:(s next); showCR:''''.
+	Transcript show:(s emphasis); show:' '.
+	Transcript show:''''; show:(s next); showCR:''''.
      ].
     "
 
@@ -171,42 +171,42 @@
 
     if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos > 0 && pos <= __intVal(l)) {
-            OBJ cls, ret;
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos > 0 && pos <= __intVal(l)) {
+	    OBJ cls, ret;
 
-            cls = __qClass(coll);
-            if (cls == @global(String)) {
-                if (pos <= __stringSize(coll)) {
-                    ch = __stringVal(coll)[pos-1];
-                    ret = __MKCHARACTER(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(ByteArray)) {
-                if (pos <= __byteArraySize(coll)) {
-                    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
-                    ret = __mkSmallInteger(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(Unicode16String)) {
-                if (pos <= __unicode16StringSize(coll)) {
-                    ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
-                    ret = __MKUCHARACTER(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(Array)) {
-                if (pos <= __arraySize(coll)) {
-                    ret = __ArrayInstPtr(coll)->a_element[pos-1];
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            }
-        }
+	    cls = __qClass(coll);
+	    if (cls == @global(String)) {
+		if (pos <= __stringSize(coll)) {
+		    ch = __stringVal(coll)[pos-1];
+		    ret = __MKCHARACTER(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(ByteArray)) {
+		if (pos <= __byteArraySize(coll)) {
+		    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+		    ret = __mkSmallInteger(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(Unicode16String)) {
+		if (pos <= __unicode16StringSize(coll)) {
+		    ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
+		    ret = __MKUCHARACTER(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(Array)) {
+		if (pos <= __arraySize(coll)) {
+		    ret = __ArrayInstPtr(coll)->a_element[pos-1];
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    }
+	}
     }
 %}.
     ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
@@ -222,19 +222,19 @@
     |answer|
 
     self contentsSpecies = collection class ifTrue:[
-        ((position + count - ZeroPosition) > readLimit) ifFalse:[
-            answer := collection copyFrom:position+1 to:position+count.
-            position := position+count.
-            ^ answer
-        ].
+	((position + count - ZeroPosition) > readLimit) ifFalse:[
+	    answer := collection copyFrom:position+1 to:position+count.
+	    position := position+count.
+	    ^ answer
+	].
     ].
     ^ super next:count
 
     "
      #[1 2 3 4 5 6 7 8 9] readStream
-        next;      
-        next:5;    
-        next.
+	next;
+	next:5;
+	next.
     "
 !
 
@@ -256,54 +256,54 @@
     coll = __INST(collection);
     p = __INST(position);
     l = __INST(readLimit);
-    
+
     if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
 
-        limit = __intVal(l);
-        sz = __qSize(coll) - OHDR_SIZE;
-        if (sz < limit)
-            limit = sz; 
-        cp = __stringVal(coll) + pos - 1;
+	limit = __intVal(l);
+	sz = __qSize(coll) - OHDR_SIZE;
+	if (sz < limit)
+	    limit = sz;
+	cp = __stringVal(coll) + pos - 1;
 
-        for (;;) {
-            if (pos > limit) break;
-            ch = *cp;
+	for (;;) {
+	    if (pos > limit) break;
+	    ch = *cp;
 
-            if (((ch >= 'a') && (ch <= 'z')) ||
-                ((ch >= 'A') && (ch <= 'Z')) ||
-                ((ch >= '0') && (ch <= '9')))
-                break;
-            cp++;
-            pos++;
-        }
+	    if (((ch >= 'a') && (ch <= 'z')) ||
+		((ch >= 'A') && (ch <= 'Z')) ||
+		((ch >= '0') && (ch <= '9')))
+		break;
+	    cp++;
+	    pos++;
+	}
 
-        len = 0;
-        for (;;) {
-            if (pos > limit) break;
-            ch = *cp & 0xFF;
+	len = 0;
+	for (;;) {
+	    if (pos > limit) break;
+	    ch = *cp & 0xFF;
 
-            if (! (((ch >= 'a') && (ch <= 'z')) ||
-                   ((ch >= 'A') && (ch <= 'Z')) ||
-                   ((ch >= '0') && (ch <= '9'))))
-                break;
-            buffer[len++] = ch;
-            if (len >= (sizeof(buffer)-1)) {
-                /* emergency */
-                break;
-            }
-            pos++;
-            cp++;
-        }
+	    if (! (((ch >= 'a') && (ch <= 'z')) ||
+		   ((ch >= 'A') && (ch <= 'Z')) ||
+		   ((ch >= '0') && (ch <= '9'))))
+		break;
+	    buffer[len++] = ch;
+	    if (len >= (sizeof(buffer)-1)) {
+		/* emergency */
+		break;
+	    }
+	    pos++;
+	    cp++;
+	}
 
-        /* make ZeroPosition-based */
-        pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-        __INST(position) = __mkSmallInteger(pos);
-        buffer[len] = '\0';
-        RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil );
+	/* make ZeroPosition-based */
+	pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+	__INST(position) = __mkSmallInteger(pos);
+	buffer[len] = '\0';
+	RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil );
     }
 %}
 .
@@ -329,35 +329,35 @@
 
     if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos > 0 && pos <= __intVal(l)) {
-            OBJ cls, ret;
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos > 0 && pos <= __intVal(l)) {
+	    OBJ cls, ret;
 
-            cls = __qClass(coll);
-            if (cls == @global(String)) {
-                if (pos <= __stringSize(coll)) {
-                    ch = __stringVal(coll)[pos-1];
-                    ret = __mkSmallInteger(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(ByteArray)) {
-                if (pos <= __byteArraySize(coll)) {
-                    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
-                    ret = __mkSmallInteger(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(Array)) {
-                if (pos <= __arraySize(coll)) {
-                    ret = __ArrayInstPtr(coll)->a_element[pos-1];
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            }
-        }
+	    cls = __qClass(coll);
+	    if (cls == @global(String)) {
+		if (pos <= __stringSize(coll)) {
+		    ch = __stringVal(coll)[pos-1];
+		    ret = __mkSmallInteger(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(ByteArray)) {
+		if (pos <= __byteArraySize(coll)) {
+		    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+		    ret = __mkSmallInteger(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(Array)) {
+		if (pos <= __arraySize(coll)) {
+		    ret = __ArrayInstPtr(coll)->a_element[pos-1];
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    }
+	}
     }
 %}.
     ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
@@ -374,20 +374,20 @@
      The receiver must support reading of binary bytes.
 
      Notice: this method is provided here for protocol completeness
-             with externalStreams - it is normally not used with other
-             streams."
+	     with externalStreams - it is normally not used with other
+	     streams."
 
-    ((initialIndex + numBytes - 1) <= aCollection size 
-        and:[(position + numBytes) <= readLimit 
-        and:[collection isByteCollection 
-        and:[aCollection isByteCollection
+    ((initialIndex + numBytes - 1) <= aCollection size
+	and:[(position + numBytes) <= readLimit
+	and:[collection isByteCollection
+	and:[aCollection isByteCollection
     ]]]) ifTrue:[
-        "do it the fast way"
-        aCollection 
-            replaceBytesFrom:initialIndex to:(initialIndex + numBytes - 1) 
-            with:collection startingAt:position+1.
-        position := position + numBytes.
-        ^ numBytes
+	"do it the fast way"
+	aCollection
+	    replaceBytesFrom:initialIndex to:(initialIndex + numBytes - 1)
+	    with:collection startingAt:position+1.
+	position := position + numBytes.
+	^ numBytes
     ].
     "do it the hard way"
     ^ super nextBytes:numBytes into:aCollection startingAt:initialIndex
@@ -419,32 +419,32 @@
     coll = __INST(collection);
     p = __INST(position);
     l = __INST(readLimit);
-    
+
     if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        limit = __intVal(l);
-        sz = __qSize(coll) - OHDR_SIZE;
-        if (sz < limit)
-            limit = sz; 
-        cp = __stringVal(coll) + pos - 1;
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	limit = __intVal(l);
+	sz = __qSize(coll) - OHDR_SIZE;
+	if (sz < limit)
+	    limit = sz;
+	cp = __stringVal(coll) + pos - 1;
 
-        for (;;) {
-            if (pos > limit) break;
-            ch = *cp;
+	for (;;) {
+	    if (pos > limit) break;
+	    ch = *cp;
 
-            if ((ch < '0') || (ch > '9')) break;
-            val = val * 10 + (ch - '0');
-            pos++;
-            if (val > (_MAX_INT / 10)) goto oops;
-            cp++;
-        }
-        /* make ZeroPosition-based */
-        pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-        __INST(position) = __mkSmallInteger(pos);
-        RETURN (__mkSmallInteger(val));
+	    if ((ch < '0') || (ch > '9')) break;
+	    val = val * 10 + (ch - '0');
+	    pos++;
+	    if (val > (_MAX_INT / 10)) goto oops;
+	    cp++;
+	}
+	/* make ZeroPosition-based */
+	pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+	__INST(position) = __mkSmallInteger(pos);
+	RETURN (__mkSmallInteger(val));
     }
 oops:
     value = __mkSmallInteger(val);
@@ -456,8 +456,8 @@
 
     nextOne := self peek.
     [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
-        value := (value * 10) + nextOne digitValue.
-        nextOne := self nextPeek
+	value := (value * 10) + nextOne digitValue.
+	nextOne := self nextPeek
     ].
     ^ value
 !
@@ -480,46 +480,46 @@
     l = __INST(readLimit);
 
     if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos > 0) {
-            OBJ cls, ret;
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos > 0) {
+	    OBJ cls, ret;
 
-            if (pos > __intVal(l)) {
-                RETURN(nil);
-            }
+	    if (pos > __intVal(l)) {
+		RETURN(nil);
+	    }
 
-            cls = __qClass(coll);
-            if (cls == @global(String)) {
-                if (pos <= __stringSize(coll)) {
-                    ch = __stringVal(coll)[pos-1];
-                    ret = __MKCHARACTER(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(ByteArray)) {
-                if (pos <= __byteArraySize(coll)) {
-                    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
-                    ret = __mkSmallInteger(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(Unicode16String)) {
-                if (pos <= __unicode16StringSize(coll)) {
-                    ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
-                    ret = __MKUCHARACTER(ch);
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            } else if (cls == @global(Array)) {
-                if (pos <= __arraySize(coll)) {
-                    ret = __ArrayInstPtr(coll)->a_element[pos-1];
-                    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
-                    RETURN ( ret );
-                }
-            }
-        }
+	    cls = __qClass(coll);
+	    if (cls == @global(String)) {
+		if (pos <= __stringSize(coll)) {
+		    ch = __stringVal(coll)[pos-1];
+		    ret = __MKCHARACTER(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(ByteArray)) {
+		if (pos <= __byteArraySize(coll)) {
+		    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+		    ret = __mkSmallInteger(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(Unicode16String)) {
+		if (pos <= __unicode16StringSize(coll)) {
+		    ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
+		    ret = __MKUCHARACTER(ch);
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    } else if (cls == @global(Array)) {
+		if (pos <= __arraySize(coll)) {
+		    ret = __ArrayInstPtr(coll)->a_element[pos-1];
+		    __INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1);
+		    RETURN ( ret );
+		}
+	    }
+	}
     }
 %}.
     ret := collection at:(position + 1 - ZeroPosition).
@@ -540,20 +540,20 @@
     l = __INST(readLimit);
 
     if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
-        REGISTER int pos;
-        unsigned ch;
+	REGISTER int pos;
+	unsigned ch;
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) {
-            pos = pos + 1;
-            ch = __stringVal(coll)[pos-1];
-            /* make ZeroPosition-based */
-            pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-            __INST(position) = __mkSmallInteger(pos);
-            RETURN ( __MKCHARACTER(ch) );
-        }
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) {
+	    pos = pos + 1;
+	    ch = __stringVal(coll)[pos-1];
+	    /* make ZeroPosition-based */
+	    pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+	    __INST(position) = __mkSmallInteger(pos);
+	    RETURN ( __MKCHARACTER(ch) );
+	}
     }
 %}.
     ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
@@ -580,27 +580,27 @@
 
     if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos <= __intVal(l) && pos > 0) {
-            cls = __qClass(coll);
-            if (cls == @global(String)) {
-                if (pos <= __stringSize(coll)) {
-                    ch = __stringVal(coll)[pos-1];
-                    RETURN ( __MKCHARACTER(ch) );
-                }
-            } else if (cls == @global(ByteArray)) {
-                if (pos <= __byteArraySize(coll)) {
-                    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
-                    RETURN ( __mkSmallInteger(ch) );
-                }
-            } else if (cls == @global(Array)) {
-                if (pos <= __arraySize(coll)) {
-                    RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
-                }
-            }
-        }
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos <= __intVal(l) && pos > 0) {
+	    cls = __qClass(coll);
+	    if (cls == @global(String)) {
+		if (pos <= __stringSize(coll)) {
+		    ch = __stringVal(coll)[pos-1];
+		    RETURN ( __MKCHARACTER(ch) );
+		}
+	    } else if (cls == @global(ByteArray)) {
+		if (pos <= __byteArraySize(coll)) {
+		    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+		    RETURN ( __mkSmallInteger(ch) );
+		}
+	    } else if (cls == @global(Array)) {
+		if (pos <= __arraySize(coll)) {
+		    RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
+		}
+	    }
+	}
     }
 %}.
     ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
@@ -670,46 +670,46 @@
     l = __INST(readLimit);
 
     if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
-        REGISTER unsigned char *chars;
-        REGISTER unsigned ch;
-        REGISTER int pos;
-        int limit;
-        int sz;
+	REGISTER unsigned char *chars;
+	REGISTER unsigned ch;
+	REGISTER int pos;
+	int limit;
+	int sz;
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos <= 0) {
-            RETURN ( nil );
-        }
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos <= 0) {
+	    RETURN ( nil );
+	}
 
-        limit = __intVal(l);
-        sz = __qSize(coll) - OHDR_SIZE;
-        if (limit > sz) {
-            limit = sz;
-        }
+	limit = __intVal(l);
+	sz = __qSize(coll) - OHDR_SIZE;
+	if (limit > sz) {
+	    limit = sz;
+	}
 
-        chars = (unsigned char *)(__stringVal(coll) + pos - 1);
-        while (pos <= limit) {
-            pos++;
-            ch = *chars++;
-            if ((ch > 0x20)
-             || ((ch != ' ')
-                 && (ch != '\t')
-                 && (ch != '\r')
-                 && (ch != '\n')
-                 && (ch != '\f')
-                 && (ch != 0x0B))) {
-                /* make ZeroPosition-based */
-                pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-                __INST(position) = __mkSmallInteger(pos-1);
-                RETURN ( __MKCHARACTER(ch) );
-            }
-        }
-        /* make ZeroPosition-based */
-        pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-        __INST(position) = __mkSmallInteger(pos);
-        RETURN ( nil );
+	chars = (unsigned char *)(__stringVal(coll) + pos - 1);
+	while (pos <= limit) {
+	    pos++;
+	    ch = *chars++;
+	    if ((ch > 0x20)
+	     || ((ch != ' ')
+		 && (ch != '\t')
+		 && (ch != '\r')
+		 && (ch != '\n')
+		 && (ch != '\f')
+		 && (ch != 0x0B))) {
+		/* make ZeroPosition-based */
+		pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+		__INST(position) = __mkSmallInteger(pos-1);
+		RETURN ( __MKCHARACTER(ch) );
+	    }
+	}
+	/* make ZeroPosition-based */
+	pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+	__INST(position) = __mkSmallInteger(pos);
+	RETURN ( nil );
     }
 %}.
     ^ super skipSeparators
@@ -737,43 +737,43 @@
     l = __INST(readLimit);
 
     if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
-        REGISTER unsigned char *chars;
-        REGISTER unsigned ch;
-        REGISTER int pos;
-        int limit;
+	REGISTER unsigned char *chars;
+	REGISTER unsigned ch;
+	REGISTER int pos;
+	int limit;
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos <= 0) {
-            RETURN ( nil );
-        }
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos <= 0) {
+	    RETURN ( nil );
+	}
 
-        limit = __intVal(l);
-        if (limit > (__qSize(coll) - OHDR_SIZE))
-            limit = __qSize(coll) - OHDR_SIZE;
+	limit = __intVal(l);
+	if (limit > (__qSize(coll) - OHDR_SIZE))
+	    limit = __qSize(coll) - OHDR_SIZE;
 
-        chars = (unsigned char *)(__stringVal(coll) + pos - 1);
-        while (pos <= limit) {
-            ch = *chars++;
-            if (((int)ch > 0x20)
-             || (
-                 (ch != ' ') 
-                 && (ch != '\t')
-                 && (ch != '\f')
-                 && (ch != '\b')
-                 && (ch != 0x0B))) {
-                /* make ZeroPosition-based */
-                pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-                __INST(position) = __mkSmallInteger(pos);
-                RETURN ( __MKCHARACTER(ch) );
-            }
-            pos++;
-        }
-        /* make ZeroPosition-based */
-        pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-        __INST(position) = __mkSmallInteger(pos);
-        RETURN ( nil );
+	chars = (unsigned char *)(__stringVal(coll) + pos - 1);
+	while (pos <= limit) {
+	    ch = *chars++;
+	    if (((int)ch > 0x20)
+	     || (
+		 (ch != ' ')
+		 && (ch != '\t')
+		 && (ch != '\f')
+		 && (ch != '\b')
+		 && (ch != 0x0B))) {
+		/* make ZeroPosition-based */
+		pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+		__INST(position) = __mkSmallInteger(pos);
+		RETURN ( __MKCHARACTER(ch) );
+	    }
+	    pos++;
+	}
+	/* make ZeroPosition-based */
+	pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+	__INST(position) = __mkSmallInteger(pos);
+	RETURN ( nil );
     }
 %}
 .
@@ -782,7 +782,7 @@
 
 skipThrough:anObject
     "skip all objects up-to and including anObject.
-     Return the receiver if skip was successful, 
+     Return the receiver if skip was successful,
      otherwise (i.e. if not found) return nil and leave the stream positioned at the end.
      On success, the next read operation will return the element after anObject.
      - reimplemented for speed on String-Streams for faster scanning"
@@ -797,40 +797,40 @@
     if (__isStringLike(coll)
      && __isCharacter(anObject)
      && __bothSmallInteger(p, l)) {
-        REGISTER unsigned char *chars;
-        REGISTER int pos, limit;
-        unsigned ch;
-        int sz;
+	REGISTER unsigned char *chars;
+	REGISTER int pos, limit;
+	unsigned ch;
+	int sz;
 
-        pos = __intVal(p);
-        /* make 1-based */
-        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
-        if (pos <= 0) {
-            RETURN ( nil );
-        }
+	pos = __intVal(p);
+	/* make 1-based */
+	pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+	if (pos <= 0) {
+	    RETURN ( nil );
+	}
 
-        limit = __intVal(l);
-        sz = __stringSize(coll);
-        if (limit > sz) limit = sz;
+	limit = __intVal(l);
+	sz = __stringSize(coll);
+	if (limit > sz) limit = sz;
 
-        chars = (unsigned char *)(__stringVal(coll) + pos - 1);
-        ch = __intVal(_characterVal(anObject)) & 0xFF;
-        while (pos < limit) {
-            if (*chars == ch) {
-                ch = *++chars;
-                pos++;
-                /* make ZeroPosition-based */
-                pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-                __INST(position) = __mkSmallInteger(pos);
-                RETURN ( self );
-            }
-            chars++;
-            pos++;
-        }
-        /* make ZeroPosition-based */
-        pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
-        __INST(position) = __mkSmallInteger(pos+1);
-        RETURN ( nil );
+	chars = (unsigned char *)(__stringVal(coll) + pos - 1);
+	ch = __intVal(__characterVal(anObject)) & 0xFF;
+	while (pos < limit) {
+	    if (*chars == ch) {
+		ch = *++chars;
+		pos++;
+		/* make ZeroPosition-based */
+		pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+		__INST(position) = __mkSmallInteger(pos);
+		RETURN ( self );
+	    }
+	    chars++;
+	    pos++;
+	}
+	/* make ZeroPosition-based */
+	pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition));
+	__INST(position) = __mkSmallInteger(pos+1);
+	RETURN ( nil );
     }
 %}.
     ^ super skipThrough:anObject
@@ -847,10 +847,10 @@
 !ReadStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.66 2013-03-22 14:24:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.67 2013-05-21 20:44:47 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.66 2013-03-22 14:24:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.67 2013-05-21 20:44:47 cg Exp $'
 ! !