--- a/ReadStream.st Mon Feb 19 16:05:10 1996 +0100
+++ b/ReadStream.st Mon Feb 19 16:07:27 1996 +0100
@@ -10,11 +10,13 @@
hereby transferred.
"
+'From Smalltalk/X, Version:2.10.8 on 6-feb-1996 at 15:31:28' !
+
PositionableStream subclass:#ReadStream
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- category:'Streams'
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Streams'
!
!ReadStream class methodsFor:'documentation'!
@@ -75,37 +77,34 @@
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
- pos = _intVal(p);
- if (pos > _intVal(l)) {
- RETURN ( nil );
- }
- if (pos > 0) {
- OBJ cls;
+ pos = _intVal(p);
+ if (pos > 0 && pos <= _intVal(l)) {
+ OBJ cls;
- cls = __qClass(coll);
- if (cls == String) {
- if (pos <= _stringSize(coll)) {
- _INST(position) = _MKSMALLINT(pos + 1);
- ch = _stringVal(coll)[pos-1];
- RETURN ( _MKCHARACTER(ch) );
- }
- } else if (cls == ByteArray) {
- if (pos <= _byteArraySize(coll)) {
- _INST(position) = _MKSMALLINT(pos + 1);
- ch = _ByteArrayInstPtr(coll)->ba_element[pos-1];
- RETURN ( _MKSMALLINT(ch) );
- }
- } else if (cls == Array) {
- if (pos <= _arraySize(coll)) {
- _INST(position) = _MKSMALLINT(pos + 1);
- RETURN ( _ArrayInstPtr(coll)->a_element[pos-1]);
- }
- }
- }
+ cls = __qClass(coll);
+ if (cls == String) {
+ if (pos <= _stringSize(coll)) {
+ _INST(position) = _MKSMALLINT(pos + 1);
+ ch = _stringVal(coll)[pos-1];
+ RETURN ( _MKCHARACTER(ch) );
+ }
+ } else if (cls == ByteArray) {
+ if (pos <= _byteArraySize(coll)) {
+ _INST(position) = _MKSMALLINT(pos + 1);
+ ch = _ByteArrayInstPtr(coll)->ba_element[pos-1];
+ RETURN ( _MKSMALLINT(ch) );
+ }
+ } else if (cls == Array) {
+ if (pos <= _arraySize(coll)) {
+ _INST(position) = _MKSMALLINT(pos + 1);
+ RETURN ( _ArrayInstPtr(coll)->a_element[pos-1]);
+ }
+ }
+ }
}
%}
.
- (position > readLimit) ifTrue:[^ nil].
+ (position > readLimit) ifTrue:[^ self pastEnd].
ret := collection at:position.
position := position + 1.
^ ret
@@ -244,31 +243,22 @@
l = _INST(readLimit);
if (__isString(coll) && __bothSmallInteger(p, l)) {
- REGISTER int pos;
- unsigned ch;
+ REGISTER int pos;
+ unsigned ch;
- pos = _intVal(p);
- if (pos > _intVal(l)) {
- RETURN ( nil );
- }
- if ((pos > 0) && (pos <= _stringSize(coll))) {
- _INST(position) = _MKSMALLINT(pos + 1);
- pos = pos + 1;
- if (pos > _intVal(l)) {
- RETURN ( nil );
- }
- if (pos <= _stringSize(coll)) {
- ch = _stringVal(coll)[pos-1];
- RETURN ( _MKCHARACTER(ch) );
- }
- RETURN ( nil );
- }
+ pos = _intVal(p);
+ if ((pos > 0) && (pos < _intVal(l)) && (pos < _stringSize(coll))) {
+ pos += 1;
+ _INST(position) = _MKSMALLINT(pos);
+ ch = _stringVal(coll)[pos-1];
+ RETURN ( _MKCHARACTER(ch) );
+ }
}
%}
.
- (position > readLimit) ifTrue:[^ nil].
+ (position > readLimit) ifTrue:[^ self pastEnd].
position := position + 1.
- (position > readLimit) ifTrue:[^ nil].
+ (position > readLimit) ifTrue:[^ self pastEnd].
^ collection at:position
!
@@ -344,33 +334,29 @@
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
- pos = _intVal(p);
- if (pos > _intVal(l)) {
- RETURN ( nil );
- }
-
- if (pos > 0) {
- cls = __qClass(coll);
- if (cls == String) {
- if (pos <= _stringSize(coll)) {
- ch = _stringVal(coll)[pos-1];
- RETURN ( _MKCHARACTER(ch) );
- }
- } else if (cls == ByteArray) {
- if (pos <= _byteArraySize(coll)) {
- ch = _ByteArrayInstPtr(coll)->ba_element[pos-1];
- RETURN ( _MKSMALLINT(ch) );
- }
- } else if (cls == Array) {
- if (pos <= _arraySize(coll)) {
- RETURN ( _ArrayInstPtr(coll)->a_element[pos-1]);
- }
- }
- }
+ pos = _intVal(p);
+ if (pos <= _intVal(l) && pos > 0) {
+ cls = __qClass(coll);
+ if (cls == String) {
+ if (pos <= _stringSize(coll)) {
+ ch = _stringVal(coll)[pos-1];
+ RETURN ( _MKCHARACTER(ch) );
+ }
+ } else if (cls == ByteArray) {
+ if (pos <= _byteArraySize(coll)) {
+ ch = _ByteArrayInstPtr(coll)->ba_element[pos-1];
+ RETURN ( _MKSMALLINT(ch) );
+ }
+ } else if (cls == Array) {
+ if (pos <= _arraySize(coll)) {
+ RETURN ( _ArrayInstPtr(coll)->a_element[pos-1]);
+ }
+ }
+ }
}
%}
.
- (position > readLimit) ifTrue:[^ nil].
+ (position > readLimit) ifTrue:[^ self pastEnd].
^ collection at:position
!
@@ -556,5 +542,5 @@
!ReadStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.22 1996-01-04 01:23:30 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.23 1996-02-19 15:07:26 stefan Exp $'
! !