Mail Archives: djgpp/1998/12/09/05:34:58
On Tue, 8 Dec 1998, HANRIGOU wrote:
> fin = fopen(input_file, "r");
> dout = fopen(output_file, "w");
> ...
> while ((c = read(fileno(fin), buf, sizeof (buf))) > 0)
> for (bufp = buf; c > 0; c -= d, bufp += d)
> if ((d = write(fileno(dout), bufp, c)) <= 0)
> break;
I'd say this program has a bug. Why would anybody use `fopen' to open
a file, and then read it with `read' rather than `fread'?
> Nevertheless is this behaviour correct? Couldn't we expect file mode
> changes on FILE *f to be automatically applied to fileno(f)?
I don't know if there's something to expect here, as `fopen' and
`read' are largely unrelated. Obviously, ANSI doesn't even know about
`read'.
DJ, does Posix say anything about O_BINARY in `open', or whether "rb"
should imply the underlying handle is open in binary mode?
- Raw text -