diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 29f972cbb2e..28cee922693 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,6 +1,24 @@ 2003-05-22 Paolo Carlini - * include/bits/fstream.tcc (_M_underflow): simplify: + * include/std/std_fstream.h (_S_pback_size): Remove definition. + (_M_create_pback(), _M_destroy_pback()): Simplify for a single-char + pback buffer. + * include/bits/fstream.tcc (_S_pback_size): Remove declaration. + * testsuite/27_io/basic_filebuf/3.cc: Remove explicit instantiation + of _S_pback_size for systems with no COMDAT or weak support. + * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc: Likewise. + * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc: Likewise. + * testsuite/27_io/basic_filebuf/underflow/10096.cc: Likewise. + * testsuite/27_io/basic_fstream/3.cc: Likewise. + * testsuite/27_io/basic_ifstream/3.cc: Likewise. + * testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc: Likewise. + * testsuite/27_io/basic_ofstream/3.cc: Likewise. + * testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc: Likewise. + * testsuite/27_io/basic_streambuf/3.cc: Likewise. + +2003-05-22 Paolo Carlini + + * include/bits/fstream.tcc (_M_underflow): Simplify: !__testout implies _M_filepos == _M_in_end, therefore the first _M_file.seekoff call is never issued. diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 0aa93fef7bb..cda0bacd9f9 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -39,10 +39,6 @@ namespace std { - template - const size_t - basic_filebuf<_CharT, _Traits>::_S_pback_size; - template void basic_filebuf<_CharT, _Traits>:: diff --git a/libstdc++-v3/include/std/std_fstream.h b/libstdc++-v3/include/std/std_fstream.h index 24c9f7fc6db..27794881c75 100644 --- a/libstdc++-v3/include/std/std_fstream.h +++ b/libstdc++-v3/include/std/std_fstream.h @@ -158,8 +158,7 @@ namespace std * @note pbacks of over one character are not currently supported. * @endif */ - static const size_t _S_pback_size = 1; - char_type _M_pback[_S_pback_size]; + char_type _M_pback[1]; char_type* _M_pback_cur_save; char_type* _M_pback_end_save; bool _M_pback_init; @@ -176,12 +175,9 @@ namespace std { if (!_M_pback_init) { - size_t __dist = this->_M_in_end - this->_M_in_cur; - size_t __len = std::min(_S_pback_size, __dist); - traits_type::copy(_M_pback, this->_M_in_cur, __len); _M_pback_cur_save = this->_M_in_cur; _M_pback_end_save = this->_M_in_end; - this->setg(_M_pback, _M_pback, _M_pback + __len); + this->setg(_M_pback, _M_pback, _M_pback + 1); _M_pback_init = true; } } @@ -195,17 +191,9 @@ namespace std if (_M_pback_init) { // Length _M_in_cur moved in the pback buffer. - size_t __off_cur = this->_M_in_cur - _M_pback; - - // For in | out buffers, the end can be pushed back... - size_t __off_end = 0; - size_t __pback_len = this->_M_in_end - _M_pback; - size_t __save_len = _M_pback_end_save - this->_M_buf; - if (__pback_len > __save_len) - __off_end = __pback_len - __save_len; - + const size_t __off_cur = this->_M_in_cur - _M_pback; this->setg(this->_M_buf, _M_pback_cur_save + __off_cur, - _M_pback_end_save + __off_end); + _M_pback_end_save); _M_pback_init = false; } } diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc index ddec01c02e3..54cfba150bd 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc @@ -127,13 +127,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07(); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc index e1628c4a884..a391d22fc03 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc @@ -129,13 +129,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07(); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc index 0f1ee2e1d61..02f7b67047c 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc @@ -129,13 +129,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07(); diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc index 588a625e475..8dd24343f2e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc @@ -63,13 +63,6 @@ void test01() VERIFY( fb.sgetc() == MyTraits::eof() ); } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test01(); diff --git a/libstdc++-v3/testsuite/27_io/basic_fstream/3.cc b/libstdc++-v3/testsuite/27_io/basic_fstream/3.cc index 216e9a26216..4f78ed0d193 100644 --- a/libstdc++-v3/testsuite/27_io/basic_fstream/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_fstream/3.cc @@ -131,13 +131,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07(); diff --git a/libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc b/libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc index 9de0c62a019..dd38b252c65 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc @@ -131,13 +131,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07(); diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc index c70275745ce..99dd0b09bc1 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc @@ -180,10 +180,6 @@ template template unsigned char std::basic_string::_Rep::_S_terminal; - -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; #endif int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc index 5149ecd5580..3bba780a4c6 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc @@ -131,13 +131,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07(); diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc index a38bddc162b..3cdf3b83310 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc @@ -151,10 +151,6 @@ template template unsigned char std::basic_string::_Rep::_S_terminal; - -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; #endif int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc index 36e5290540d..c599985d43f 100644 --- a/libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc @@ -129,13 +129,6 @@ void test07() } } -#if !__GXX_WEAK__ -// Explicitly instantiate for systems with no COMDAT or weak support. -template - std::basic_filebuf::int_type - std::basic_filebuf::_S_pback_size; -#endif - int main() { test07();