Merge pull request #125 from lioncash/cdghz

cdvdGigaherz: Simplify the loops within readLine and readLineW
This commit is contained in:
David Quintana 2014-07-15 11:53:36 +02:00
commit 1736c1e32e
1 changed files with 14 additions and 20 deletions

View File

@ -98,20 +98,17 @@ int FileStream::read(byte* b, int len)
string FileStream::readLine() string FileStream::readLine()
{ {
string s; string s;
char c;
s.clear(); s.clear();
do { while (!eof())
if(eof()) {
char c = read();
if ((c == '\n') || (c == '\r') || (c == '\0'))
break; break;
c = read(); s.append(1, c);
}
if((c=='\n')||(c=='\r')||(c==0))
break;
s.append(1,c);
} while(true);
return s; return s;
} }
@ -119,20 +116,17 @@ string FileStream::readLine()
wstring FileStream::readLineW() wstring FileStream::readLineW()
{ {
wstring s; wstring s;
wchar_t c;
s.clear(); s.clear();
do { while (!eof())
if(eof()) {
wchar_t c = read<wchar_t>();
if ((c == L'\n') || (c == L'\r') || (c == L'\0'))
break; break;
c = read<wchar_t>(); s.append(1, c);
}
if((c==L'\n')||(c==L'\r')||(c==0))
break;
s.append(1,c);
} while(true);
return s; return s;
} }