This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Fix second half of libstdc++/6745
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 18 Nov 2002 21:08:47 +0100
- Subject: [v3] Fix second half of libstdc++/6745
Hi,
the below, tested x86-linux, approved by Benjamin, fixes the
interactive part of the PR.
Ciao, Paolo.
///////////
2002-11-18 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/6745 (continued)
* include/bits/streambuf.tcc (__copy_streambufs):
Deal with interactive input by using isatty as in the
fix for libstdc++/8399.
diff -urN libstdc++-v3-orig/include/bits/streambuf.tcc libstdc++-v3/include/bits/streambuf.tcc
--- libstdc++-v3-orig/include/bits/streambuf.tcc 2002-11-01 18:30:35.000000000 +0100
+++ libstdc++-v3/include/bits/streambuf.tcc 2002-11-17 20:51:40.000000000 +0100
@@ -37,6 +37,10 @@
#pragma GCC system_header
+#ifdef _GLIBCPP_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
namespace std
{
template<typename _CharT, typename _Traits>
@@ -219,8 +223,14 @@
}
else
{
- _CharT __buf[256];
- streamsize __charsread = __sbin->sgetn(__buf, sizeof(__buf));
+#ifdef _GLIBCPP_HAVE_ISATTY
+ size_t __size = isatty(0) ? 1 : static_cast<size_t>(BUFSIZ);
+#else
+ size_t __size = 1;
+#endif
+ _CharT* __buf =
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __size));
+ streamsize __charsread = __sbin->sgetn(__buf, __size);
__xtrct = __sbout->sputn(__buf, __charsread);
__ret += __xtrct;
if (__xtrct != __charsread)