In 2.3.1 with compiler-cascade.diff and the 3 diffs I posted yesterday
and today, I noticed that FileStream>>#copyFrom:to: uses 0-index,
whereas PositionableStream>>#copyFrom:to: uses 1-index.
st> | fs |
fs := FileStream fopen: '/home/sirian/TODO' mode: FileStream read.
[(fs copyFrom: 1 to: 3) printNl] ensure: [fs close]!
' To'
st> ('* Today' readStream copyFrom: 1 to: 3) printNl!
'* T'
(/home/sirian/TODO starts with '* Today:')
I'll assume that 0-index is intended, because that's what
PositionableStream>>#segmentFrom:to: depends on in compiler/RBParser.st.
On a related note, I found something else in kernel/FileDescr.st:
copyFrom: from to: to
"Answer the contents of the file between the two given positions"
| offset fromPos toPos savePos |
from > to ifTrue: [
from = to + 1 ifTrue: [ ^self species new ].
^SystemExceptions.ArgumentOutOfRange signalOn: from mustBeBetween: 1 and: to + 1
].
savePos := self fileOp: 5.
^[
self position: fromPos.
self next: toPos - fromPos + 1
] ensure: [
self position: savePos
]
How do offset, fromPos, and toPos get set in this method?
--
Stephen Compall
http://scompall.nocandysw.com/blog_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk