Fixed Trac #5139 ("Initial Stream Position in Boost.Interprocess.Vectorstream")

This commit is contained in:
Ion Gaztañaga
2015-06-24 16:18:17 +02:00
parent 5c090a64be
commit e352a84dd2
5 changed files with 20 additions and 5 deletions

View File

@@ -6734,6 +6734,7 @@ thank them:
[section:release_notes_boost_1_59_00 Boost 1.59 Release]
* Fixed bugs:
* [@https://svn.boost.org/trac/boost/ticket/5139 ( Trac #5139 ( (['"Initial Stream Position in Boost.Interprocess.Vectorstream"])].
* [@https://github.com/boostorg/interprocess/pull/19 GitHub Pull #19 (['"Fix exception visibility"])]. Thanks to Romain-Geissler.
[endsect]

View File

@@ -200,8 +200,8 @@ class basic_bufferbuf
if(!in && !out)
return pos_type(off_type(-1));
else if((in && (!(m_mode & std::ios_base::in) || this->gptr() == 0)) ||
(out && (!(m_mode & std::ios_base::out) || this->pptr() == 0)))
else if((in && (!(m_mode & std::ios_base::in) || (off != 0 && this->gptr() == 0) )) ||
(out && (!(m_mode & std::ios_base::out) || (off != 0 && this->pptr() == 0))))
return pos_type(off_type(-1));
std::streamoff newoff;

View File

@@ -298,8 +298,8 @@ class basic_vectorbuf
return pos_type(off_type(-1));
else if((in && out) && (dir == std::ios_base::cur))
return pos_type(off_type(-1));
else if((in && (!(m_mode & std::ios_base::in) || this->gptr() == 0)) ||
(out && (!(m_mode & std::ios_base::out) || this->pptr() == 0)))
else if((in && (!(m_mode & std::ios_base::in) || (off != 0 && this->gptr() == 0) )) ||
(out && (!(m_mode & std::ios_base::out) || (off != 0 && this->pptr() == 0))))
return pos_type(off_type(-1));
off_type newoff;

View File

@@ -34,6 +34,12 @@ static int bufferstream_test()
//This will be zero-initialized
static char buffer [BufSize];
bufferstream bufstream;
if(bufstream.tellg() != std::streampos(0)){
return 1;
}
if(bufstream.tellp() != std::streampos(0)){
return 1;
}
std::stringstream std_stringstream;
std::string str1, str2, str3("testline:");
int number1, number2;
@@ -129,7 +135,7 @@ static int bufferstream_test()
int main ()
{
if(bufferstream_test()==-1){
if(bufferstream_test()){
return 1;
}
return 0;

View File

@@ -39,6 +39,14 @@ static int vectorstream_test()
{
{ //Test high watermarking initialization
my_stringstream_t my_stringstream;
if(my_stringstream.tellg() != std::streampos(0)){
return 1;
}
if(my_stringstream.tellp() != std::streampos(0)){
return 1;
}
int a (0);
my_stringstream << 11;
my_stringstream >> a;