2002-05-03 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 May 2002 18:22:58 +0000 (18:22 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 May 2002 18:22:58 +0000 (18:22 +0000)
PR libstdc++/6549.
* include/bits/fstream.tcc (filebuf::_M_underflow_common): Revert.
* testsuite/27_io/narrow_stream_objects.cc (test07): Add.

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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc

index b3da14e..cb6dfa9 100644 (file)
@@ -1,3 +1,9 @@
+2002-05-03  Benjamin Kosnik  <bkoz@redhat.com>
+
+       PR libstdc++/6549.
+       * include/bits/fstream.tcc (filebuf::_M_underflow_common): Revert.
+       * testsuite/27_io/narrow_stream_objects.cc (test07): Add.
+       
 2002-05-03  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * config/os/irix/irix5.2/bits/ctype_noninline.h (classic_table):
index 40b9f32..90850f5 100644 (file)
@@ -182,21 +182,6 @@ namespace std
                return traits_type::to_int_type(*_M_in_cur);
            }
 
-         // Check for unbuffered stream.
-         if (_M_buf_size == 1)
-           {
-             int_type __c = _M_file.sys_getc();
-             if (__c != __ret)
-               {
-                 __ret = __c;
-                 *_M_in_cur = traits_type::to_char_type(__c);
-                 _M_set_determinate(1);
-                 if (__testout)
-                   _M_out_cur = _M_in_cur;
-               }
-             return __ret;
-           }
-
          // Sync internal and external buffers.
          // NB: __testget -> __testput as _M_buf_unified here.
          bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
@@ -251,6 +236,14 @@ namespace std
                  __ret = traits_type::to_int_type(*_M_in_cur);
                  if (__bump)
                    _M_in_cur_move(1);
+                 else if (_M_buf_size == 1)
+                   {
+                     // If we are synced with stdio, we have to unget the
+                     // character we just read so that the file pointer
+                     // doesn't move.
+                     _M_file.sys_ungetc(*_M_in_cur);
+                     _M_set_indeterminate();
+                   }
                }          
            }
        }
index 27291be..016a982 100644 (file)
@@ -165,6 +165,16 @@ void test06()
     cerr << "i == " << i << endl;
 }
 
+// libstdc++/6548
+void test07()
+{
+  bool test = true;
+  std::cout << "Please, enter 'test':";
+  std::string s;
+  std::getline(std::cin, s, '\n');
+  VERIFY( s == "test" );
+}
+
 int 
 main()
 {
@@ -175,5 +185,6 @@ main()
   // test04();
   // test05();
   // test06();
+  // test07();
   return 0;
 }