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]

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():

int underflow();
wint_t 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.

I agree.

Petur


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