bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no new modules 'freading', 'fwriting'


From: Bruno Haible
Subject: Re: no new modules 'freading', 'fwriting'
Date: Fri, 27 Apr 2007 12:52:19 +0200
User-agent: KMail/1.5.4

Hi Eric,

> > I got these working reasonably only on glibc. Portability problems occurred
> > on Solaris, OSF/1, AIX, MacOS X, IRIX, HP-UX. If someone wants to continue,
> > here's the code.
> 
> What sort of problems?

Many ASSERTs of the unit tests failed. On some stdio implementations, there
is simply apparently no way to reliably detect whether the last operation -
excluding fflush - was reading, or was writing, or there was none (i.e.
the stream is in its initial state).

> I got it the tests to work on both cygwin and mingw as follows
> ...
> Also, on mingw, freading reports false
> after fseek, and flush reports false after fflush, but I think both of
> these conditions are okay.  In other words, the functionality of freading
> is not so much to determine whether the last operation was a read, but to
> determine whether a reposition must take place before attempting a write
> to avoid undefined behavior.

Well, you removed half of the ASSERTs from the unit tests. Could you please
also update the specification in freading.h and fwriting.h, stating the new
meaning of these functions? So that it becomes clear
  - what is meant by "last operation",
  - what is the result when the stream is in its initial state,
  - under which conditions the result of freadable() and fwritable() is
    undefined.

Also, the freading test fails on glibc systems:

                      BEFORE                 WITH FREADING

glibc 2.3.6           OK                     test-freading fails
MacOS X 10.3.9        OK                     OK
Solaris 9             OK                     OK
Solaris 9, 64-bit     OK                     OK
AIX 5.1               OK                     OK
IRIX 6.5              OK                     OK
HP-UX 11              OK                     OK
OSF/1 4.0d            OK                     OK
OSF/1 5.1a            OK                     OK
mingw                 test-fflush fails      OK

> I just deleted the use of fflush after reading in your
> tests, as that is not portable without the fflush module (which still
> doesn't work on at least mingw).

Can you add them back now? The test-freadable and test-fwritable also use
fflush, and the broken mingw fflush caused these tests to misbehave. But
the fixed fflush now makes them work also on mingw.

> Maybe it is worth changing the specification comments to state that it is
> possible for both freading and fwriting to be false (only if the file is
> read-write; and the last action was open, reposition (fseek, fsetpos, or
> rewind), EOF on reading, or fflush on writing, since those are the actions
> that must occur on transition between read and write according to POSIX),
> but that it is never possible to have both freading and fwriting true at
> once.

Yes, please make the comments as precise as possible.

> I'm checking this in now, since I needed it to fix fflush on mingw (see
> next email).  I assume you'll help me fix any fallout if I (re-)break
> fflush on MacOS.

MacOS X is fine this time :-)

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]