Allow seek to position 0 in a vectorstream with empty storage, always reserve 1k for core_file printf buffer

This commit is contained in:
Vas Crabb 2016-03-10 04:41:08 +11:00
parent 5fa07c9202
commit 8dad674507
2 changed files with 4 additions and 3 deletions

View File

@ -613,6 +613,7 @@ int core_text_file::puts(char const *s)
int core_text_file::vprintf(util::format_argument_pack<std::ostream> const &args)
{
m_printf_buffer.reserve(1024);
m_printf_buffer.seekp(0, ovectorstream::beg);
util::stream_format<std::ostream, std::ostream>(m_printf_buffer, args);
m_printf_buffer.put('\0');

View File

@ -116,7 +116,7 @@ public:
void reserve(typename vector_type::size_type size)
{
if ((m_mode & std::ios_base::out) && (m_storage.size() < size))
if ((m_mode & std::ios_base::out) && (m_storage.capacity() < size))
{
m_storage.reserve(size);
adjust();
@ -150,8 +150,8 @@ protected:
bool const out(which & std::ios_base::out);
if ((!in && !out) ||
(in && out && (std::ios_base::cur == dir)) ||
(in && (!(m_mode & std::ios_base::in) || !this->gptr())) ||
(out && (!(m_mode & std::ios_base::out) || !this->pptr())))
(in && !(m_mode & std::ios_base::in)) ||
(out && !(m_mode & std::ios_base::out)))
{
return pos_type(off_type(-1));
}