--- a/ReadStream.st Thu Sep 30 17:07:49 2004 +0200
+++ b/ReadStream.st Fri Oct 01 09:36:29 2004 +0200
@@ -146,37 +146,41 @@
/* make 1-based */
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
if (pos > 0 && pos <= __intVal(l)) {
- OBJ cls;
+ OBJ cls, ret;
cls = __qClass(coll);
if (cls == @global(String)) {
if (pos <= __stringSize(coll)) {
+ ch = __stringVal(coll)[pos-1];
+ ret = __MKCHARACTER(ch);
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- ch = __stringVal(coll)[pos-1];
- RETURN ( __MKCHARACTER(ch) );
+ RETURN ( ret );
}
} else if (cls == @global(ByteArray)) {
if (pos <= __byteArraySize(coll)) {
+ ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+ ret = __MKSMALLINT(ch);
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
- RETURN ( __MKSMALLINT(ch) );
+ RETURN ( ret );
}
} else if (cls == @global(Unicode16String)) {
if (pos <= __unicode16StringSize(coll)) {
+ ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
+ ret = __MKUCHARACTER(ch);
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- ch = __Unicode16StringInstPtr(coll)->s_element[pos-1];
- RETURN ( __MKUCHARACTER(ch) );
+ RETURN ( ret );
}
} else if (cls == @global(Array)) {
if (pos <= __arraySize(coll)) {
+ ret = __ArrayInstPtr(coll)->a_element[pos-1];
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
+ RETURN ( ret );
}
}
}
}
%}.
- ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
+ ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
ret := collection at:(position + 1 - ZeroPosition).
position := position + 1.
^ ret
@@ -277,31 +281,34 @@
/* make 1-based */
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition));
if (pos > 0 && pos <= __intVal(l)) {
- OBJ cls;
+ OBJ cls, ret;
cls = __qClass(coll);
if (cls == @global(String)) {
if (pos <= __stringSize(coll)) {
+ ch = __stringVal(coll)[pos-1];
+ ret = __MKSMALLINT(ch);
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- ch = __stringVal(coll)[pos-1];
- RETURN ( __MKSMALLINT(ch) );
+ RETURN ( ret );
}
} else if (cls == @global(ByteArray)) {
if (pos <= __byteArraySize(coll)) {
+ ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
+ ret = __MKSMALLINT(ch);
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- ch = __ByteArrayInstPtr(coll)->ba_element[pos-1];
- RETURN ( __MKSMALLINT(ch) );
+ RETURN ( ret );
}
} else if (cls == @global(Array)) {
if (pos <= __arraySize(coll)) {
+ ret = __ArrayInstPtr(coll)->a_element[pos-1];
__INST(position) = __MKSMALLINT(__intVal(__INST(position)) + 1);
- RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
+ RETURN ( ret );
}
}
}
}
%}.
- ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
+ ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
ret := collection at:(position + 1 -ZeroPosition).
position := position + 1.
^ ret asInteger
@@ -416,25 +423,25 @@
l = __INST(readLimit);
if (__isString(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) = __MKSMALLINT(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) = __MKSMALLINT(pos);
+ RETURN ( __MKCHARACTER(ch) );
+ }
}
%}.
- ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
+ ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
position := position + 1.
- ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
+ ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
^ collection at:(position + 1 - ZeroPosition)
!
@@ -513,30 +520,30 @@
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 ( __MKSMALLINT(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 ( __MKSMALLINT(ch) );
+ }
+ } else if (cls == @global(Array)) {
+ if (pos <= __arraySize(coll)) {
+ RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]);
+ }
+ }
+ }
}
%}.
- ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEnd].
+ ((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead].
^ collection at:(position + 1 - ZeroPosition)
!
@@ -780,5 +787,5 @@
!ReadStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.51 2004-09-10 11:16:19 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.52 2004-10-01 07:36:12 cg Exp $'
! !