ReadStream.st
changeset 8098 8d1d5cd8529b
parent 7483 471b86450ede
child 8140 7cc7ac5f29ca
--- a/ReadStream.st	Fri Mar 05 20:42:02 2004 +0100
+++ b/ReadStream.st	Fri Mar 05 21:00:26 2004 +0100
@@ -45,7 +45,6 @@
 "
 ! !
 
-
 !ReadStream methodsFor:'converting'!
 
 readStream
@@ -134,32 +133,38 @@
 
     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;
+        pos = __intVal(p);
+        /* make 1-based */
+        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+        if (pos > 0 && pos <= __intVal(l)) {
+            OBJ cls;
 
-	    cls = __qClass(coll);
-	    if (cls == @global(String)) {
-		if (pos <= __stringSize(coll)) {
-		    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
-		    ch = __stringVal(coll)[pos-1];
-		    RETURN ( __MKCHARACTER(ch) );
-		}
-	    } else if (cls == @global(ByteArray)) {
-		if (pos <= __byteArraySize(coll)) {
-		    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
-		    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
-		    RETURN ( __MKSMALLINT(ch) );
-		}
-	    } else if (cls == @global(Array)) {
-		if (pos <= __arraySize(coll)) {
-		    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
-		    RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
-		}
-	    }
-	}
+            cls = __qClass(coll);
+            if (cls == @global(String)) {
+                if (pos <= __stringSize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    ch = __stringVal(coll)[pos-1];
+                    RETURN ( __MKCHARACTER(ch) );
+                }
+            } else if (cls == @global(ByteArray)) {
+                if (pos <= __byteArraySize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+                    RETURN ( __MKSMALLINT(ch) );
+                }
+            } else if (cls == @global(Unicode16String)) {
+                if (pos <= __unicode16StringSize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
+                    RETURN ( __MKUCHARACTER(ch) );
+                }
+            } else if (cls == @global(Array)) {
+                if (pos <= __arraySize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
+                }
+            }
+        }
     }
 %}.
     ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
@@ -259,38 +264,38 @@
 
     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;
+        pos = __intVal(p);
+        /* make 1-based */
+        pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
+        if (pos > 0 && pos <= __intVal(l)) {
+            OBJ cls;
 
-	    cls = __qClass(coll);
-	    if (cls == @global(String)) {
-		if (pos <= __stringSize(coll)) {
-		    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
-		    ch = __stringVal(coll)[pos-1];
-		    RETURN ( __MKSMALLINT(ch) );
-		}
-	    } else if (cls == @global(ByteArray)) {
-		if (pos <= __byteArraySize(coll)) {
-		    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
-		    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
-		    RETURN ( __MKSMALLINT(ch) );
-		}
-	    } else if (cls == @global(Array)) {
-		if (pos <= __arraySize(coll)) {
-		    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
-		    RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
-		}
-	    }
-	}
+            cls = __qClass(coll);
+            if (cls == @global(String)) {
+                if (pos <= __stringSize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    ch = __stringVal(coll)[pos-1];
+                    RETURN ( __MKSMALLINT(ch) );
+                }
+            } else if (cls == @global(ByteArray)) {
+                if (pos <= __byteArraySize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+                    RETURN ( __MKSMALLINT(ch) );
+                }
+            } else if (cls == @global(Array)) {
+                if (pos <= __arraySize(coll)) {
+                    __INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
+                    RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
+                }
+            }
+        }
     }
 %}.
     ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
     ret := collection at:(position + 1 -ZeroPosition).
     position := position + 1.
-    ^ ret
+    ^ ret asInteger
 !
 
 nextDecimalInteger
@@ -728,5 +733,5 @@
 !ReadStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.48 2003-07-08 20:31:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.49 2004-03-05 20:00:26 cg Exp $'
 ! !