ReadStream.st
changeset 1406 fd7eed0e648f
parent 1400 0ee12d945849
child 1422 9a0b792f2953
--- a/ReadStream.st	Thu May 16 14:46:53 1996 +0200
+++ b/ReadStream.st	Thu May 16 14:49:04 1996 +0200
@@ -400,36 +400,50 @@
     l = __INST(readLimit);
 
     if (__isString(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;
+        int sz;
 
-	pos = __intVal(p);
-	if (pos <= 0) {
-	    RETURN ( nil );
-	}
+        pos = __intVal(p);
+        if (pos <= 0) {
+            RETURN ( nil );
+        }
 
-	limit = __intVal(l);
-	if (limit > (__qSize(coll) - OHDR_SIZE))
-	    limit = __qSize(coll) - OHDR_SIZE;
+        limit = __intVal(l);
+        sz = __qSize(coll) - OHDR_SIZE;
+        if (limit > sz) {
+            limit = sz;
+        }
 
-	chars = (unsigned char *)(__stringVal(coll) + pos - 1);
-	while (pos <= limit) {
-	    ch = *chars++;
-	    if ((ch != ' ') && (ch != '\t') && (ch != '\r')
-	     && (ch != '\n') && (ch != 0x0B)) {
-		__INST(position) = __MKSMALLINT(pos);
-		RETURN ( __MKCHARACTER(ch) );
-	    }
-	    pos++;
-	}
-	__INST(position) = __MKSMALLINT(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 != 0x0B))) {
+                __INST(position) = __MKSMALLINT(pos-1);
+                RETURN ( __MKCHARACTER(ch) );
+            }
+        }
+        __INST(position) = __MKSMALLINT(pos);
+        RETURN ( nil );
     }
-%}
-.
+%}.
     ^ super skipSeparators
+
+    "
+     |s|
+
+     s := '     hello     world    ' readStream.
+     s skipSeparators.
+     s next.
+    "
 !
 
 skipSeparatorsExceptCR
@@ -569,5 +583,5 @@
 !ReadStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.27 1996-05-15 15:30:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.28 1996-05-16 12:49:04 cg Exp $'
 ! !