aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Egorov <egorovv@mailandnews.com>2000-05-09 07:19:14 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2000-05-09 07:19:14 +0000
commitc0b84d79d2533597dcce00eaddc0652aecf9fe87 (patch)
tree680d5729f6fb38d313b6e014e2964216f72074de
parent6b6c1201e6e9a1ff43c6871810881a1776c99c0c (diff)
downloadgcc-c0b84d79d2533597dcce00eaddc0652aecf9fe87.zip
gcc-c0b84d79d2533597dcce00eaddc0652aecf9fe87.tar.gz
gcc-c0b84d79d2533597dcce00eaddc0652aecf9fe87.tar.bz2
streambuf.tcc (basic_streambuf::xsgetn): Fix uflow case.
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
-rw-r--r--libstdc++-v3/ChangeLog9
-rw-r--r--libstdc++-v3/bits/streambuf.tcc18
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf.cc21
3 files changed, 39 insertions, 9 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 5980f69..9bc1845 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/bits/streambuf.tcc b/libstdc++-v3/bits/streambuf.tcc
index 8aeb421..45eb332 100644
--- a/libstdc++-v3/bits/streambuf.tcc
+++ b/libstdc++-v3/bits/streambuf.tcc
@@ -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;
diff --git a/libstdc++-v3/testsuite/27_io/filebuf.cc b/libstdc++-v3/testsuite/27_io/filebuf.cc
index 586388e..40e6cc6 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf.cc
@@ -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;
}