Merge pull request #42 from pmconrad/getline_eof
Dont ignore EOF because users cannot distinguish EOF and empty input …
This commit is contained in:
commit
a8b85f6dcc
1 changed files with 6 additions and 11 deletions
|
|
@ -78,17 +78,12 @@ namespace fc {
|
||||||
|
|
||||||
fc::istream& getline( fc::istream& i, fc::string& s, char delim ) {
|
fc::istream& getline( fc::istream& i, fc::string& s, char delim ) {
|
||||||
fc::stringstream ss;
|
fc::stringstream ss;
|
||||||
try
|
char c;
|
||||||
{
|
i.read( &c, 1 );
|
||||||
char c;
|
while( true ) {
|
||||||
i.read( &c, 1 );
|
if( c == delim ) { s = ss.str(); return i; }
|
||||||
while( true ) {
|
if( c != '\r' ) ss.write(&c,1);
|
||||||
if( c == delim ) { s = ss.str(); return i; }
|
i.read( &c, 1 );
|
||||||
if( c != '\r' ) ss.write(&c,1);
|
|
||||||
i.read( &c, 1 );
|
|
||||||
}
|
|
||||||
} catch ( fc::eof_exception& )
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
s = ss.str();
|
s = ss.str();
|
||||||
return i;
|
return i;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue