[v3] Fix second half of libstdc++/6745

Paolo Carlini pcarlini@unitus.it
Wed Nov 20 06:13:00 GMT 2002


Hi Benjamin and Jonathan and everyone!

>>A potentially much simpler solution occured to me.  Could we declare that
>>Paolo's original patch (the one that started this thread) only applies to
>>cin?  I.e., make the condition this:
>>   if (__sbin == cin->rdbuf() && isatty(0))
>>    
>>
>Hey y'all. I think a better way to think about this is that the
>streambuf is unbuffered. That way you don't have to deal with the isatty
>issue. (For unbuffered streams, _M_buf_size_opt == 0)
>
>If you do the checks based on that I think it will be cleaner.
>
Interesting, thanks.
I'm planning to work harder on this, following Jonathan ideas, in the 
next few days.

However I can already confirm that the idea basically *works*! I mean, a 
gross implementation
using reinterpret_cast<basic_streambuf<char/wchar_t>* > to compare 
__sbin to cin and wcin
(then or-ing the two) leads to to the efficient use of BUFSIZ in the 
safe situations: for instance,
Matt Austern testcase (that attached to 8071) runs about 3 time faster 
than with current mainline!

In my first quick attempts at coding Jonathan's nice ideas about 
__streambuf_is_stdin_and_tty
I had some troubles with redefinition errors at link time. I tried to 
follow closely the strategy
currently used for __copy_streambufs but without success, dunno why...
(I must admit that I don't know well the "extern template" extension...)

Ciao for now, Paolo.



More information about the Libstdc++ mailing list