OSDN Git Service

2002-11-18 Paolo Carlini <pcarlini@unitus.it>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Nov 2002 20:03:52 +0000 (20:03 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Nov 2002 20:03:52 +0000 (20:03 +0000)
PR libstdc++/6745 (continued)
* include/bits/streambuf.tcc (__copy_streambufs):
Deal with interactive input by using isatty as in the
fix for libstdc++/8399.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59229 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 302f582..7934d74 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 c8084ee..cdaab2e 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)