summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-21 00:06:51 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-21 00:06:51 +0000
commit227be4e17be4bedb1f5317c98edcbf0a295566d6 (patch)
tree86a931a543012a803c455f39850cd161f1c52185
parent6175855a7a6d797606cc41935d3e202d442f085a (diff)
downloadppe42-gcc-227be4e17be4bedb1f5317c98edcbf0a295566d6.tar.gz
ppe42-gcc-227be4e17be4bedb1f5317c98edcbf0a295566d6.zip
2000-07-20 Benjamin Kosnik <bkoz@cygnus.com>
* bits/std_streambuf.h: Add bits for pback buffers here, so that in_avail, etc can use them. * bits/std_fstream.h: Ditto. * bits/fstream.tcc: Ditto. * testsuite/27_io/filebuf.cc: Tweaks. * testsuite/27_io/filebuf-3.tst: Correct for pbackfail bits. 2000-07-19 Benjamin Kosnik <bkoz@cygnus.com> * src/localename.cc: Same. * src/locale.cc: Same. * bits/localefwd.h: _M_init_facet to _M_facet_init. * bits/locale_facets.h: _M_init_boolnames to _M_boolnames_init. * bits/std_sstream.h: Change _M_init_stringbuf to _M_stringbuf_init. * bits/fstream.tcc: Change _M_init_filebuf to _M_filebuf_init. * bits/std_fstream.h: Same. * bits/basic_string.h: Tweaks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35157 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog24
-rw-r--r--libstdc++-v3/bits/basic_string.h4
-rw-r--r--libstdc++-v3/bits/fstream.tcc219
-rw-r--r--libstdc++-v3/bits/locale_facets.h6
-rw-r--r--libstdc++-v3/bits/localefwd.h2
-rw-r--r--libstdc++-v3/bits/std_fstream.h57
-rw-r--r--libstdc++-v3/bits/std_sstream.h8
-rw-r--r--libstdc++-v3/bits/std_streambuf.h84
-rw-r--r--libstdc++-v3/src/locale.cc52
-rw-r--r--libstdc++-v3/src/localename.cc36
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf-3.tst2
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf.cc2
12 files changed, 302 insertions, 194 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 6f6b8126209..d2e2e536c63 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,27 @@
+2000-07-20 Benjamin Kosnik <bkoz@cygnus.com>
+
+ * bits/std_streambuf.h: Add bits for pback buffers here, so that
+ in_avail, etc can use them.
+ * bits/std_fstream.h: Ditto.
+ * bits/fstream.tcc: Ditto.
+ * testsuite/27_io/filebuf.cc: Tweaks.
+ * testsuite/27_io/filebuf-3.tst: Correct for pbackfail bits.
+
+2000-07-19 Benjamin Kosnik <bkoz@cygnus.com>
+
+ * src/localename.cc: Same.
+ * src/locale.cc: Same.
+ * bits/localefwd.h: _M_init_facet to _M_facet_init.
+
+ * bits/locale_facets.h: _M_init_boolnames to _M_boolnames_init.
+
+ * bits/std_sstream.h: Change _M_init_stringbuf to _M_stringbuf_init.
+
+ * bits/fstream.tcc: Change _M_init_filebuf to _M_filebuf_init.
+ * bits/std_fstream.h: Same.
+
+ * bits/basic_string.h: Tweaks.
+
2000-07-19 Phil Edwards <pme@sourceware.cygnus.com>
* docs/18_support/howto.html: Update.
diff --git a/libstdc++-v3/bits/basic_string.h b/libstdc++-v3/bits/basic_string.h
index 99401e6053f..0d21c2d9a2f 100644
--- a/libstdc++-v3/bits/basic_string.h
+++ b/libstdc++-v3/bits/basic_string.h
@@ -221,11 +221,11 @@ namespace std {
// Data Members (public):
// NB: This is an unsigned type, and thus represents the maximum
// size that the allocator can hold.
- static const size_type npos = static_cast<size_type>(-1);
+ static const size_type npos = static_cast<size_type>(-1);
private:
// Data Members (private):
- mutable _Alloc_hider _M_dataplus;
+ mutable _Alloc_hider _M_dataplus;
// The following storage is init'd to 0 by the linker, resulting
// (carefully) in an empty string with one reference.
diff --git a/libstdc++-v3/bits/fstream.tcc b/libstdc++-v3/bits/fstream.tcc
index 556c110bbe0..7f334524458 100644
--- a/libstdc++-v3/bits/fstream.tcc
+++ b/libstdc++-v3/bits/fstream.tcc
@@ -39,7 +39,7 @@ namespace std
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
- _M_init_filebuf(void)
+ _M_filebuf_init()
{
_M_buf_unified = true; // Tie input to output for basic_filebuf.
_M_buf_size = _M_buf_size_opt;
@@ -50,6 +50,30 @@ namespace std
delete _M_file;
throw;
}
+ }
+
+ template<typename _CharT, typename _Traits>
+ void
+ basic_filebuf<_CharT, _Traits>::
+ _M_allocate_buffers()
+ {
+ // Allocate internal buffer.
+ try {
+ _M_buf = new char_type[_M_buf_size];
+ }
+ catch(...) {
+ delete [] _M_buf;
+ throw;
+ }
+
+ // Allocate pback buffer.
+ try {
+ _M_pback = new char_type[_M_pback_size];
+ }
+ catch(...) {
+ delete [] _M_pback;
+ throw;
+ }
}
template<typename _CharT, typename _Traits>
@@ -66,24 +90,18 @@ namespace std
_M_last_overflowed(false)
{
_M_fcvt = &use_facet<__codecvt_type>(this->getloc());
- _M_init_filebuf();
+ _M_filebuf_init();
_M_file->sys_open(__fd, __mode);
if (this->is_open() && _M_buf_size)
{
+ _M_allocate_buffers();
_M_mode = __mode;
+
// XXX So that istream::getc() will only need to get 1 char,
// as opposed to BUF_SIZE.
if (__fd == 0)
_M_buf_size = 1;
- try {
- _M_buf = new char_type[_M_buf_size];
- }
- catch(...) {
- delete [] _M_buf;
- throw;
- }
-
this->_M_set_indeterminate();
}
}
@@ -96,19 +114,12 @@ namespace std
__filebuf_type *__retval = NULL;
if (!this->is_open())
{
- _M_init_filebuf();
+ _M_filebuf_init();
_M_file->open(__s, __mode);
if (this->is_open() && _M_buf_size)
{
+ _M_allocate_buffers();
_M_mode = __mode;
-
- try {
- _M_buf = new char_type[_M_buf_size];
- }
- catch(...) {
- delete [] _M_buf;
- throw;
- }
// For time being, set both (in/out) sets of pointers.
_M_set_indeterminate();
@@ -132,7 +143,10 @@ namespace std
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
if (__testput)
_M_really_overflow(traits_type::eof());
-
+
+ // NB: Do this here so that re-opened filebufs will be cool...
+ _M_pback_destroy();
+
#if 0
// XXX not done
if (_M_last_overflowed)
@@ -142,18 +156,23 @@ namespace std
}
#endif
- if (_M_file)
- {
- delete _M_file;
- _M_file = NULL;
- _M_mode = ios_base::openmode(0);
- if (_M_buf_size)
- delete [] _M_buf;
- _M_buf = NULL;
- this->setg(NULL, NULL, NULL);
- this->setp(NULL, NULL);
- __retval = this;
- }
+ _M_mode = ios_base::openmode(0);
+ if (_M_buf_size)
+ delete [] _M_buf;
+ _M_buf = NULL;
+ delete [] _M_pback;
+ _M_pback = NULL;
+ this->setg(NULL, NULL, NULL);
+ this->setp(NULL, NULL);
+ __retval = this;
+ }
+
+ // Can actually allocate this file as part of an open and never
+ // have it be opened.....
+ if (_M_file)
+ {
+ delete _M_file;
+ _M_file = NULL;
}
_M_last_overflowed = false;
return __retval;
@@ -173,7 +192,7 @@ namespace std
if (_M_in_cur >= _M_in_end)
__testeof = this->underflow() == traits_type::eof();
if (!__testeof)
- __retval = (_M_in_end - _M_in_cur) / sizeof(char_type);
+ __retval = _M_in_end - _M_in_cur;
}
_M_last_overflowed = false;
return __retval;
@@ -185,13 +204,24 @@ namespace std
underflow()
{
int_type __retval = traits_type::eof();
- bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
- bool __testinit = _M_is_indeterminate();
- bool __testout = _M_mode & ios_base::out;
bool __testin = _M_mode & ios_base::in;
if (__testin)
{
+ // Check for pback madness, and if so swich back to the
+ // normal buffers and jet outta here before expensive
+ // fileops happen...
+ if (_M_pback_init)
+ {
+ _M_pback_destroy();
+ if (_M_in_cur < _M_in_end)
+ return traits_type::to_int_type(*_M_in_cur);
+ }
+
+ bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
+ bool __testinit = _M_is_indeterminate();
+ bool __testout = _M_mode & ios_base::out;
+
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
if (__testget)
@@ -260,56 +290,63 @@ namespace std
pbackfail(int_type __i)
{
int_type __retval = traits_type::eof();
- char_type __c = traits_type::to_char_type(__i);
- bool __testeof = traits_type::eq_int_type(__i, traits_type::eof());
- bool __testout = _M_mode & ios_base::out;
bool __testin = _M_mode & ios_base::in;
if (__testin)
{
- if (!_M_is_indeterminate())
+ bool __testpb = _M_in_beg < _M_in_cur;
+ char_type __c = traits_type::to_char_type(__i);
+ bool __testeof = traits_type::eq_int_type(__i, __retval);
+
+ if (__testpb)
{
- bool __testpb = _M_in_beg < _M_in_cur;
+ bool __testout = _M_mode & ios_base::out;
bool __testeq = traits_type::eq(__c, this->gptr()[-1]);
// Try to put back __c into input sequence in one of three ways.
// Order these tests done in is unspecified by the standard.
- if (!__testeof && __testpb && __testeq)
+ if (!__testeof && __testeq)
{
--_M_in_cur;
if (__testout)
--_M_out_cur;
__retval = __i;
}
- else if (!__testeof && __testpb && __testout)
+ else if (__testeof)
{
--_M_in_cur;
if (__testout)
--_M_out_cur;
- *_M_in_cur = __c;
- __retval = __i;
+ __retval = traits_type::not_eof(__i);
}
- else if (__testeof && __testpb)
+ else if (!__testeof)
{
--_M_in_cur;
if (__testout)
--_M_out_cur;
- __retval = traits_type::not_eof(__i);
+ _M_pback_create();
+ *_M_in_cur = __c;
+ __retval = __i;
}
}
else
- {
- // Need to make a putback position available.
+ {
+ // At the beginning of the buffer, need to make a
+ // putback position available.
this->seekoff(-1, ios_base::cur);
this->underflow();
- if (!__testeof)
- {
- *_M_in_cur = __c;
- __retval = __c;
- }
- else
- __retval = traits_type::not_eof(__i);
- }
+ if (!__testeof)
+ {
+ if (!traits_type::eq(__c, *_M_in_cur))
+ {
+ _M_pback_create();
+ *_M_in_cur = __c;
+ }
+ __retval = __i;
+ }
+ else
+ __retval = traits_type::not_eof(__i);
+ }
}
_M_last_overflowed = false;
return __retval;
@@ -355,7 +392,7 @@ namespace std
// stack. Convert internal buffer plus __c (ie,
// "pending sequence") to temporary conversion buffer.
int __plen = _M_out_end - _M_out_beg;
- char_type __pbuf[__plen + sizeof(char_type)];
+ char_type __pbuf[__plen + 1];
traits_type::copy(__pbuf, this->pbase(), __plen);
if (!__testeof)
{
@@ -411,6 +448,9 @@ namespace std
if (__testopen && !__testfail && (__testin || __testout))
{
+ // Ditch any pback buffers to avoid confusion.
+ _M_pback_destroy();
+
if (__way != ios_base::cur || __off != 0)
{
off_type __computed_off = __width * __off;
@@ -464,68 +504,7 @@ namespace std
void
basic_filebuf<_CharT, _Traits>::
_M_output_unshift()
- {
-#if 0
- // XXX Not complete, or correct.
- int __width = _M_fcvt->encoding();
-
- if (__width < 0)
- {
- // Part one: call codecvt::unshift
- int __unsft_len = 0;
- char_type __unsft_buf[_M_buf_size];
- char_type* __unsft_cur; // XXX Set to external buf.
- _M_state_beg = _M_state_cur;
- __res_type __r = _M_fcvt->unshift(_M_state_cur,
- __unsft_buf,
- __unsft_buf + _M_buf_size,
- __unsft_cur);
-
- // Note, for char_type == char, wchar_t unshift
- // should store no charachers.
- if (__r == codecvt_base::ok || __r == codecvt_base::noconv)
- __unsft_len = __unsft_cur - __unsft_buf;
-
- // "Output the resulting sequence."
- if (__unsft_len)
- {
- int __plen = _M_out_cur - _M_out_beg;
- int __rlen = __plen + __unsft_len;
- char_type __rbuf[__rlen];
- char_type* __rend;
- traits_type::copy(__rbuf, this->pbase(), __plen);
- traits_type::copy(__rbuf + __plen, __unsft_buf,
- __unsft_len);
-
- char __conv_buf[__rlen];
- char* __conv_end;
-
- _M_state_beg = _M_state_cur; // XXX Needed?
- __r = _M_fcvt->out(_M_state_cur,
- __rbuf, __rbuf + __rlen,
- const_cast<const char_type*&>(__rend),
- __conv_buf,
- __conv_buf + __rlen,
- __conv_end);
-
- if (__r != codecvt_base::error)
- {
- streamsize __r = _M_file->xsputn(__conv_buf, __rlen);
- if (__r == __rlen)
- {
- _M_out_cur = _M_out_beg;
- if (_M_mode & ios_base::in)
- _M_in_cur = _M_out_cur;
- }
- else
- {
- // XXX Throw "wig out and die exception?"
- }
- }
- }
- }
-#endif
- }
+ { }
template<typename _CharT, typename _Traits>
void
diff --git a/libstdc++-v3/bits/locale_facets.h b/libstdc++-v3/bits/locale_facets.h
index 1c73ab9e2bb..14be3f25c56 100644
--- a/libstdc++-v3/bits/locale_facets.h
+++ b/libstdc++-v3/bits/locale_facets.h
@@ -1268,7 +1268,7 @@ namespace std
protected:
// For use only during construction
void
- _M_init_boolnames(const string_type& __t, const string_type& __f)
+ _M_boolnames_init(const string_type& __t, const string_type& __f)
{
_M_truename = __t;
_M_falsename = __f;
@@ -1297,7 +1297,7 @@ namespace std
numpunct<char>::numpunct(size_t __refs): _Numpunct<char>(__refs)
{
_M_init('.', ',', "");
- _M_init_boolnames("true", "false");
+ _M_boolnames_init("true", "false");
}
#ifdef _GLIBCPP_USE_WCHAR_T
@@ -1305,7 +1305,7 @@ namespace std
numpunct<wchar_t>::numpunct(size_t __refs): _Numpunct<wchar_t>(__refs)
{
_M_init(L'.', L',', "");
- _M_init_boolnames(L"true", L"false");
+ _M_boolnames_init(L"true", L"false");
}
#endif
diff --git a/libstdc++-v3/bits/localefwd.h b/libstdc++-v3/bits/localefwd.h
index 7f12457c8bc..ceb376c02b6 100644
--- a/libstdc++-v3/bits/localefwd.h
+++ b/libstdc++-v3/bits/localefwd.h
@@ -370,7 +370,7 @@ namespace std
template<typename _Facet>
inline void
- _M_init_facet(_Facet* __facet)
+ _M_facet_init(_Facet* __facet)
{ _M_install_facet(&_Facet::id, __facet); }
void
diff --git a/libstdc++-v3/bits/std_fstream.h b/libstdc++-v3/bits/std_fstream.h
index 045bb60b092..4ffbb245447 100644
--- a/libstdc++-v3/bits/std_fstream.h
+++ b/libstdc++-v3/bits/std_fstream.h
@@ -52,7 +52,7 @@ namespace std {
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
-
+
// Non-standard Types:
typedef basic_streambuf<char_type, traits_type> __streambuf_type;
typedef basic_filebuf<char_type, traits_type> __filebuf_type;
@@ -65,13 +65,22 @@ namespace std {
private:
// Data Members:
+ // External buffer.
__file_type* _M_file;
- __state_type _M_state_cur;// Current state type for codecvt.
+
+ // Current and beginning state type for codecvt.
+ __state_type _M_state_cur;
__state_type _M_state_beg;
- const __codecvt_type* _M_fcvt; // Cached value from use_facet.
+
+ // Cached value from use_facet.
+ const __codecvt_type* _M_fcvt;
+
+ // MT lock inherited from libio or other low-level io library.
__c_lock _M_lock;
- bool _M_last_overflowed; // XXX Needed?
-
+
+ // XXX Needed?
+ bool _M_last_overflowed;
+
public:
// Constructors/destructor:
basic_filebuf();
@@ -98,9 +107,13 @@ namespace std {
close(void);
protected:
- // Common initialization code for both ctors goes here.
+ // Allocate up pback and internal buffers.
+ void
+ _M_allocate_buffers();
+
+ // Create __file_type object and initialize it properly.
void
- _M_init_filebuf(void);
+ _M_filebuf_init();
// Overridden virtual functions:
virtual streamsize
@@ -173,7 +186,7 @@ namespace std {
// (_M_out_beg - _M_out_cur)
streamoff __cur = _M_file->seekoff(0, ios_base::cur);
off_type __off = _M_out_cur - _M_out_beg;
- this->_M_really_overflow();
+ _M_really_overflow();
_M_file->seekpos(__cur + __off);
}
_M_last_overflowed = false;
@@ -183,6 +196,34 @@ namespace std {
virtual void
imbue(const locale& __loc);
+ virtual streamsize
+ xsgetn(char_type* __s, streamsize __n)
+ {
+ streamsize __retval = 0;
+ // Clear out pback buffer before going on to the real deal...
+ if (_M_pback_init)
+ {
+ while (__retval < __n && _M_in_cur < _M_in_end)
+ {
+ *__s = *_M_in_cur;
+ ++__retval;
+ ++__s;
+ ++_M_in_cur;
+ }
+ _M_pback_destroy();
+ }
+ if (__retval < __n)
+ __retval += __streambuf_type::xsgetn(__s, __n - __retval);
+ return __retval;
+ }
+
+ virtual streamsize
+ xsputn(const char_type* __s, streamsize __n)
+ {
+ _M_pback_destroy();
+ return __streambuf_type::xsputn(__s, __n);
+ }
+
void
_M_output_unshift();
};
diff --git a/libstdc++-v3/bits/std_sstream.h b/libstdc++-v3/bits/std_sstream.h
index 4394dc90306..343919c68c2 100644
--- a/libstdc++-v3/bits/std_sstream.h
+++ b/libstdc++-v3/bits/std_sstream.h
@@ -64,13 +64,13 @@ namespace std {
explicit
basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out)
: __streambuf_type(), _M_string()
- { _M_init_stringbuf(__mode); }
+ { _M_stringbuf_init(__mode); }
explicit
basic_stringbuf(const __string_type& __str,
ios_base::openmode __mode = ios_base::in | ios_base::out)
: __streambuf_type(), _M_string(__str)
- { _M_init_stringbuf(__mode); }
+ { _M_stringbuf_init(__mode); }
// Get and set:
__string_type
@@ -95,13 +95,13 @@ namespace std {
str(const __string_type& __s)
{
_M_string = __s;
- _M_init_stringbuf(_M_mode);
+ _M_stringbuf_init(_M_mode);
}
protected:
// Common initialization code for both ctors goes here.
void
- _M_init_stringbuf(ios_base::openmode __mode)
+ _M_stringbuf_init(ios_base::openmode __mode)
{
// _M_buf_size is a convenient alias for "what the streambuf
// thinks the allocated size of the string really is." This is
diff --git a/libstdc++-v3/bits/std_streambuf.h b/libstdc++-v3/bits/std_streambuf.h
index 23bdd5cca8d..35e214c9123 100644
--- a/libstdc++-v3/bits/std_streambuf.h
+++ b/libstdc++-v3/bits/std_streambuf.h
@@ -98,11 +98,11 @@ namespace std {
// for an internal buffer.
// get == input == read
// put == output == write
- char_type* _M_in_cur; // Current read area.
char_type* _M_in_beg; // Start of get area.
+ char_type* _M_in_cur; // Current read area.
char_type* _M_in_end; // End of get area.
- char_type* _M_out_cur; // Current put area.
char_type* _M_out_beg; // Start of put area.
+ char_type* _M_out_cur; // Current put area.
char_type* _M_out_end; // End of put area.
// Place to stash in || out || in | out settings for current streambuf.
@@ -117,6 +117,61 @@ namespace std {
// Cached use_facet<ctype>, which is based on the current locale info.
const __ctype_type* _M_buf_fctype;
+ // Necessary bits for putback buffer management. Only used in
+ // the basic_filebuf class, as necessary for the standard
+ // requirements. The only basic_streambuf member function that
+ // needs access to these data members is in_avail...
+ // NB: pbacks of over one character are not currently supported.
+ int_type _M_pback_size;
+ char_type* _M_pback;
+ char_type* _M_pback_cur_save;
+ char_type* _M_pback_end_save;
+ bool _M_pback_init;
+
+ // Initializes pback buffers, and moves normal buffers to safety.
+ // Assumptions:
+ // _M_in_cur has already been moved back
+ void
+ _M_pback_create()
+ {
+ if (!_M_pback_init)
+ {
+ int_type __dist = _M_in_end - _M_in_cur;
+ int_type __len = min(_M_pback_size, __dist);
+ traits_type::copy(_M_pback, _M_in_cur, __len);
+ _M_pback_cur_save = _M_in_cur;
+ _M_pback_end_save = _M_in_end;
+ this->setg(_M_pback, _M_pback, _M_pback + __len);
+ _M_pback_init = true;
+ }
+ }
+
+ // Deactivates pback buffer contents, and restores normal buffer.
+ // Assumptions:
+ // The pback buffer has only moved forward.
+ void
+ _M_pback_destroy()
+ {
+ if (_M_pback_init)
+ {
+ // Length _M_in_cur moved in the pback buffer.
+ int_type __off_cur = _M_in_cur - _M_pback;
+
+ // For in | out buffers, the end can be pushed back...
+ int_type __off_end = 0;
+ int_type __pback_len = _M_in_end - _M_pback;
+ int_type __save_len = _M_pback_end_save - _M_buf;
+ if (__pback_len > __save_len)
+ __off_end = __pback_len - __save_len;
+
+ this->setg(_M_buf, _M_pback_cur_save + __off_cur,
+ _M_pback_end_save + __off_end);
+ _M_pback_cur_save = NULL;
+ _M_pback_end_save = NULL;
+ _M_pback_init = false;
+ }
+ }
+
// Correctly sets the _M_out_cur pointer, and bumps the
// appropriate _M_*_end pointers as well. Necessary for the
// un-tied stringbufs, in in|out mode.
@@ -195,6 +250,7 @@ namespace std {
_M_mode = ios_base::openmode(0);
_M_buf_fctype = NULL;
_M_buf_locale_init = false;
+
}
// Locales:
@@ -240,7 +296,16 @@ namespace std {
{
streamsize __retval;
if (_M_in_cur && _M_in_cur < _M_in_end)
- __retval = this->egptr() - this->gptr();
+ {
+ if (_M_pback_init)
+ {
+ int_type __save_len = _M_pback_end_save - _M_pback_cur_save;
+ int_type __pback_len = _M_in_cur - _M_pback;
+ __retval = __save_len - __pback_len;
+ }
+ else
+ __retval = this->egptr() - this->gptr();
+ }
else
__retval = this->showmanyc();
return __retval;
@@ -289,13 +354,12 @@ namespace std {
protected:
basic_streambuf()
: _M_buf(NULL), _M_buf_size(0),
- _M_buf_size_opt(static_cast<int_type>(BUFSIZ * sizeof(char_type))),
- _M_buf_unified(false), _M_in_cur(0), _M_in_beg(0), _M_in_end(0),
- _M_out_cur(0), _M_out_beg(0), _M_out_end(0),
- _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
- _M_buf_locale_init(false)
-
- { _M_buf_fctype = &use_facet<__ctype_type>(this->getloc()); }
+ _M_buf_size_opt(static_cast<int_type>(BUFSIZ)), _M_buf_unified(false),
+ _M_in_beg(0), _M_in_cur(0), _M_in_end(0), _M_out_beg(0), _M_out_cur(0),
+ _M_out_end(0), _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
+ _M_buf_locale_init(false), _M_pback_size(1), _M_pback(NULL),
+ _M_pback_cur_save(NULL), _M_pback_end_save(NULL), _M_pback_init(false)
+ { _M_buf_fctype = &use_facet<__ctype_type>(this->getloc()); }
// Get area:
char_type*
diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc
index 4faa2a40494..15dcf996ca8 100644
--- a/libstdc++-v3/src/locale.cc
+++ b/libstdc++-v3/src/locale.cc
@@ -338,44 +338,44 @@ namespace std {
// (constructor for (*the_classic_locale) adds a third)
// collate category
- _S_classic->_M_init_facet(new std::collate<char>);
+ _S_classic->_M_facet_init(new std::collate<char>);
// ctype category
- _S_classic->_M_init_facet(new std::ctype<char>);
- _S_classic->_M_init_facet(new codecvt<char, char, mbstate_t>);
+ _S_classic->_M_facet_init(new std::ctype<char>);
+ _S_classic->_M_facet_init(new codecvt<char, char, mbstate_t>);
// monetary category
- _S_classic->_M_init_facet(new moneypunct<char, false>);
- _S_classic->_M_init_facet(new moneypunct<char,true >);
- _S_classic->_M_init_facet(new money_get<char>);
- _S_classic->_M_init_facet(new money_put<char>);
+ _S_classic->_M_facet_init(new moneypunct<char, false>);
+ _S_classic->_M_facet_init(new moneypunct<char,true >);
+ _S_classic->_M_facet_init(new money_get<char>);
+ _S_classic->_M_facet_init(new money_put<char>);
// numeric category
- _S_classic->_M_init_facet(new numpunct<char>);
- _S_classic->_M_init_facet(new num_get<char>);
- _S_classic->_M_init_facet(new num_put<char>);
+ _S_classic->_M_facet_init(new numpunct<char>);
+ _S_classic->_M_facet_init(new num_get<char>);
+ _S_classic->_M_facet_init(new num_put<char>);
// time category
- _S_classic->_M_init_facet(new time_get<char>);
- _S_classic->_M_init_facet(new time_put<char>);
+ _S_classic->_M_facet_init(new time_get<char>);
+ _S_classic->_M_facet_init(new time_put<char>);
// messages category
- _S_classic->_M_init_facet(new std::messages<char>);
+ _S_classic->_M_facet_init(new std::messages<char>);
#ifdef _GLIBCPP_USE_WCHAR_T
- _S_classic->_M_init_facet(new std::collate<wchar_t>);
- _S_classic->_M_init_facet(new std::ctype<wchar_t>);
- _S_classic->_M_init_facet(new codecvt<wchar_t, char, mbstate_t>);
- _S_classic->_M_init_facet(new moneypunct<wchar_t, false>);
- _S_classic->_M_init_facet(new moneypunct<wchar_t,true >);
- _S_classic->_M_init_facet(new money_get<wchar_t>);
- _S_classic->_M_init_facet(new money_put<wchar_t>);
- _S_classic->_M_init_facet(new numpunct<wchar_t>);
- _S_classic->_M_init_facet(new num_get<wchar_t>);
- _S_classic->_M_init_facet(new num_put<wchar_t>);
- _S_classic->_M_init_facet(new time_get<wchar_t>);
- _S_classic->_M_init_facet(new time_put<wchar_t>);
- _S_classic->_M_init_facet(new std::messages<wchar_t>);
+ _S_classic->_M_facet_init(new std::collate<wchar_t>);
+ _S_classic->_M_facet_init(new std::ctype<wchar_t>);
+ _S_classic->_M_facet_init(new codecvt<wchar_t, char, mbstate_t>);
+ _S_classic->_M_facet_init(new moneypunct<wchar_t, false>);
+ _S_classic->_M_facet_init(new moneypunct<wchar_t,true >);
+ _S_classic->_M_facet_init(new money_get<wchar_t>);
+ _S_classic->_M_facet_init(new money_put<wchar_t>);
+ _S_classic->_M_facet_init(new numpunct<wchar_t>);
+ _S_classic->_M_facet_init(new num_get<wchar_t>);
+ _S_classic->_M_facet_init(new num_put<wchar_t>);
+ _S_classic->_M_facet_init(new time_get<wchar_t>);
+ _S_classic->_M_facet_init(new time_put<wchar_t>);
+ _S_classic->_M_facet_init(new std::messages<wchar_t>);
#endif
// finesse static init order hassles
diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc
index 0af674eea53..200346930c9 100644
--- a/libstdc++-v3/src/localename.cc
+++ b/libstdc++-v3/src/localename.cc
@@ -147,8 +147,8 @@ namespace std {
locale::_Impl::_M_construct_collate(const char* /*name*/)
{
#if 0
- _M_init_facet(new std::collate_byname<char>(name));
- _M_init_facet(new std::collate_byname<wchar_t>(name));
+ _M_facet_init(new std::collate_byname<char>(name));
+ _M_facet_init(new std::collate_byname<wchar_t>(name));
#endif
}
@@ -156,10 +156,10 @@ namespace std {
locale::_Impl::_M_construct_ctype(const char* /*name*/)
{
#if 0
- _M_init_facet(new std::ctype_byname<char>(name));
- _M_init_facet(new std::ctype_byname<wchar_t>(name));
- _M_init_facet(new std::codecvt_byname<char,char,mbstate_t>(name));
- _M_init_facet(new std::codecvt_byname<wchar_t,char,mbstate_t>(name));
+ _M_facet_init(new std::ctype_byname<char>(name));
+ _M_facet_init(new std::ctype_byname<wchar_t>(name));
+ _M_facet_init(new std::codecvt_byname<char,char,mbstate_t>(name));
+ _M_facet_init(new std::codecvt_byname<wchar_t,char,mbstate_t>(name));
#endif
}
@@ -167,10 +167,10 @@ namespace std {
locale::_Impl::_M_construct_monetary(const char* /*name*/)
{
#if 0
- _M_init_facet(new std::moneypunct_byname<char,false>(name));
- _M_init_facet(new std::moneypunct_byname<wchar_t,false>(name));
- _M_init_facet(new std::moneypunct_byname<char,true >(name));
- _M_init_facet(new std::moneypunct_byname<wchar_t,true >(name));
+ _M_facet_init(new std::moneypunct_byname<char,false>(name));
+ _M_facet_init(new std::moneypunct_byname<wchar_t,false>(name));
+ _M_facet_init(new std::moneypunct_byname<char,true >(name));
+ _M_facet_init(new std::moneypunct_byname<wchar_t,true >(name));
locale::_M_initialize();
_M_replace_facet(locale::_S_classic, &std::money_get<char>(name)::id);
@@ -184,8 +184,8 @@ namespace std {
locale::_Impl::_M_construct_numeric(const char* /*name*/)
{
#if 0
- _M_init_facet(new std::numpunct_byname<char>(name));
- _M_init_facet(new std::numpunct_byname<wchar_t>(name));
+ _M_facet_init(new std::numpunct_byname<char>(name));
+ _M_facet_init(new std::numpunct_byname<wchar_t>(name));
locale::_M_initialize();
_M_replace_facet(locale::_S_classic, &std::num_get<char>::id);
@@ -199,10 +199,10 @@ namespace std {
locale::_Impl::_M_construct_time(const char* /*name*/)
{
#if 0
- _M_init_facet(new std::time_get_byname<char>(name));
- _M_init_facet(new std::time_get_byname<wchar_t>(name));
- _M_init_facet(new std::time_put_byname<char>(name));
- _M_init_facet(new std::time_put_byname<wchar_t>(name));
+ _M_facet_init(new std::time_get_byname<char>(name));
+ _M_facet_init(new std::time_get_byname<wchar_t>(name));
+ _M_facet_init(new std::time_put_byname<char>(name));
+ _M_facet_init(new std::time_put_byname<wchar_t>(name));
#endif
}
@@ -210,8 +210,8 @@ namespace std {
locale::_Impl::_M_construct_messages(const char* /*name*/)
{
#if 0
- _M_init_facet(new std::messages_byname<char>(name));
- _M_init_facet(new std::messages_byname<wchar_t>(name));
+ _M_facet_init(new std::messages_byname<char>(name));
+ _M_facet_init(new std::messages_byname<wchar_t>(name));
#endif
}
diff --git a/libstdc++-v3/testsuite/27_io/filebuf-3.tst b/libstdc++-v3/testsuite/27_io/filebuf-3.tst
index d998eef2330..0a81f511290 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf-3.tst
+++ b/libstdc++-v3/testsuite/27_io/filebuf-3.tst
@@ -1,6 +1,6 @@
bd2
456x
-9mzuva?@ABCDEFGHIJKLMNOPQRSTUVWXYZracadabras, i wannaz
+9m;uva?@ABCDEFGHIJKLMNOPQRSTUVWXYZracadabras, i wanna
because because
because. . .
of the wonderful things he does!!
diff --git a/libstdc++-v3/testsuite/27_io/filebuf.cc b/libstdc++-v3/testsuite/27_io/filebuf.cc
index ce51a5915ea..3e0450e388f 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf.cc
@@ -337,7 +337,7 @@ bool test03() {
strmsz_1 = fb_03.in_avail();
c2 = fb_03.sungetc(); // delete the 'a'
strmsz_2 = fb_03.in_avail();
- test &= c2 == 'v';
+ test &= c2 == 'v'; // test &= c2 != traits_type::eof();
test &= strmsz_1 + 1 == strmsz_2;
//test for _in_cur == _in_beg
for (int i = 50; i < 32 + 29; ++i)
OpenPOWER on IntegriCloud