This is the mail archive of the
mailing list for the libstdc++ project.
RE: [Patch/RFC] Fix libstdc++/9533
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Nathan Myers" <ncm-nospam at cantrip dot org>,<libstdc++ at gcc dot gnu dot org>
- Date: Fri, 21 Mar 2003 12:35:44 -0000
- Subject: RE: [Patch/RFC] Fix libstdc++/9533
> > Consider this fragment from 27.3:
> > Mixing operations on corresponding wide- and narrow-character
> > streams follows the same semantics as mixing such operations
> > on FILEs, as specified in Amendment 1 of the ISO C standard.
> I agree. I think that, after sync_with_stdio(false) has been called,
> the only conforming buffered streambuf possible is an object derived
> from both basic_streambuf<char> and basic_streambuf<wchar_t>.
That requires overloading on return type for underflow():
but I agree that some shared state is needed.
> When the last operation done is through the char interface,
> the buffer pointers for the wchar_t interface are set all equal,
> so that when a wide character operation is attempted, underflow
> can re-interpret the raw input according to the current locale.
stdio doesn't work like that on my system (glibc 2.3). Instead
getc(stdin) returns EOF if fwide(stdin, 0) > 0 and getwc(stdin)
returns WEOF if fwide(stdin, 0) < 0. (I don't have access to
amendment 1, so I'm not sure what's correct here.)
> This is pretty simple to implement, particularly since we don't
> have support seeking or output. (Putback is a bit tricky.)
The current implementation supports seeking when stdin is
redirected or file descriptor 0 is replaced with dup2.
> There's no particular reason to want to use filebuf for cin or
> cout, aside from a commendable laziness.