diff options
author | kan <kan@FreeBSD.org> | 2005-06-03 03:29:38 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2005-06-03 03:29:38 +0000 |
commit | 3b6c93380e20c56b8151f9c6fc3916670b987df5 (patch) | |
tree | c4e455c4fe8d2a3ed1d621536386e3e252ad36bc /contrib/libstdc++/include | |
parent | 2156e40a831a8e0ab68e4bc091c2940bf46ca6df (diff) | |
download | FreeBSD-src-3b6c93380e20c56b8151f9c6fc3916670b987df5.zip FreeBSD-src-3b6c93380e20c56b8151f9c6fc3916670b987df5.tar.gz |
Gcc 3.4.4 C++ support bits.
Diffstat (limited to 'contrib/libstdc++/include')
25 files changed, 304 insertions, 187 deletions
diff --git a/contrib/libstdc++/include/Makefile.am b/contrib/libstdc++/include/Makefile.am index 34e2033..ae9495a 100644 --- a/contrib/libstdc++/include/Makefile.am +++ b/contrib/libstdc++/include/Makefile.am @@ -204,7 +204,6 @@ ext_headers = \ ${ext_srcdir}/algorithm \ ${ext_srcdir}/bitmap_allocator.h \ ${ext_srcdir}/debug_allocator.h \ - ${ext_srcdir}/demangle.h \ ${ext_srcdir}/enc_filebuf.h \ ${ext_srcdir}/stdio_filebuf.h \ ${ext_srcdir}/stdio_sync_filebuf.h \ diff --git a/contrib/libstdc++/include/Makefile.in b/contrib/libstdc++/include/Makefile.in index aad3d17..9d110b3 100644 --- a/contrib/libstdc++/include/Makefile.in +++ b/contrib/libstdc++/include/Makefile.in @@ -404,7 +404,6 @@ ext_headers = \ ${ext_srcdir}/algorithm \ ${ext_srcdir}/bitmap_allocator.h \ ${ext_srcdir}/debug_allocator.h \ - ${ext_srcdir}/demangle.h \ ${ext_srcdir}/enc_filebuf.h \ ${ext_srcdir}/stdio_filebuf.h \ ${ext_srcdir}/stdio_sync_filebuf.h \ diff --git a/contrib/libstdc++/include/bits/basic_string.h b/contrib/libstdc++/include/bits/basic_string.h index 16fe5ac..04e1500 100644 --- a/contrib/libstdc++/include/bits/basic_string.h +++ b/contrib/libstdc++/include/bits/basic_string.h @@ -211,7 +211,9 @@ namespace std void _M_dispose(const _Alloc& __a) { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif if (__gnu_cxx::__exchange_and_add(&this->_M_refcount, -1) <= 0) _M_destroy(__a); } // XXX MT @@ -222,7 +224,9 @@ namespace std _CharT* _M_refcopy() throw() { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif __gnu_cxx::__atomic_add(&this->_M_refcount, 1); return _M_refdata(); } // XXX MT @@ -1846,9 +1850,11 @@ namespace std * * Returns an integer < 0 if this string is ordered before @a str, 0 if * their values are equivalent, or > 0 if this string is ordered after - * @a str. If the lengths of @a str and this string are different, the - * shorter one is ordered first. If they are the same, returns the - * result of traits::compare(data(),str.data(),size()); + * @a str. Determines the effective length rlen of the strings to + * compare as the smallest of size() and str.size(). The function + * then compares the two strings by calling traits::compare(data(), + * str.data(),rlen). If the result of the comparison is nonzero returns + * it, otherwise the shorter one is ordered first. */ int compare(const basic_string& __str) const @@ -1873,10 +1879,12 @@ namespace std * Form the substring of this string from the @a n characters starting * at @a pos. Returns an integer < 0 if the substring is ordered * before @a str, 0 if their values are equivalent, or > 0 if the - * substring is ordered after @a str. If the lengths @a of str and the - * substring are different, the shorter one is ordered first. If they - * are the same, returns the result of - * traits::compare(substring.data(),str.data(),size()); + * substring is ordered after @a str. Determines the effective length + * rlen of the strings to compare as the smallest of the length of the + * substring and @a str.size(). The function then compares the two + * strings by calling traits::compare(substring.data(),str.data(),rlen). + * If the result of the comparison is nonzero returns it, otherwise the + * shorter one is ordered first. */ int compare(size_type __pos, size_type __n, const basic_string& __str) const; @@ -1895,10 +1903,12 @@ namespace std * starting at @a pos2. Returns an integer < 0 if this substring is * ordered before the substring of @a str, 0 if their values are * equivalent, or > 0 if this substring is ordered after the substring - * of @a str. If the lengths of the substring of @a str and this - * substring are different, the shorter one is ordered first. If they - * are the same, returns the result of - * traits::compare(substring.data(),str.substr(pos2,n2).data(),size()); + * of @a str. Determines the effective length rlen of the strings + * to compare as the smallest of the lengths of the substrings. The + * function then compares the two strings by calling + * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). + * If the result of the comparison is nonzero returns it, otherwise the + * shorter one is ordered first. */ int compare(size_type __pos1, size_type __n1, const basic_string& __str, @@ -1911,9 +1921,12 @@ namespace std * * Returns an integer < 0 if this string is ordered before @a s, 0 if * their values are equivalent, or > 0 if this string is ordered after - * @a s. If the lengths of @a s and this string are different, the - * shorter one is ordered first. If they are the same, returns the - * result of traits::compare(data(),s,size()); + * @a s. Determines the effective length rlen of the strings to + * compare as the smallest of size() and the length of a string + * constructed from @a s. The function then compares the two strings + * by calling traits::compare(data(),s,rlen). If the result of the + * comparison is nonzero returns it, otherwise the shorter one is + * ordered first. */ int compare(const _CharT* __s) const; @@ -1930,10 +1943,13 @@ namespace std * Form the substring of this string from the @a n1 characters starting * at @a pos. Returns an integer < 0 if the substring is ordered * before @a s, 0 if their values are equivalent, or > 0 if the - * substring is ordered after @a s. If the lengths of @a s and the - * substring are different, the shorter one is ordered first. If they - * are the same, returns the result of - * traits::compare(substring.data(),s,size()); + * substring is ordered after @a s. Determines the effective length + * rlen of the strings to compare as the smallest of the length of the + * substring and the length of a string constructed from @a s. The + * function then compares the two string by calling + * traits::compare(substring.data(),s,rlen). If the result of the + * comparison is nonzero returns it, otherwise the shorter one is + * ordered first. */ int compare(size_type __pos, size_type __n1, const _CharT* __s) const; @@ -1950,10 +1966,12 @@ namespace std * at @a pos1. Form a string from the first @a n2 characters of @a s. * Returns an integer < 0 if this substring is ordered before the string * from @a s, 0 if their values are equivalent, or > 0 if this substring - * is ordered after the string from @a s. If the lengths of this - * substring and @a n2 are different, the shorter one is ordered first. - * If they are the same, returns the result of - * traits::compare(substring.data(),s,size()); + * is ordered after the string from @a s. Determines the effective + * length rlen of the strings to compare as the smallest of the length + * of the substring and @a n2. The function then compares the two + * strings by calling traits::compare(substring.data(),s,rlen). If the + * result of the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. * * NB: s must have at least n2 characters, '\0' has no special * meaning. @@ -1963,11 +1981,14 @@ namespace std size_type __n2) const; }; - template<typename _CharT, typename _Traits, typename _Alloc> inline basic_string<_CharT, _Traits, _Alloc>:: basic_string() +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { } +#else + : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { } +#endif // operator+ /** diff --git a/contrib/libstdc++/include/bits/basic_string.tcc b/contrib/libstdc++/include/bits/basic_string.tcc index 7034778..fc90111 100644 --- a/contrib/libstdc++/include/bits/basic_string.tcc +++ b/contrib/libstdc++/include/bits/basic_string.tcc @@ -88,8 +88,10 @@ namespace std _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, input_iterator_tag) { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__beg == __end && __a == _Alloc()) return _S_empty_rep()._M_refdata(); +#endif // Avoid reallocation for common case. _CharT __buf[128]; size_type __len = 0; @@ -134,11 +136,12 @@ namespace std _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, forward_iterator_tag) { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__beg == __end && __a == _Alloc()) return _S_empty_rep()._M_refdata(); - +#endif // NB: Not required, but considered best practice. - if (__builtin_expect(__is_null_pointer(__beg), 0)) + if (__builtin_expect(__is_null_pointer(__beg) && __beg != __end, 0)) __throw_logic_error(__N("basic_string::_S_construct NULL not valid")); const size_type __dnew = static_cast<size_type>(std::distance(__beg, @@ -162,9 +165,10 @@ namespace std basic_string<_CharT, _Traits, _Alloc>:: _S_construct(size_type __n, _CharT __c, const _Alloc& __a) { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__n == 0 && __a == _Alloc()) return _S_empty_rep()._M_refdata(); - +#endif // Check for out_of_range and length_error exceptions. _Rep* __r = _Rep::_S_create(__n, size_type(0), __a); if (__n) @@ -358,8 +362,10 @@ namespace std basic_string<_CharT, _Traits, _Alloc>::_Rep:: _M_destroy(const _Alloc& __a) throw () { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (this == &_S_empty_rep()) - return; + return; +#endif const size_type __size = sizeof(_Rep_base) + (this->_M_capacity + 1) * sizeof(_CharT); _Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size); @@ -369,8 +375,10 @@ namespace std void basic_string<_CharT, _Traits, _Alloc>::_M_leak_hard() { +#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (_M_rep() == &_S_empty_rep()) - return; + return; +#endif if (_M_rep()->_M_is_shared()) _M_mutate(0, 0, 0); _M_rep()->_M_set_leaked(); @@ -385,8 +393,7 @@ namespace std const size_type __new_size = __old_size + __len2 - __len1; const size_type __how_much = __old_size - __pos - __len1; - if (_M_rep() == &_S_empty_rep() - || _M_rep()->_M_is_shared() || __new_size > capacity()) + if (__new_size > capacity() || _M_rep()->_M_is_shared()) { // Must reallocate. const allocator_type __a = get_allocator(); diff --git a/contrib/libstdc++/include/bits/boost_concept_check.h b/contrib/libstdc++/include/bits/boost_concept_check.h index 7c99838..ff154f7 100644 --- a/contrib/libstdc++/include/bits/boost_concept_check.h +++ b/contrib/libstdc++/include/bits/boost_concept_check.h @@ -727,9 +727,8 @@ struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; }; __function_requires< _DefaultConstructibleConcept<_Sequence> >(); _Sequence - __c _IsUnused(__n), - __c2 _IsUnused(__n, __t), - __c3 _IsUnused(__first, __last); + __c _IsUnused(__n, __t), + __c2 _IsUnused(__first, __last); __c.insert(__p, __t); __c.insert(__p, __n, __t); diff --git a/contrib/libstdc++/include/bits/c++config b/contrib/libstdc++/include/bits/c++config index 80539b1..d6eee46 100644 --- a/contrib/libstdc++/include/bits/c++config +++ b/contrib/libstdc++/include/bits/c++config @@ -35,7 +35,7 @@ #include <bits/os_defines.h> // The current version of the C++ library in compressed ISO date format. -#define __GLIBCXX__ 20040728 +#define __GLIBCXX__ 20050519 // Allow use of "export template." This is currently not a feature // that g++ supports. diff --git a/contrib/libstdc++/include/bits/fstream.tcc b/contrib/libstdc++/include/bits/fstream.tcc index 6c2e182..25a4d48 100644 --- a/contrib/libstdc++/include/bits/fstream.tcc +++ b/contrib/libstdc++/include/bits/fstream.tcc @@ -396,8 +396,7 @@ namespace std // Convert pending sequence to external representation, // and output. if (_M_convert_to_external(this->pbase(), - this->pptr() - this->pbase()) - && (!__testeof || !_M_file.sync())) + this->pptr() - this->pbase())) { _M_set_buffer(0); __ret = traits_type::not_eof(__c); @@ -497,6 +496,74 @@ namespace std template<typename _CharT, typename _Traits> streamsize basic_filebuf<_CharT, _Traits>:: + xsgetn(_CharT* __s, streamsize __n) + { + // Clear out pback buffer before going on to the real deal... + streamsize __ret = 0; + if (this->_M_pback_init) + { + if (__n > 0 && this->gptr() == this->eback()) + { + *__s++ = *this->gptr(); + this->gbump(1); + __ret = 1; + --__n; + } + _M_destroy_pback(); + } + + // Optimization in the always_noconv() case, to be generalized in the + // future: when __n > __buflen we read directly instead of using the + // buffer repeatedly. + const bool __testin = this->_M_mode & ios_base::in; + const streamsize __buflen = this->_M_buf_size > 1 ? this->_M_buf_size - 1 + : 1; + if (__n > __buflen && __check_facet(_M_codecvt).always_noconv() + && __testin && !_M_writing) + { + // First, copy the chars already present in the buffer. + const streamsize __avail = this->egptr() - this->gptr(); + if (__avail != 0) + { + if (__avail == 1) + *__s = *this->gptr(); + else + traits_type::copy(__s, this->gptr(), __avail); + __s += __avail; + this->gbump(__avail); + __ret += __avail; + __n -= __avail; + } + + const streamsize __len = _M_file.xsgetn(reinterpret_cast<char*>(__s), + __n); + if (__len == -1) + __throw_ios_failure(__N("basic_filebuf::xsgetn " + "error reading the file")); + __ret += __len; + if (__len == __n) + { + _M_set_buffer(0); + _M_reading = true; + } + else if (__len == 0) + { + // If end of file is reached, set 'uncommitted' + // mode, thus allowing an immediate write without + // an intervening seek. + _M_set_buffer(-1); + _M_reading = false; + } + } + else + __ret += __streambuf_type::xsgetn(__s, __n); + + return __ret; + } + + template<typename _CharT, typename _Traits> + streamsize + basic_filebuf<_CharT, _Traits>:: xsputn(const _CharT* __s, streamsize __n) { // Optimization in the always_noconv() case, to be generalized in the @@ -504,8 +571,8 @@ namespace std // using the buffer. streamsize __ret = 0; const bool __testout = this->_M_mode & ios_base::out; - if (__testout && !_M_reading - && __check_facet(_M_codecvt).always_noconv()) + if (__check_facet(_M_codecvt).always_noconv() + && __testout && !_M_reading) { // Measurement would reveal the best choice. const streamsize __chunk = 1ul << 10; @@ -724,7 +791,6 @@ namespace std { // Make sure that the internal buffer resyncs its idea of // the file position with the external file. - // NB: _M_file.sync() will be called within. int __ret = 0; if (this->pbase() < this->pptr()) { diff --git a/contrib/libstdc++/include/bits/ios_base.h b/contrib/libstdc++/include/bits/ios_base.h index 694785d..08c952d 100644 --- a/contrib/libstdc++/include/bits/ios_base.h +++ b/contrib/libstdc++/include/bits/ios_base.h @@ -52,7 +52,28 @@ namespace std // as permitted (but not required) in the standard, in order to provide // better type safety in iostream calls. A side effect is that // expressions involving them are no longer compile-time constants. - enum _Ios_Fmtflags { _S_ios_fmtflags_end = 1L << 16 }; + enum _Ios_Fmtflags + { + _S_boolalpha = 1L << 0, + _S_dec = 1L << 1, + _S_fixed = 1L << 2, + _S_hex = 1L << 3, + _S_internal = 1L << 4, + _S_left = 1L << 5, + _S_oct = 1L << 6, + _S_right = 1L << 7, + _S_scientific = 1L << 8, + _S_showbase = 1L << 9, + _S_showpoint = 1L << 10, + _S_showpos = 1L << 11, + _S_skipws = 1L << 12, + _S_unitbuf = 1L << 13, + _S_uppercase = 1L << 14, + _S_adjustfield = _S_left | _S_right | _S_internal, + _S_basefield = _S_dec | _S_oct | _S_hex, + _S_floatfield = _S_scientific | _S_fixed, + _S_ios_fmtflags_end = 1L << 16 + }; inline _Ios_Fmtflags operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) @@ -66,15 +87,15 @@ namespace std operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); } - inline _Ios_Fmtflags + inline _Ios_Fmtflags& operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) { return __a = __a | __b; } - inline _Ios_Fmtflags + inline _Ios_Fmtflags& operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) { return __a = __a & __b; } - inline _Ios_Fmtflags + inline _Ios_Fmtflags& operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) { return __a = __a ^ __b; } @@ -83,7 +104,16 @@ namespace std { return _Ios_Fmtflags(~static_cast<int>(__a)); } - enum _Ios_Openmode { _S_ios_openmode_end = 1L << 16 }; + enum _Ios_Openmode + { + _S_app = 1L << 0, + _S_ate = 1L << 1, + _S_bin = 1L << 2, + _S_in = 1L << 3, + _S_out = 1L << 4, + _S_trunc = 1L << 5, + _S_ios_openmode_end = 1L << 16 + }; inline _Ios_Openmode operator&(_Ios_Openmode __a, _Ios_Openmode __b) @@ -97,15 +127,15 @@ namespace std operator^(_Ios_Openmode __a, _Ios_Openmode __b) { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); } - inline _Ios_Openmode + inline _Ios_Openmode& operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) { return __a = __a | __b; } - inline _Ios_Openmode + inline _Ios_Openmode& operator&=(_Ios_Openmode& __a, _Ios_Openmode __b) { return __a = __a & __b; } - inline _Ios_Openmode + inline _Ios_Openmode& operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) { return __a = __a ^ __b; } @@ -114,7 +144,14 @@ namespace std { return _Ios_Openmode(~static_cast<int>(__a)); } - enum _Ios_Iostate { _S_ios_iostate_end = 1L << 16 }; + enum _Ios_Iostate + { + _S_goodbit = 0, + _S_badbit = 1L << 0, + _S_eofbit = 1L << 1, + _S_failbit = 1L << 2, + _S_ios_iostate_end = 1L << 16 + }; inline _Ios_Iostate operator&(_Ios_Iostate __a, _Ios_Iostate __b) @@ -128,15 +165,15 @@ namespace std operator^(_Ios_Iostate __a, _Ios_Iostate __b) { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); } - inline _Ios_Iostate + inline _Ios_Iostate& operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) { return __a = __a | __b; } - inline _Ios_Iostate + inline _Ios_Iostate& operator&=(_Ios_Iostate& __a, _Ios_Iostate __b) { return __a = __a & __b; } - inline _Ios_Iostate + inline _Ios_Iostate& operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) { return __a = __a ^ __b; } @@ -144,7 +181,13 @@ namespace std operator~(_Ios_Iostate __a) { return _Ios_Iostate(~static_cast<int>(__a)); } - enum _Ios_Seekdir { _S_ios_seekdir_end = 1L << 16 }; + enum _Ios_Seekdir + { + _S_beg = 0, + _S_cur = SEEK_CUR, + _S_end = SEEK_END, + _S_ios_seekdir_end = 1L << 16 + }; // 27.4.2 Class ios_base /** diff --git a/contrib/libstdc++/include/bits/istream.tcc b/contrib/libstdc++/include/bits/istream.tcc index 6417e95..9decce3 100644 --- a/contrib/libstdc++/include/bits/istream.tcc +++ b/contrib/libstdc++/include/bits/istream.tcc @@ -1176,11 +1176,15 @@ namespace std extern template istream& operator>>(istream&, unsigned char*); extern template istream& operator>>(istream&, signed char*); + extern template class basic_iostream<char>; + #ifdef _GLIBCXX_USE_WCHAR_T extern template class basic_istream<wchar_t>; extern template wistream& ws(wistream&); extern template wistream& operator>>(wistream&, wchar_t&); extern template wistream& operator>>(wistream&, wchar_t*); + + extern template class basic_iostream<wchar_t>; #endif #endif } // namespace std diff --git a/contrib/libstdc++/include/bits/locale_facets.h b/contrib/libstdc++/include/bits/locale_facets.h index 60db8a4..db0e951 100644 --- a/contrib/libstdc++/include/bits/locale_facets.h +++ b/contrib/libstdc++/include/bits/locale_facets.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -690,7 +690,7 @@ namespace std mutable char _M_widen[1 + static_cast<unsigned char>(-1)]; mutable char _M_narrow[1 + static_cast<unsigned char>(-1)]; mutable char _M_narrow_ok; // 0 uninitialized, 1 init, - // 2 non-consecutive + // 2 memcpy can't be used public: /// The facet id for ctype<char> @@ -865,7 +865,8 @@ namespace std char_type widen(char __c) const { - if (_M_widen_ok) return _M_widen[static_cast<unsigned char>(__c)]; + if (_M_widen_ok) + return _M_widen[static_cast<unsigned char>(__c)]; this->_M_widen_init(); return this->do_widen(__c); } @@ -896,7 +897,8 @@ namespace std memcpy(__to, __lo, __hi - __lo); return __hi; } - if (!_M_widen_ok) _M_widen_init(); + if (!_M_widen_ok) + _M_widen_init(); return this->do_widen(__lo, __hi, __to); } @@ -924,7 +926,8 @@ namespace std if (_M_narrow[static_cast<unsigned char>(__c)]) return _M_narrow[static_cast<unsigned char>(__c)]; const char __t = do_narrow(__c, __dfault); - if (__t != __dfault) _M_narrow[static_cast<unsigned char>(__c)] = __t; + if (__t != __dfault) + _M_narrow[static_cast<unsigned char>(__c)] = __t; return __t; } @@ -954,7 +957,7 @@ namespace std narrow(const char_type* __lo, const char_type* __hi, char __dfault, char *__to) const { - if (__builtin_expect(_M_narrow_ok == 1,true)) + if (__builtin_expect(_M_narrow_ok == 1, true)) { memcpy(__to, __lo, __hi - __lo); return __hi; @@ -1161,17 +1164,13 @@ namespace std _M_widen_ok = 1; // Set _M_widen_ok to 2 if memcpy can't be used. - for (size_t __j = 0; __j < sizeof(_M_widen); ++__j) - if (__tmp[__j] != _M_widen[__j]) - { - _M_widen_ok = 2; - break; - } + if (memcmp(__tmp, _M_widen, sizeof(_M_widen))) + _M_widen_ok = 2; } // Fill in the narrowing cache and flag whether all values are - // valid or not. _M_narrow_ok is set to 1 if the whole table is - // narrowed, 2 if only some values could be narrowed. + // valid or not. _M_narrow_ok is set to 2 if memcpy can't + // be used. void _M_narrow_init() const { char __tmp[sizeof(_M_narrow)]; @@ -1179,21 +1178,18 @@ namespace std __tmp[__i] = __i; do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow); - // Check if any default values were created. Do this by - // renarrowing with a different default value and comparing. - bool __consecutive = true; - for (size_t __j = 0; __j < sizeof(_M_narrow); ++__j) - if (!_M_narrow[__j]) - { - char __c; - do_narrow(__tmp + __j, __tmp + __j + 1, 1, &__c); - if (__c == 1) - { - __consecutive = false; - break; - } - } - _M_narrow_ok = __consecutive ? 1 : 2; + _M_narrow_ok = 1; + if (memcmp(__tmp, _M_narrow, sizeof(_M_narrow))) + _M_narrow_ok = 2; + else + { + // Deal with the special case of zero: renarrow with a + // different default and compare. + char __c; + do_narrow(__tmp, __tmp + 1, 1, &__c); + if (__c == 1) + _M_narrow_ok = 2; + } } }; diff --git a/contrib/libstdc++/include/bits/locale_facets.tcc b/contrib/libstdc++/include/bits/locale_facets.tcc index f0f5e3a..4f65844 100644 --- a/contrib/libstdc++/include/bits/locale_facets.tcc +++ b/contrib/libstdc++/include/bits/locale_facets.tcc @@ -1151,8 +1151,8 @@ namespace std const ios_base::fmtflags __flags = __io.flags(); if ((__flags & ios_base::boolalpha) == 0) { - unsigned long __uv = __v; - __s = _M_insert_int(__s, __io, __fill, __uv); + const long __l = __v; + __s = _M_insert_int(__s, __io, __fill, __l); } else { @@ -1229,8 +1229,7 @@ namespace std const void* __v) const { const ios_base::fmtflags __flags = __io.flags(); - const ios_base::fmtflags __fmt = ~(ios_base::showpos - | ios_base::basefield + const ios_base::fmtflags __fmt = ~(ios_base::basefield | ios_base::uppercase | ios_base::internal); __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase)); @@ -1674,22 +1673,22 @@ namespace std char* __cs = static_cast<char*>(__builtin_alloca(__cs_size)); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 328. Bad sprintf format modifier in money_put<>::do_put() - int __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units, - _S_get_c_locale()); + int __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units, + _S_get_c_locale(), 0); // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { __cs_size = __len + 1; __cs = static_cast<char*>(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(__cs, __cs_size, "%.0Lf", __units, - _S_get_c_locale()); + __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units, + _S_get_c_locale(), 0); } #else // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'. const int __cs_size = numeric_limits<long double>::max_exponent10 + 3; char* __cs = static_cast<char*>(__builtin_alloca(__cs_size)); - int __len = std::__convert_from_v(__cs, 0, "%.0Lf", __units, - _S_get_c_locale()); + int __len = std::__convert_from_v(__cs, 0, "%.*Lf", __units, + _S_get_c_locale(), 0); #endif _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __cs_size)); @@ -1837,8 +1836,13 @@ namespace std __tm, __wcs); break; case 'S': - // Seconds. - __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 59, 2, + // Seconds. [tm_sec] + // [00, 60] in C99 (one leap-second), [00, 61] in C89. +#ifdef _GLIBCXX_USE_C99 + __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2, +#else + __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2, +#endif __io, __err); break; case 't': @@ -1998,8 +2002,7 @@ namespace std for (size_t __i2 = 1; __i2 < __nmatches; ++__i2) __minlen = std::min(__minlen, __traits_type::length(__names[__matches[__i2]])); - ++__pos; - ++__beg; + ++__beg, ++__pos; if (__pos < __minlen && __beg != __end) for (size_t __i3 = 0; __i3 < __nmatches;) { @@ -2016,8 +2019,7 @@ namespace std if (__nmatches == 1) { // Make sure found name is completely extracted. - ++__pos; - ++__beg; + ++__beg, ++__pos; __name = __names[__matches[0]]; const size_t __len = __traits_type::length(__name); while (__pos < __len && __beg != __end && __name[__pos] == *__beg) @@ -2090,7 +2092,7 @@ namespace std // __days array with the same index points to a day, and that // day's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err) + if (!__err && __beg != __end) { size_t __pos = __traits_type::length(__days[__tmpwday]); __tp._M_days(__days); @@ -2105,9 +2107,10 @@ namespace std if (__len != __pos) __err |= ios_base::failbit; } - if (!__err) - __tm->tm_wday = __tmpwday; } + if (!__err) + __tm->tm_wday = __tmpwday; + if (__beg == __end) __err |= ios_base::eofbit; return __beg; @@ -2135,7 +2138,7 @@ namespace std // __months array with the same index points to a month, and that // month's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err) + if (!__err && __beg != __end) { size_t __pos = __traits_type::length(__months[__tmpmon]); __tp._M_months(__months); @@ -2150,9 +2153,9 @@ namespace std if (__len != __pos) __err |= ios_base::failbit; } - if (!__err) - __tm->tm_mon = __tmpmon; } + if (!__err) + __tm->tm_mon = __tmpmon; if (__beg == __end) __err |= ios_base::eofbit; @@ -2234,7 +2237,7 @@ namespace std // NB: This size is arbitrary. Should this be a data member, // initialized at construction? - const size_t __maxlen = 64; + const size_t __maxlen = 128; char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen)); diff --git a/contrib/libstdc++/include/bits/sstream.tcc b/contrib/libstdc++/include/bits/sstream.tcc index 04cd6ec..03f49fb 100644 --- a/contrib/libstdc++/include/bits/sstream.tcc +++ b/contrib/libstdc++/include/bits/sstream.tcc @@ -123,6 +123,7 @@ namespace std { // Update egptr() to match the actual string end. _M_update_egptr(); + if (this->gptr() < this->egptr()) __ret = traits_type::to_int_type(*this->gptr()); } @@ -141,10 +142,11 @@ namespace std __testin &= !(__mode & ios_base::out); __testout &= !(__mode & ios_base::in); - if (_M_string.capacity() && (__testin || __testout || __testboth)) + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 453. basic_stringbuf::seekoff need not always fail for an empty stream. + const char_type* __beg = __testin ? this->eback() : this->pbase(); + if ((__beg || !__off) && (__testin || __testout || __testboth)) { - char_type* __beg = __testin ? this->eback() : this->pbase(); - _M_update_egptr(); off_type __newoffi = 0; @@ -181,15 +183,15 @@ namespace std seekpos(pos_type __sp, ios_base::openmode __mode) { pos_type __ret = pos_type(off_type(-1)); - if (_M_string.capacity()) - { - off_type __pos (__sp); - const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; - const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; - char_type* __beg = __testin ? this->eback() : this->pbase(); + const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; + const char_type* __beg = __testin ? this->eback() : this->pbase(); + if (__beg) + { _M_update_egptr(); + off_type __pos(__sp); const bool __testpos = 0 <= __pos && __pos <= this->egptr() - __beg; if ((__testin || __testout) && __testpos) @@ -198,7 +200,7 @@ namespace std this->gbump((__beg + __pos) - this->gptr()); if (__testout) this->pbump((__beg + __pos) - this->pptr()); - __ret = pos_type(off_type(__pos)); + __ret = __sp; } } return __ret; diff --git a/contrib/libstdc++/include/bits/stl_algo.h b/contrib/libstdc++/include/bits/stl_algo.h index 6fed578..74956d7 100644 --- a/contrib/libstdc++/include/bits/stl_algo.h +++ b/contrib/libstdc++/include/bits/stl_algo.h @@ -1103,8 +1103,6 @@ namespace std // concept requirements __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< _ForwardIterator>) - __glibcxx_function_requires(_ConvertibleConcept<_Tp, - typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_function_requires(_EqualOpConcept< typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_valid_range(__first, __last); @@ -4908,9 +4906,6 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_EqualOpConcept< - typename iterator_traits<_InputIterator>::value_type, - typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, typename iterator_traits<_InputIterator>::value_type, typename iterator_traits<_ForwardIterator>::value_type>) diff --git a/contrib/libstdc++/include/bits/stl_algobase.h b/contrib/libstdc++/include/bits/stl_algobase.h index 17c3007..d482529 100644 --- a/contrib/libstdc++/include/bits/stl_algobase.h +++ b/contrib/libstdc++/include/bits/stl_algobase.h @@ -1,6 +1,6 @@ // Bits and pieces used in algorithms -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -617,9 +617,8 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_EqualityComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_EqualityComparableConcept< + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator1>::value_type, typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_requires_valid_range(__first1, __last1); @@ -747,10 +746,12 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); diff --git a/contrib/libstdc++/include/bits/stl_list.h b/contrib/libstdc++/include/bits/stl_list.h index 060755a..afb118b 100644 --- a/contrib/libstdc++/include/bits/stl_list.h +++ b/contrib/libstdc++/include/bits/stl_list.h @@ -1,6 +1,6 @@ // List implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -119,7 +119,8 @@ namespace _GLIBCXX_STD typedef _Tp* pointer; typedef _Tp& reference; - _List_iterator() { } + _List_iterator() + : _M_node() { } _List_iterator(_List_node_base* __x) : _M_node(__x) { } @@ -195,7 +196,8 @@ namespace _GLIBCXX_STD typedef const _Tp* pointer; typedef const _Tp& reference; - _List_const_iterator() { } + _List_const_iterator() + : _M_node() { } _List_const_iterator(const _List_node_base* __x) : _M_node(__x) { } diff --git a/contrib/libstdc++/include/bits/stl_tree.h b/contrib/libstdc++/include/bits/stl_tree.h index ac9add8..cea16f1 100644 --- a/contrib/libstdc++/include/bits/stl_tree.h +++ b/contrib/libstdc++/include/bits/stl_tree.h @@ -1,6 +1,6 @@ // RB tree implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -161,7 +161,8 @@ namespace std typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; typedef _Rb_tree_node<_Tp>* _Link_type; - _Rb_tree_iterator() { } + _Rb_tree_iterator() + : _M_node() { } _Rb_tree_iterator(_Link_type __x) : _M_node(__x) { } @@ -231,7 +232,8 @@ namespace std typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr; typedef const _Rb_tree_node<_Tp>* _Link_type; - _Rb_tree_const_iterator() { } + _Rb_tree_const_iterator() + : _M_node() { } _Rb_tree_const_iterator(_Link_type __x) : _M_node(__x) { } @@ -702,7 +704,7 @@ namespace std const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) { return __x.size() == __y.size() - && equal(__x.begin(), __x.end(), __y.begin()); + && std::equal(__x.begin(), __x.end(), __y.begin()); } template<typename _Key, typename _Val, typename _KeyOfValue, @@ -711,8 +713,8 @@ namespace std operator<(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) { - return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); + return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } template<typename _Key, typename _Val, typename _KeyOfValue, diff --git a/contrib/libstdc++/include/bits/vector.tcc b/contrib/libstdc++/include/bits/vector.tcc index abd1ba7..786afab 100644 --- a/contrib/libstdc++/include/bits/vector.tcc +++ b/contrib/libstdc++/include/bits/vector.tcc @@ -1,6 +1,6 @@ // Vector implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -118,7 +118,7 @@ namespace _GLIBCXX_STD vector<_Tp,_Alloc>:: erase(iterator __first, iterator __last) { - iterator __i(copy(__last, end(), __first)); + iterator __i(std::copy(__last, end(), __first)); std::_Destroy(__i, end()); this->_M_impl._M_finish = this->_M_impl._M_finish - (__last - __first); return __first; @@ -143,7 +143,7 @@ namespace _GLIBCXX_STD } else if (size() >= __xlen) { - iterator __i(copy(__x.begin(), __x.end(), begin())); + iterator __i(std::copy(__x.begin(), __x.end(), begin())); std::_Destroy(__i, end()); } else @@ -209,7 +209,7 @@ namespace _GLIBCXX_STD } else if (size() >= __len) { - iterator __new_finish(copy(__first, __last, this->_M_impl._M_start)); + iterator __new_finish(std::copy(__first, __last, this->_M_impl._M_start)); std::_Destroy(__new_finish, end()); this->_M_impl._M_finish = __new_finish.base(); } diff --git a/contrib/libstdc++/include/debug/map.h b/contrib/libstdc++/include/debug/map.h index 2a6794b..0171584 100644 --- a/contrib/libstdc++/include/debug/map.h +++ b/contrib/libstdc++/include/debug/map.h @@ -163,7 +163,7 @@ namespace __gnu_debug_def void insert(_InputIterator __first, _InputIterator __last) { - __glibcxx_valid_range(__first, __last); + __glibcxx_check_valid_range(__first, __last); _Base::insert(__first, __last); } diff --git a/contrib/libstdc++/include/ext/pool_allocator.h b/contrib/libstdc++/include/ext/pool_allocator.h index eec79e7..0f087a0 100644 --- a/contrib/libstdc++/include/ext/pool_allocator.h +++ b/contrib/libstdc++/include/ext/pool_allocator.h @@ -48,6 +48,7 @@ #define _POOL_ALLOCATOR_H 1 #include <bits/c++config.h> +#include <cstdlib> #include <new> #include <bits/functexcept.h> #include <bits/atomicity.h> @@ -72,7 +73,7 @@ namespace __gnu_cxx * @endif * (See @link Allocators allocators info @endlink for more.) */ - class __pool_base + class __pool_alloc_base { protected: @@ -116,7 +117,7 @@ namespace __gnu_cxx template<typename _Tp> - class __pool_alloc : private __pool_base + class __pool_alloc : private __pool_alloc_base { private: static _Atomic_word _S_force_new; diff --git a/contrib/libstdc++/include/ext/rope b/contrib/libstdc++/include/ext/rope index 95afd82..b4bf2c96 100644 --- a/contrib/libstdc++/include/ext/rope +++ b/contrib/libstdc++/include/ext/rope @@ -1,6 +1,6 @@ // SGI's rope class -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -152,7 +152,7 @@ class sequence_buffer : public iterator<std::output_iterator_tag,void,void,void, sequence_buffer(const sequence_buffer& __x) { _M_prefix = __x._M_prefix; _M_buf_count = __x._M_buf_count; - copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); + std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); } sequence_buffer(sequence_buffer& __x) { __x.flush(); @@ -169,7 +169,7 @@ class sequence_buffer : public iterator<std::output_iterator_tag,void,void,void, sequence_buffer& operator= (const sequence_buffer& __x) { _M_prefix = __x._M_prefix; _M_buf_count = __x._M_buf_count; - copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); + std::copy(__x._M_buffer, __x._M_buffer + __x._M_buf_count, _M_buffer); return *this; } void push_back(value_type __x) diff --git a/contrib/libstdc++/include/ext/ropeimpl.h b/contrib/libstdc++/include/ext/ropeimpl.h index 5eba107..29dc550 100644 --- a/contrib/libstdc++/include/ext/ropeimpl.h +++ b/contrib/libstdc++/include/ext/ropeimpl.h @@ -1295,7 +1295,7 @@ rope<_CharT,_Alloc>::_S_compare (const _RopeRep* __left, __right_len = __right->_M_size; if (_Rope_constants::_S_leaf == __left->_M_tag) { _RopeLeaf* __l = (_RopeLeaf*) __left; - if (_RopeRep::_S_leaf == __right->_M_tag) { + if (_Rope_constants::_S_leaf == __right->_M_tag) { _RopeLeaf* __r = (_RopeLeaf*) __right; return lexicographical_compare_3way( __l->_M_data, __l->_M_data + __left_len, diff --git a/contrib/libstdc++/include/std/std_complex.h b/contrib/libstdc++/include/std/std_complex.h index e1027f6..244ed28 100644 --- a/contrib/libstdc++/include/std/std_complex.h +++ b/contrib/libstdc++/include/std/std_complex.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- complex number classes. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -736,9 +736,7 @@ namespace std typedef float value_type; complex(float = 0.0f, float = 0.0f); -#ifdef _GLIBCXX_BUGGY_COMPLEX - complex(const complex& __z) : _M_value(__z._M_value) { } -#endif + explicit complex(const complex<double>&); explicit complex(const complex<long double>&); @@ -892,10 +890,8 @@ namespace std public: typedef double value_type; - complex(double =0.0, double =0.0); -#ifdef _GLIBCXX_BUGGY_COMPLEX - complex(const complex& __z) : _M_value(__z._M_value) { } -#endif + complex(double = 0.0, double = 0.0); + complex(const complex<float>&); explicit complex(const complex<long double>&); @@ -1049,9 +1045,7 @@ namespace std typedef long double value_type; complex(long double = 0.0L, long double = 0.0L); -#ifdef _GLIBCXX_BUGGY_COMPLEX - complex(const complex& __z) : _M_value(__z._M_value) { } -#endif + complex(const complex<float>&); complex(const complex<double>&); diff --git a/contrib/libstdc++/include/std/std_fstream.h b/contrib/libstdc++/include/std/std_fstream.h index 040f579..3dec366 100644 --- a/contrib/libstdc++/include/std/std_fstream.h +++ b/contrib/libstdc++/include/std/std_fstream.h @@ -418,24 +418,7 @@ namespace std // [documentation is inherited] virtual streamsize - xsgetn(char_type* __s, streamsize __n) - { - // Clear out pback buffer before going on to the real deal... - streamsize __ret = 0; - if (this->_M_pback_init) - { - if (__n && this->gptr() == this->eback()) - { - *__s++ = *this->gptr(); - this->gbump(1); - __ret = 1; - } - _M_destroy_pback(); - } - if (__ret < __n) - __ret += __streambuf_type::xsgetn(__s, __n - __ret); - return __ret; - } + xsgetn(char_type* __s, streamsize __n); // [documentation is inherited] virtual streamsize diff --git a/contrib/libstdc++/include/std/std_memory.h b/contrib/libstdc++/include/std/std_memory.h index 4e6641e..1d278e6 100644 --- a/contrib/libstdc++/include/std/std_memory.h +++ b/contrib/libstdc++/include/std/std_memory.h @@ -58,6 +58,7 @@ #include <bits/stl_uninitialized.h> #include <bits/stl_raw_storage_iter.h> #include <debug/debug.h> +#include <limits> namespace std { @@ -73,8 +74,9 @@ namespace std pair<_Tp*, ptrdiff_t> __get_temporary_buffer(ptrdiff_t __len, _Tp*) { - if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) - __len = INT_MAX / sizeof(_Tp); + const ptrdiff_t __max = numeric_limits<ptrdiff_t>::max() / sizeof(_Tp); + if (__len > __max) + __len = __max; while (__len > 0) { @@ -105,7 +107,7 @@ namespace std * Provides the nothrow exception guarantee. */ template<typename _Tp> - inline pair<_Tp*,ptrdiff_t> + inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } diff --git a/contrib/libstdc++/include/std/std_sstream.h b/contrib/libstdc++/include/std/std_sstream.h index 6b5728b..0a6738a 100644 --- a/contrib/libstdc++/include/std/std_sstream.h +++ b/contrib/libstdc++/include/std/std_sstream.h @@ -111,8 +111,8 @@ namespace std */ explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out) - : __streambuf_type(), _M_mode(), _M_string() - { _M_stringbuf_init(__mode); } + : __streambuf_type(), _M_mode(__mode), _M_string() + { } /** * @brief Starts with an existing string buffer. @@ -140,8 +140,7 @@ namespace std __string_type str() const { - const bool __testout = this->_M_mode & ios_base::out; - if (__testout) + if (this->pptr()) { // The current egptr() may not be the actual string end. if (this->pptr() > this->egptr()) @@ -169,7 +168,7 @@ namespace std } protected: - // Common initialization code for both ctors goes here. + // Common initialization code goes here. /** * @if maint * @doctodo @@ -277,9 +276,8 @@ namespace std _M_update_egptr() { const bool __testin = this->_M_mode & ios_base::in; - const bool __testout = this->_M_mode & ios_base::out; - if (__testout && this->pptr() > this->egptr()) + if (this->pptr() && this->pptr() > this->egptr()) if (__testin) this->setg(this->eback(), this->gptr(), this->pptr()); else |