Simplify the code in wxTextFile::OnRead() slightly.
No real changes, just use a self-explanatory "lastWasCR" variable instead of storing the last character read which wasn't used for anything except comparing it with '\r'. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75010 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -208,8 +208,8 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
||||
|
||||
// now break the buffer in lines
|
||||
|
||||
// last processed character, we need to know if it was a CR or not
|
||||
wxChar chLast = '\0';
|
||||
// was the last processed character a CR?
|
||||
bool lastWasCR = false;
|
||||
|
||||
// the beginning of the current line, changes inside the loop
|
||||
wxString::const_iterator lineStart = str.begin();
|
||||
@@ -221,7 +221,7 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
||||
{
|
||||
case '\n':
|
||||
// could be a DOS or Unix EOL
|
||||
if ( chLast == '\r' )
|
||||
if ( lastWasCR )
|
||||
{
|
||||
if ( p - 1 >= lineStart )
|
||||
{
|
||||
@@ -239,10 +239,11 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
||||
}
|
||||
|
||||
lineStart = p + 1;
|
||||
lastWasCR = false;
|
||||
break;
|
||||
|
||||
case '\r':
|
||||
if ( chLast == '\r' )
|
||||
if ( lastWasCR )
|
||||
{
|
||||
// Mac empty line
|
||||
AddLine(wxEmptyString, wxTextFileType_Mac);
|
||||
@@ -250,10 +251,12 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
||||
}
|
||||
//else: we don't know what this is yet -- could be a Mac EOL or
|
||||
// start of DOS EOL so wait for next char
|
||||
|
||||
lastWasCR = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( chLast == '\r' )
|
||||
if ( lastWasCR )
|
||||
{
|
||||
// Mac line termination
|
||||
if ( p - 1 >= lineStart )
|
||||
@@ -267,9 +270,8 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
||||
}
|
||||
lineStart = p;
|
||||
}
|
||||
lastWasCR = false;
|
||||
}
|
||||
|
||||
chLast = ch;
|
||||
}
|
||||
|
||||
// anything in the last line?
|
||||
@@ -280,7 +282,7 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
||||
// be followed by a LF.
|
||||
wxString lastLine(lineStart, end);
|
||||
wxTextFileType lastType;
|
||||
if ( chLast == '\r' )
|
||||
if ( lastWasCR )
|
||||
{
|
||||
// last line had Mac EOL, exclude it from the string
|
||||
lastLine.RemoveLast();
|
||||
|
Reference in New Issue
Block a user