Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4716: boost::filesystem::path operator>> drops leading slash.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-19 19:02:11
#4716: boost::filesystem::path operator>> drops leading slash.
--------------------------------------+-------------------------------------
Reporter: norman.wilson@⦠| Owner:
Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
Version: Boost 1.44.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------------+-------------------------------------
Comment (by luke@â¦):
I ran into this same issue. However, I think its actually worse than
dropping the leading slash. It drops the leading character whatever it is
unless it is a double quote.
boost\filesystem\v3\path.hpp
template <class Char, class Traits>
inline std::basic_istream<Char, Traits>&
operator>>(std::basic_istream<Char, Traits>& is, path& p)
{
std::basic_string<Char> str;
is >> boost::io::quoted(str, static_cast<Char>('&'));
p = str;
return is;
}
The problem is coming from the boost::io::quoted function.
boost\io\detail\quoted_manip.hpp
// extractor for non-const std::basic_string& proxies
template <class Char, class Traits, class Alloc>
std::basic_istream<Char, Traits>& operator>>(std::basic_istream<Char,
Traits>& is,
const quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>&
proxy)
{
Char c;
is >> c;
if (c != proxy.delim)
{
proxy.string = c;
is >> proxy.string;
return is;
}
proxy.string.clear();
{
boost::io::ios_flags_saver ifs(is);
is >> std::noskipws;
for (;;)
{
is >> c;
if (!is.good()) // cope with I/O errors or end-of-file
break;
if (c == proxy.escape)
{
is >> c;
if (!is.good()) // cope with I/O errors or end-of-file
break;
}
else if (c == proxy.delim)
break;
proxy.string += c;
}
}
return is;
}
The function is checking if the first character in the stream is a double
quote, if it is all works fine. However if its not it assigns the value
of the first character to the proxy.string and then uses the insertion
operator to get the rest of the characters. However the insertion is not
an append it is an assignment so the effect is the first character is
lost. I'm not exactly sure if this is expected behavior of this function
of not. A workaround is to change the proxy.string = c; to is.unget();
This will preserve the first character.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4716#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC