Commit d7ccc917 by Paolo Carlini Committed by Paolo Carlini

std_fstream.h (_S_pback_size): Remove definition.

2003-05-22  Paolo Carlini  <pcarlini@unitus.it>

	* 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.

From-SVN: r67102
parent 5f875c8f
2003-05-22 Paolo Carlini <pcarlini@unitus.it> 2003-05-22 Paolo Carlini <pcarlini@unitus.it>
* 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 <pcarlini@unitus.it>
* include/bits/fstream.tcc (_M_underflow): Simplify:
!__testout implies _M_filepos == _M_in_end, therefore !__testout implies _M_filepos == _M_in_end, therefore
the first _M_file.seekoff call is never issued. the first _M_file.seekoff call is never issued.
......
...@@ -40,10 +40,6 @@ ...@@ -40,10 +40,6 @@
namespace std namespace std
{ {
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
const size_t
basic_filebuf<_CharT, _Traits>::_S_pback_size;
template<typename _CharT, typename _Traits>
void void
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
_M_allocate_internal_buffer() _M_allocate_internal_buffer()
......
...@@ -158,8 +158,7 @@ namespace std ...@@ -158,8 +158,7 @@ namespace std
* @note pbacks of over one character are not currently supported. * @note pbacks of over one character are not currently supported.
* @endif * @endif
*/ */
static const size_t _S_pback_size = 1; char_type _M_pback[1];
char_type _M_pback[_S_pback_size];
char_type* _M_pback_cur_save; char_type* _M_pback_cur_save;
char_type* _M_pback_end_save; char_type* _M_pback_end_save;
bool _M_pback_init; bool _M_pback_init;
...@@ -176,12 +175,9 @@ namespace std ...@@ -176,12 +175,9 @@ namespace std
{ {
if (!_M_pback_init) 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_cur_save = this->_M_in_cur;
_M_pback_end_save = this->_M_in_end; _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; _M_pback_init = true;
} }
} }
...@@ -195,17 +191,9 @@ namespace std ...@@ -195,17 +191,9 @@ namespace std
if (_M_pback_init) if (_M_pback_init)
{ {
// Length _M_in_cur moved in the pback buffer. // Length _M_in_cur moved in the pback buffer.
size_t __off_cur = this->_M_in_cur - _M_pback; const 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;
this->setg(this->_M_buf, _M_pback_cur_save + __off_cur, 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; _M_pback_init = false;
} }
} }
......
...@@ -127,13 +127,6 @@ void test07() ...@@ -127,13 +127,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
...@@ -129,13 +129,6 @@ void test07() ...@@ -129,13 +129,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
...@@ -129,13 +129,6 @@ void test07() ...@@ -129,13 +129,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
...@@ -63,13 +63,6 @@ void test01() ...@@ -63,13 +63,6 @@ void test01()
VERIFY( fb.sgetc() == MyTraits::eof() ); VERIFY( fb.sgetc() == MyTraits::eof() );
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<char, MyTraits>::int_type
std::basic_filebuf<char, MyTraits>::_S_pback_size;
#endif
int main() int main()
{ {
test01(); test01();
......
...@@ -131,13 +131,6 @@ void test07() ...@@ -131,13 +131,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
...@@ -131,13 +131,6 @@ void test07() ...@@ -131,13 +131,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
...@@ -180,10 +180,6 @@ template ...@@ -180,10 +180,6 @@ template
template template
unsigned char unsigned char
std::basic_string<unsigned char>::_Rep::_S_terminal; std::basic_string<unsigned char>::_Rep::_S_terminal;
template
std::basic_filebuf<unsigned char>::int_type
std::basic_filebuf<unsigned char>::_S_pback_size;
#endif #endif
int main() int main()
......
...@@ -131,13 +131,6 @@ void test07() ...@@ -131,13 +131,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
...@@ -151,10 +151,6 @@ template ...@@ -151,10 +151,6 @@ template
template template
unsigned char unsigned char
std::basic_string<unsigned char>::_Rep::_S_terminal; std::basic_string<unsigned char>::_Rep::_S_terminal;
template
std::basic_filebuf<unsigned char>::int_type
std::basic_filebuf<unsigned char>::_S_pback_size;
#endif #endif
int main() int main()
......
...@@ -129,13 +129,6 @@ void test07() ...@@ -129,13 +129,6 @@ void test07()
} }
} }
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_filebuf<gnu_char_type>::int_type
std::basic_filebuf<gnu_char_type>::_S_pback_size;
#endif
int main() int main()
{ {
test07(); test07();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment