End of lines are tricky as they vary between platforms, but the docs states
The wxTextInputStream correctly reads text files (or streams) in DOS, Macintosh and Unix formats and reports a single newline char as a line ending.
However, I do not see any way to retrieve the EOL type wxTextInputStream uses, and it is not documented how it decides which one to use.
It seems that EOLs are processed with this code
Code: Select all
bool wxTextInputStream::EatEOL(const wxChar &c)
{
if (c == wxT('\n')) return true; // eat on UNIX
if (c == wxT('\r')) // eat on both Mac and DOS
{
wxChar c2 = GetChar();
if (!c2) return true; // end of stream reached, had enough :-)
if (c2 != wxT('\n')) UngetLast(); // Don't eat on Mac
return true;
}
return false;
}
Out of curiosity, if you open the file with wxTextFile, does its GetLineCount() return the number you think it should?
I know it sounds silly but I would also check if numLines is initialized to 0. Also, just to be sure , I would change
Code: Select all
while(input.IsOk() && !input.Eof() )
to
Code: Select all
while(text.IsOk() && !text.Eof() )