From d00342a76f291e9a01548b90ebfe3334959ce7aa Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sat, 22 Mar 2008 00:46:17 +0100 Subject: An other attempt to fix operator>> for tChannelID. --- tools.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'tools.cpp') diff --git a/tools.cpp b/tools.cpp index 3a80ff7..b8c23ab 100644 --- a/tools.cpp +++ b/tools.cpp @@ -17,16 +17,21 @@ using namespace tnt; istream& operator>>( istream& is, tChannelID& ret ) { - string line; - if ( !getline( is, line ) ) { - if ( !is.eof() ) - is.setstate( ios::badbit ); - return is; - } - - if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) - is.setstate( ios::badbit ); - return is; + string line; + if (!getline( is, line ) ) { + if (0 == is.gcount()) { + is.clear(is.rdstate() & ~ios::failbit); + return is; + } + if (!is.eof()) { + is.setstate( ios::badbit ); + return is; + } + } + + if ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) + is.setstate( ios::badbit ); + return is; } namespace vdrlive { -- cgit v1.2.3