PR libstdc++/6745 (continued)
authorPaolo Carlini <pcarlini@unitus.it>
Mon, 18 Nov 2002 20:03:52 +0000 (21:03 +0100)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 18 Nov 2002 20:03:52 +0000 (20:03 +0000)
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.

From-SVN: r59229

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/streambuf.tcc

index 302f582f5e2b0af92c21d0a6a925c3b50e253938..7934d74d5150e7519acb83a674406dc176f19444 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2002-11-17  Jakub Jelinek  <jakub@redhat.com>
 
        * config/linker-map.gnu: Export _S_construct even if size_t is
index c8084ee68ada3c6ea95e95d1fa908c589fb9a287..cdaab2e213bf92285095e479cdb79af1f80f0139 100644 (file)
 
 #pragma GCC system_header
 
+#ifdef _GLIBCPP_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 namespace std 
 {
   template<typename _CharT, typename _Traits>
@@ -219,8 +223,14 @@ namespace std
                }
              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)