+ for (n = 0; n < nRead; n++)
+ {
+ ch = buf[n];
+ switch ( ch )
+ {
+ case '\n':
+ // Dos/Unix line termination
+ *strPtr = '\0';
+ AddLine(wxString(strBuf, conv),
+ chLast == '\r' ? wxTextFileType_Dos
+ : wxTextFileType_Unix);
+ strPtr = strBuf;
+ chLast = '\n';
+ break;
+
+ case '\r':
+ if ( chLast == '\r' )
+ {
+ // Mac empty line
+ AddLine(wxEmptyString, wxTextFileType_Mac);
+ }
+ else
+ chLast = '\r';
+ break;
+
+ default:
+ if ( chLast == '\r' )
+ {
+ // Mac line termination
+ *strPtr = '\0';
+ AddLine(wxString(strBuf, conv), wxTextFileType_Mac);
+ chLast = ch;
+ strPtr = strBuf;
+ *(strPtr++) = ch;
+ }
+ else
+ {
+ // add to the current line
+ *(strPtr++) = ch;
+ if ( strPtr == strEnd )
+ {
+ // we must allocate more memory
+ size_t size = strEnd - strBuf;
+ char *newBuf = new char[size + 1024];
+ memcpy(newBuf, strBuf, size);
+ delete[] strBuf;
+ strBuf = newBuf;
+ strEnd = strBuf + size + 1024;
+ strPtr = strBuf + size;
+ }
+ }
+ }
+ }
+ } while ( nRead == WXSIZEOF(buf) );