diff options
Diffstat (limited to 'contrib/libc++/include/locale')
-rw-r--r-- | contrib/libc++/include/locale | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/contrib/libc++/include/locale b/contrib/libc++/include/locale index bec27f6..0d77a4a 100644 --- a/contrib/libc++/include/locale +++ b/contrib/libc++/include/locale @@ -1587,6 +1587,52 @@ __pad_and_output(_OutputIterator __s, return __s; } +template <class _CharT, class _Traits> +_LIBCPP_HIDDEN +ostreambuf_iterator<_CharT, _Traits> +__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s, + const _CharT* __ob, const _CharT* __op, const _CharT* __oe, + ios_base& __iob, _CharT __fl) +{ + if (__s.__sbuf_ == nullptr) + return __s; + streamsize __sz = __oe - __ob; + streamsize __ns = __iob.width(); + if (__ns > __sz) + __ns -= __sz; + else + __ns = 0; + streamsize __np = __op - __ob; + if (__np > 0) + { + if (__s.__sbuf_->sputn(__ob, __np) != __np) + { + __s.__sbuf_ = nullptr; + return __s; + } + } + if (__ns > 0) + { + basic_string<_CharT, _Traits> __sp(__ns, __fl); + if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) + { + __s.__sbuf_ = nullptr; + return __s; + } + } + __np = __oe - __op; + if (__np > 0) + { + if (__s.__sbuf_->sputn(__op, __np) != __np) + { + __s.__sbuf_ = nullptr; + return __s; + } + } + __iob.width(0); + return __s; +} + template <class _CharT, class _OutputIterator> _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, @@ -3920,7 +3966,8 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: if (__cvtptr_ != nullptr) { wide_string __ws(2*(__frm_end - __frm), _Elem()); - __ws.resize(__ws.capacity()); + if (__frm != __frm_end) + __ws.resize(__ws.capacity()); codecvt_base::result __r = codecvt_base::ok; state_type __st = __cvtstate_; if (__frm != __frm_end) @@ -3980,7 +4027,8 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: if (__cvtptr_ != nullptr) { byte_string __bs(2*(__frm_end - __frm), char()); - __bs.resize(__bs.capacity()); + if (__frm != __frm_end) + __bs.resize(__bs.capacity()); codecvt_base::result __r = codecvt_base::ok; state_type __st = __cvtstate_; if (__frm != __frm_end) |