diff options
-rw-r--r-- | pages/searchresults.ecpp | 6 | ||||
-rw-r--r-- | tools.cpp | 35 |
2 files changed, 33 insertions, 8 deletions
diff --git a/pages/searchresults.ecpp b/pages/searchresults.ecpp index dce7520..0cf1e2c 100644 --- a/pages/searchresults.ecpp +++ b/pages/searchresults.ecpp @@ -61,8 +61,10 @@ bool logged_in(false); string current_day = ""; for (SearchResults::iterator result = results.begin(); result != results.end(); ++result) { - string channelname = Channels.GetByChannelID(result->Channel())->Name(); - int channelnr = Channels.GetByChannelID(result->Channel())->Number(); + cChannel* channel = Channels.GetByChannelID(result->Channel()); + if (!channel) continue; + string channelname = channel->Name(); + int channelnr = channel->Number(); string start(result->StartTime() ? FormatDateTime(tr("%I:%M %p"), result->StartTime()) : ""); string end(result->StopTime() ? FormatDateTime(tr("%I:%M %p"), result->StopTime()) : ""); string day(result->StartTime() ? FormatDateTime(tr("%A, %b %d %Y"), result->StartTime()) : ""); @@ -17,12 +17,35 @@ using namespace tnt; istream& operator>>( istream& is, tChannelID& ret ) { - if ( is.rdbuf()->in_avail() > 0 ) { - string line; - if ( !getline( is, line ) || ( !line.empty() && !( ret = tChannelID::FromString( line.c_str() ) ).Valid() ) ) - is.setstate( ios::badbit ); - } - return is; + /* alternativ implementation + string line; + if ( !getline( is, line ) ) { + if ( !is.eof() ) + is.setstate( ios::badbit ); + else + is.clear(); + 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 { |