From d9d71657bddce08c4686c41cf2ea00b344bd47b6 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 18 Nov 2002 21:03:52 +0100 Subject: [PATCH] PR libstdc++/6745 (continued) 2002-11-18 Paolo Carlini 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 | 7 +++++++ libstdc++-v3/include/bits/streambuf.tcc | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 302f582f5e2..7934d74d515 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2002-11-18 Paolo Carlini + + 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 * config/linker-map.gnu: Export _S_construct even if size_t is diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc index c8084ee68ad..cdaab2e213b 100644 --- a/libstdc++-v3/include/bits/streambuf.tcc +++ b/libstdc++-v3/include/bits/streambuf.tcc @@ -37,6 +37,10 @@ #pragma GCC system_header +#ifdef _GLIBCPP_HAVE_UNISTD_H +#include +#endif + namespace std { template @@ -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(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) -- 2.30.2