This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write


Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:

|> Looking at the appended bug report, I guess we should check for
|> if (fp->_flags & _IO_NO_WRITES)
|> 
|> in the fread implementation.  But what's the right place and who
|> exactly should we change it?

I cannot find anything in the standard that requires setting the error
indicator when writing to a read-only stream or reading from a write-only
stream.  Currently we only check _IO_NO_{READS,WRITES} in the underflow
and overflow methods, so that getc/putc will fail (but getc doesn't set
the error indicator yet; I'm fixing that).  Neither xsgetn nor xsputn do
any explicit checking, so they will fail only if the underlying descriptor
is truely write-only or read-only, resp. (but the standard descriptors are
read/write).

Andreas.

-- 
Andreas Schwab                                  "And now for something
schwab@suse.de                                   completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]