Mail Archives: djgpp-workers/1998/01/27/03:55:26
DJ Delorie wrote:
>
> Beware: in MS-DOS the file position may be negative. At least, this
> is what I remember from our discussion of the portability of lseek()
> under "undefined" conditions. Having a file position that doesn't
> allow for negative numbers, when MS-DOS will gladly give you a
> negative number, may cause obscure problems at runtime.
I'm not so sure whether DOS "allows" the file pointer to be negative. I
know that RBI tells me that it is allowed, but you could explain it as
easily as that the file pointer is silently overflowed when it passes
the 0 position.
This duality probably arise from the fact that with SEEK_SET the offset
parameter is considered as absolute and with SEEK_REL and SEEK_END as
relative, and when calling DOS fn 42h they both end up in the same
register.
The fact that DOS always produced errors for "negative" offsets is
probably due to the fact that those offset are 2G+ and until recently
even no one ever could create such files (DOS 6.22- even does not allow
for them)
--
\ Vik /-_-_-_-_-_-_/
\___/ Heyndrickx /
\ /-_-_-_-_-_-_/
- Raw text -