This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] libstdc++/20806 or read syscall changing \r\n to \n on mingw


Hi,

I'm trying to help the mingw32 people with this issue, which affects
istream::read. The problem is that the underlying filebuf::xsgetn
implements (since 3.4) the optimization of issuing a single
_M_file.xsgetn, which copies directly into the destination buffer: on
mingw32, the underlying read syscall, for files opened in char mode (not
binary mode), strips \r from sequences \r\n and therefore, short reads
are produced when, in fact, eof is *not* reached.

A first possibility is disabling completely the optimization when the
open mode is not binary, but this is the common case and the
optimization becomes *much* less useful on anything != mingw32

Another one, special casing mingw32.

A third one, taking somewhow into account in _M_file.xsgetn the
possibility of short reads, but this is not at all trivial, because with
pipes/fifos, after a first short read, the next ones *block*, and we
obtain regressions for time-out in the testsuite if we try just using a
loop :(

What do people think? I'm not sure we can do something really clean
right now, so close to the release of 4.0, but frankly I'm unsure about
the best fix generally.

Paolo.


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