This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] std::quoted is too eager to clear the string
- From: larsbj at gullik dot org (Lars Gullik Bjønnes)
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, libstdc++ at gcc dot gnu dot org
- Date: Fri, 21 Feb 2014 01:00:13 +0100
- Subject: [PATCH] std::quoted is too eager to clear the string
- Authentication-results: sourceware.org; auth=none
* include/std/iomanip (_Quoted_string operator>>): Do not clear
string if input is not quoted.
Currently the string is cleared regardless of
how the string is handled. This patch just
moves the clearing down so that we do not clear
it if we are not going to quote the string
(i.e. let operator>> handle the clearing if needed)
and also not if we encounter any stream error.
This has been reported as (bug 60270).
I have no GCC paperwork in order, but I expect this change
to be simple enough to not require that.
---
libstdc++-v3/include/std/iomanip | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip
index b2c7b95..73822db 100644
--- a/libstdc++-v3/include/std/iomanip
+++ b/libstdc++-v3/include/std/iomanip
@@ -415,8 +415,6 @@ _GLIBCXX_END_NAMESPACE_VERSION
const _Quoted_string<basic_string<_CharT, _Traits, _Alloc>&,
_CharT>& __str)
{
- __str._M_string.clear();
-
_CharT __c;
__is >> __c;
if (!__is.good())
@@ -427,6 +425,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
__is >> __str._M_string;
return __is;
}
+ __str._M_string.clear();
std::ios_base::fmtflags __flags
= __is.flags(__is.flags() & ~std::ios_base::skipws);
do
--
1.9.0
--
Lgb