--- a/ReadStream.st Fri Mar 22 13:26:46 2019 +0100
+++ b/ReadStream.st Fri Mar 22 13:31:18 2019 +0100
@@ -867,49 +867,51 @@
%{
OBJ _collection = __INST(collection);
- if (__isString(_collection)
+ if (__isStringLike(_collection)
&& __isCharacter(anObject)) {
- unsigned int ch = __intVal(__characterVal(anObject));
+ unsigned int ch = __intVal(__characterVal(anObject));
- if (ch <= 0xFF) {
- int _startPos = __intVal(__INST(position));
- int _endIndex;
- char *startPtr = __stringVal(_collection) + _startPos;
- char *foundPtr;
- OBJ rslt;
- int nMax;
+ if (ch <= 0xFF) {
+ int _startPos = __intVal(__INST(position));
+ int _endIndex;
+ char *startPtr = __stringVal(_collection) + _startPos;
+ char *foundPtr;
+ OBJ rslt;
+ int nMax;
- _endIndex = __stringSize(_collection);
- if (__isInteger(__INST(readLimit))) {
- int _readLimit = __intVal(__INST(readLimit));
+ _endIndex = __stringSize(_collection);
+ if (__isInteger(__INST(readLimit))) {
+ int _readLimit = __intVal(__INST(readLimit));
- if (_readLimit < _endIndex) _endIndex = _readLimit;
- }
+ if (_readLimit < _endIndex) _endIndex = _readLimit;
+ }
- nMax = _endIndex-_startPos;
- foundPtr = (char *)memchr( startPtr, ch, (long)nMax);
- if (foundPtr == 0) {
- // not found
- rslt = __MKEMPTYSTRING(nMax);
- // refetch - may GC
- _collection = __INST(collection);
- memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)nMax);
- __INST(position) = __mkSmallInteger(_endIndex);
- } else {
- // found at foundPtr
- int n = foundPtr-startPtr;
+ nMax = _endIndex-_startPos;
+ foundPtr = (char *)memchr( startPtr, ch, (long)nMax);
+ if (foundPtr == 0) {
+ // not found
+ rslt = __MKEMPTYSTRING(nMax);
+ // refetch - may GC
+ _collection = __INST(collection);
+ memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)nMax);
+ __INST(position) = __mkSmallInteger(_endIndex);
+ } else {
+ // found at foundPtr
+ int n = foundPtr-startPtr;
- rslt = __MKEMPTYSTRING(n);
- // refetch - may GC
- _collection = __INST(collection);
- memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)n);
- __INST(position) = __mkSmallInteger(_startPos + n + 1);
- }
- RETURN (rslt);
- }
+ rslt = __MKEMPTYSTRING(n);
+ // refetch - may GC
+ _collection = __INST(collection);
+ memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)n);
+ __INST(position) = __mkSmallInteger(_startPos + n + 1);
+ }
+ RETURN (rslt);
+ }
}
%}.
^ super upTo:anObject
+
+ "Modified: / 22-03-2019 / 03:01:19 / Claus Gittinger"
! !
!ReadStream methodsFor:'reading-numbers'!