Two problems/inconsistencies:
Stdio.FakeFile.read(len) will return 0 if len is more than there is data left to read. This is inconsistent with Stdio.File.read(len), which returns less than len, an empty string if no data is left (for a disk file at least).
Stdio.Stream declares a prototype string read(int nbytes); and does not allow for a second argument not_all (which would work around the previous issue).
Together this creates problems when writing a function to operate on a Stdio.Stream (open for reading), when you want to be able to drop in an instance of either a Stdio.File or a Stdio.FakeFile at runtime.
(I checked this on 7.4, can't look at 7.5 right now because the cvs browser seems to be broken)
/rjb
It's probably not fixed in 7.5. What do you say about getting access to commit such minor fixes yourself?
/ Martin Stjernholm, Roxen IS
Previous text:
2003-04-14 14:32: Subject: nasties in Stdio
Two problems/inconsistencies:
Stdio.FakeFile.read(len) will return 0 if len is more than there is data left to read. This is inconsistent with Stdio.File.read(len), which returns less than len, an empty string if no data is left (for a disk file at least).
Stdio.Stream declares a prototype string read(int nbytes); and does not allow for a second argument not_all (which would work around the previous issue).
Together this creates problems when writing a function to operate on a Stdio.Stream (open for reading), when you want to be able to drop in an instance of either a Stdio.File or a Stdio.FakeFile at runtime.
(I checked this on 7.4, can't look at 7.5 right now because the cvs browser seems to be broken)
/rjb
/ rjb
pike-devel@lists.lysator.liu.se