PositionableStream.st
branchjv
changeset 18066 89d51443ba6f
parent 18054 56594a8c6b83
parent 15357 10a1cd767648
child 18084 ab5b38bd8f81
--- a/PositionableStream.st	Sun Jun 09 00:49:37 2013 +0100
+++ b/PositionableStream.st	Mon Jun 10 17:32:35 2013 +0100
@@ -58,7 +58,9 @@
 !PositionableStream class methodsFor:'initialization'!
 
 initialize
-    ZeroPosition := 0.        "/ changed with stx rel5.1
+    ZeroPosition := 0.        "/ changed with stx rel5.1; 
+                              "/ rel6.2: no longer used (i.e. 0 has now ben hardcoded)
+                              "/ class variable to be eliminated.
 
     InvalidPositionErrorSignal isNil ifTrue:[
         InvalidPositionErrorSignal := PositionOutOfBoundsError.
@@ -109,7 +111,7 @@
      Although this is confusing ST/X has been changed to now also use 0-based stream positioning.
     "
 
-    ^ ZeroPosition
+    ^ 0
 
     "Modified: / 13-07-2006 / 20:36:54 / cg"
 ! !
@@ -230,24 +232,20 @@
 position
     "return the read position"
 
-    ZeroPosition == 0 ifTrue:[
-        ^ self position0Based
-    ] ifFalse:[
-        ^ self position1Based
-    ].
+    ^ self position0Based
 !
 
 position0Based
     "return the read position 0-based"
 
-    ^ position - ZeroPosition
+    ^ position
 !
 
 position0Based:index0Based
     "set the read (or write) position"
 
     ((index0Based > readLimit) or:[index0Based < 0]) ifTrue: [^ self positionError:index0Based].
-    position := index0Based + ZeroPosition
+    position := index0Based
 !
 
 position1Based
@@ -294,11 +292,7 @@
 position:newPos
     "set the read (or write) position"
 
-    ZeroPosition == 0 ifTrue:[
-        ^ self position0Based:newPos
-    ] ifFalse:[
-        ^ self position1Based:newPos
-    ].
+    ^ self position0Based:newPos
 
     "
      |s|
@@ -348,7 +342,7 @@
 resetPosition
     "set the read position to the beginning of the collection"
 
-    position := ZeroPosition
+    position := 0
 
     "
      |s|
@@ -365,7 +359,7 @@
      #next will return EOF, #nextPut: will append to the stream.
      (same Behavior as FileStream."
 
-    position := readLimit + ZeroPosition
+    position := readLimit
 !
 
 skip:numberToSkip
@@ -511,14 +505,14 @@
     readLimit == 0 ifTrue:[
         self assert:(aCollection isCollection)
     ].
-    position := ZeroPosition
+    position := 0
 !
 
 on:aCollection from:first to:last
     "setup for streaming on aCollection from first to last"
 
     collection := aCollection.
-    position := first - 1 + ZeroPosition.
+    position := first - 1.
     readLimit := last
 !
 
@@ -562,11 +556,11 @@
     |end result|
 
     end := position + count.
-    (end - ZeroPosition + 1) > readLimit ifTrue:[
+    end >= readLimit ifTrue:[
         end := readLimit.
     ].
 
-    result := collection copyFrom:position+1-ZeroPosition to:end.
+    result := collection copyFrom:position+1 to:end.
     position := end.
     ^ result.
 
@@ -639,7 +633,7 @@
 atEnd
     "return true, if the read-position is at the end"
 
-    ^ (position - ZeroPosition + 1) > readLimit
+    ^ position >= readLimit
 !
 
 isEmpty
@@ -665,11 +659,11 @@
 !PositionableStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.156 2013-04-25 13:09:40 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.159 2013-06-03 18:39:54 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.156 2013-04-25 13:09:40 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.159 2013-06-03 18:39:54 cg Exp $'
 ! !