ReadStream.st
changeset 21134 8afa60876626
parent 20129 2424f9b0b209
child 21242 19fabe339f8b
child 21755 3b9923afe541
--- a/ReadStream.st	Thu Dec 15 13:55:00 2016 +0100
+++ b/ReadStream.st	Thu Dec 15 13:55:14 2016 +0100
@@ -428,69 +428,6 @@
     ^ ret
 !
 
-nextDecimalInteger
-    "read the next integer in radix 10.
-     Does NOT skip initial whitespace.
-     The streams elements should be characters.
-
-     Be careful - this method returns 0 if not positioned on a digit intitially
-     or if the end of the stream is encountered.
-
-     Tuned for speed on String-Streams for faster scanning"
-
-    |value nextOne|
-%{
-    INT pos, limit, sz;
-    REGISTER unsigned char *cp;
-    REGISTER unsigned ch;
-    INT val = 0;
-    OBJ coll, p, l;
-
-    coll = __INST(collection);
-    p = __INST(position);
-    l = __INST(readLimit);
-
-    if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
-
-	pos = __intVal(p);
-	/* make 1-based */
-	pos++;
-	limit = __intVal(l);
-	sz = __qSize(coll) - OHDR_SIZE;
-	if (sz < limit)
-	    limit = sz;
-	cp = __stringVal(coll) + pos - 1;
-
-	for (;;) {
-	    if (pos > limit) break;
-	    ch = *cp;
-
-	    if ((ch < '0') || (ch > '9')) break;
-	    val = val * 10 + (ch - '0');
-	    pos++;
-	    if (val > (_MAX_INT / 10)) goto oops;
-	    cp++;
-	}
-	pos--;
-	__INST(position) = __mkSmallInteger(pos);
-	RETURN (__mkSmallInteger(val));
-    }
-oops:
-    value = __mkSmallInteger(val);
-%}
-.
-    "fall-back for non-string streams - we have to continue where
-     above primitive left off, in case of a large integer ...
-     (instead of doing a super nextDecimalInteger)"
-
-    nextOne := self peek.
-    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
-	value := (value * 10) + nextOne digitValue.
-	nextOne := self nextPeek
-    ].
-    ^ value
-!
-
 nextOrNil
     "return the next element; advance read pointer.
      return nil, if there is no next element.
@@ -950,6 +887,71 @@
     ^ super upTo:anObject
 ! !
 
+!ReadStream methodsFor:'reading-numbers'!
+
+nextDecimalInteger
+    "read the next integer in radix 10.
+     Does NOT skip initial whitespace.
+     The streams elements should be characters.
+
+     Be careful - this method returns 0 if not positioned on a digit intitially
+     or if the end of the stream is encountered.
+
+     Tuned for speed on String-Streams for faster scanning"
+
+    |value nextOne|
+%{
+    INT pos, limit, sz;
+    REGISTER unsigned char *cp;
+    REGISTER unsigned ch;
+    INT val = 0;
+    OBJ coll, p, l;
+
+    coll = __INST(collection);
+    p = __INST(position);
+    l = __INST(readLimit);
+
+    if (__isStringLike(coll) && __bothSmallInteger(p, l)) {
+
+	pos = __intVal(p);
+	/* make 1-based */
+	pos++;
+	limit = __intVal(l);
+	sz = __qSize(coll) - OHDR_SIZE;
+	if (sz < limit)
+	    limit = sz;
+	cp = __stringVal(coll) + pos - 1;
+
+	for (;;) {
+	    if (pos > limit) break;
+	    ch = *cp;
+
+	    if ((ch < '0') || (ch > '9')) break;
+	    val = val * 10 + (ch - '0');
+	    pos++;
+	    if (val > (_MAX_INT / 10)) goto oops;
+	    cp++;
+	}
+	pos--;
+	__INST(position) = __mkSmallInteger(pos);
+	RETURN (__mkSmallInteger(val));
+    }
+oops:
+    value = __mkSmallInteger(val);
+%}
+.
+    "fall-back for non-string streams - we have to continue where
+     above primitive left off, in case of a large integer ...
+     (instead of doing a super nextDecimalInteger)"
+
+    nextOne := self peek.
+    [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[
+	value := (value * 10) + nextOne digitValue.
+	nextOne := self nextPeek
+    ].
+    ^ value
+! !
+
 !ReadStream methodsFor:'writing'!
 
 nextPut:anElement