streambuf.tcc (basic_streambuf::xsgetn): Fix uflow case.
authorVadim Egorov <egorovv@mailandnews.com>
Tue, 9 May 2000 07:19:14 +0000 (07:19 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Tue, 9 May 2000 07:19:14 +0000 (07:19 +0000)
2000-05-09  Vadim Egorov  <egorovv@mailandnews.com>
    Benjamin Kosnik  <bkoz@gnu.org>
    Nathan Myers  <ncm@cantrip.org>
    Dietmar Kuehl  <dietmar_kuehl@yahoo.com>

        * bits/streambuf.tcc (basic_streambuf::xsgetn): Fix uflow case.
(basic_streambuf::xsputn): Make consistent.
* testsuite/27_io/filebuf.cc: Add tests.

Co-Authored-By: Benjamin Kosnik <bkoz@gnu.org>
Co-Authored-By: Dietmar Kuehl <dietmar_kuehl@yahoo.com>
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r33794

libstdc++-v3/ChangeLog
libstdc++-v3/bits/streambuf.tcc
libstdc++-v3/testsuite/27_io/filebuf.cc

index 5980f69..9bc1845 100644 (file)
@@ -1,3 +1,12 @@
+2000-05-03  Vadim Egorov  <egorovv@mailandnews.com>
+           Benjamin Kosnik  <bkoz@gnu.org>
+           Nathan Myers  <ncm@cantrip.org>
+           Dietmar Kuehl  <dietmar_kuehl@yahoo.com> 
+
+        * bits/streambuf.tcc (basic_streambuf::xsgetn): Fix uflow case.
+       (basic_streambuf::xsputn): Make consistent.
+       * testsuite/27_io/filebuf.cc: Add tests.
+       
 2000-05-08  Steven King  <sxking@uswest.net>
 
         * bits/char_traits.h: use wchar_t utility functions for
index 8aeb421..45eb332 100644 (file)
@@ -1,6 +1,6 @@
 // Stream buffer classes -*- C++ -*-
 
-// Copyright (C) 1997-1999 Free Software Foundation, Inc.
+// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -145,10 +145,12 @@ namespace std {
              
              if (__retval != __n)
                {
-                 if (this->uflow() != traits_type::eof())
-                   ++__retval;
-                 else
-                   break;
+                 int_type __c = this->uflow();  
+                 if (traits_type::eq_int_type(__c, traits_type::eof()))
+                    break;
+
+                 traits_type::assign(*__s++, traits_type::to_char_type(__c));
+                  ++__retval;
                }
            }
        }
@@ -175,9 +177,9 @@ namespace std {
              bool __testout = _M_mode & ios_base::out;
              if (!(__testput && __testout))
                {
-                 char_type __c = *__s;
-                 char_type __overfc = this->overflow(__c);
-                 if (__c == __overfc)
+                 int_type __c = traits_type::to_int_type(*__s);
+                 int_type __overfc = this->overflow(__c);
+                 if (traits_type::eq_int_type(__c, __overfc))
                    {
                      ++__retval;
                      ++__s;
index 586388e..40e6cc6 100644 (file)
@@ -503,12 +503,31 @@ bool test03() {
   return test;
 }
 
+bool test04()
+{
+  using namespace std;
+  typedef istream::int_type    int_type;
+
+  bool test = true;
+  ifstream ifs(name_02);
+  char buffer[] = "xxxxxxxxxx";
+  int_type len1 = ifs.rdbuf()->sgetn(buffer, sizeof(buffer));
+  test &= len1 == sizeof(buffer);
+  test &= buffer[0] == 'a';
 
-int main() {
+#ifdef DEBUG_ASSERT
+  assert(test);
+#endif
+  return test;
+}
+
+int main() 
+{
   test00();
   test01();
   test02();
   test03();
+  test04();
 
   return 0;
 }