[PATCH] Support stateful encodings in basic_filebuf

Pétur Runólfsson peturr02@ru.is
Tue Nov 4 08:42:00 GMT 2003


Benjamin Kosnik wrote:
> Nice work. Two small comments:
> 
> >1) Call codecvt::unshift() from close(), seekoff and seekpos iff
> >   _M_writing is true. Note that this is not what the standard says,
> >   but it has the benefit that the written file can actually be read
> >   again.
> 
> This is the only part of the patch that I'm a bit uneasy about, and thus
> by extension:

I don't think the description in the standard about stateful encodings
is meant to be read literally, it's a general description of what should
be done (for example, it never says that pos_type::state() should be
called).
 
> >	* testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc,
> >	* testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc:
> >	Check that sync does *not* set _M_writing to false.
>
> I believe, however, that this still leaves ostream::flush with behavior
> that is within the expected constraints.

Note that previously, sync() only set _M_writing to false if there
was something in the output buffer. Making it consistent seems an
obvious improvement.
 
> If possible, we really need written documentation for this kind
> functionality at some point (the same can be said about other large
> parts of the library, however....)

Yep :-)

Petur



More information about the Libstdc++ mailing list