865 |
865 |
866 upTo:anObject |
866 upTo:anObject |
867 %{ |
867 %{ |
868 OBJ _collection = __INST(collection); |
868 OBJ _collection = __INST(collection); |
869 |
869 |
870 if (__isString(_collection) |
870 if (__isStringLike(_collection) |
871 && __isCharacter(anObject)) { |
871 && __isCharacter(anObject)) { |
872 unsigned int ch = __intVal(__characterVal(anObject)); |
872 unsigned int ch = __intVal(__characterVal(anObject)); |
873 |
873 |
874 if (ch <= 0xFF) { |
874 if (ch <= 0xFF) { |
875 int _startPos = __intVal(__INST(position)); |
875 int _startPos = __intVal(__INST(position)); |
876 int _endIndex; |
876 int _endIndex; |
877 char *startPtr = __stringVal(_collection) + _startPos; |
877 char *startPtr = __stringVal(_collection) + _startPos; |
878 char *foundPtr; |
878 char *foundPtr; |
879 OBJ rslt; |
879 OBJ rslt; |
880 int nMax; |
880 int nMax; |
881 |
881 |
882 _endIndex = __stringSize(_collection); |
882 _endIndex = __stringSize(_collection); |
883 if (__isInteger(__INST(readLimit))) { |
883 if (__isInteger(__INST(readLimit))) { |
884 int _readLimit = __intVal(__INST(readLimit)); |
884 int _readLimit = __intVal(__INST(readLimit)); |
885 |
885 |
886 if (_readLimit < _endIndex) _endIndex = _readLimit; |
886 if (_readLimit < _endIndex) _endIndex = _readLimit; |
887 } |
887 } |
888 |
888 |
889 nMax = _endIndex-_startPos; |
889 nMax = _endIndex-_startPos; |
890 foundPtr = (char *)memchr( startPtr, ch, (long)nMax); |
890 foundPtr = (char *)memchr( startPtr, ch, (long)nMax); |
891 if (foundPtr == 0) { |
891 if (foundPtr == 0) { |
892 // not found |
892 // not found |
893 rslt = __MKEMPTYSTRING(nMax); |
893 rslt = __MKEMPTYSTRING(nMax); |
894 // refetch - may GC |
894 // refetch - may GC |
895 _collection = __INST(collection); |
895 _collection = __INST(collection); |
896 memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)nMax); |
896 memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)nMax); |
897 __INST(position) = __mkSmallInteger(_endIndex); |
897 __INST(position) = __mkSmallInteger(_endIndex); |
898 } else { |
898 } else { |
899 // found at foundPtr |
899 // found at foundPtr |
900 int n = foundPtr-startPtr; |
900 int n = foundPtr-startPtr; |
901 |
901 |
902 rslt = __MKEMPTYSTRING(n); |
902 rslt = __MKEMPTYSTRING(n); |
903 // refetch - may GC |
903 // refetch - may GC |
904 _collection = __INST(collection); |
904 _collection = __INST(collection); |
905 memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)n); |
905 memcpy((void *)__stringVal(rslt), (void *)(__stringVal(_collection) + _startPos), (size_t)n); |
906 __INST(position) = __mkSmallInteger(_startPos + n + 1); |
906 __INST(position) = __mkSmallInteger(_startPos + n + 1); |
907 } |
907 } |
908 RETURN (rslt); |
908 RETURN (rslt); |
909 } |
909 } |
910 } |
910 } |
911 %}. |
911 %}. |
912 ^ super upTo:anObject |
912 ^ super upTo:anObject |
|
913 |
|
914 "Modified: / 22-03-2019 / 03:01:19 / Claus Gittinger" |
913 ! ! |
915 ! ! |
914 |
916 |
915 !ReadStream methodsFor:'reading-numbers'! |
917 !ReadStream methodsFor:'reading-numbers'! |
916 |
918 |
917 nextDecimalInteger |
919 nextDecimalInteger |