- char c, last_endl = 0;
- bool end_line = FALSE;
- wxString line;
-
- while (!end_line) {
- c = m_input->GetC();
- if (m_input->LastError() != wxStream_NOERROR)
- break;
-
- switch (c) {
- case '\n':
- end_line = TRUE;
- break;
- case '\r':
- last_endl = '\r';
- break;
- default:
- if (last_endl == '\r') {
- end_line = TRUE;
- m_input->Ungetch(c);
- break;
- }
- line += c;
- break;
- }
- }
- return line;
-}
-
-wxTextInputStream& wxTextInputStream::operator>>(wxString& line)
-{
- line = ReadString();
- return *this;
+ return ReadLine();
+}
+
+wxString wxTextInputStream::ReadLine()
+{
+ wxString line;
+
+ while ( !m_input.Eof() )
+ {
+#if wxUSE_UNICODE
+ // FIXME: this is only works for single byte encodings
+ // How-to read a single char in an unkown encoding???
+ char buf[10];
+ buf[0] = m_input.GetC();
+ buf[1] = 0;
+
+ wxChar wbuf[2];
+ m_conv.MB2WC( wbuf, buf, 2 );
+ wxChar c = wbuf[0];
+#else
+ char c = m_input.GetC();
+#endif
+
+ if ( !m_input )
+ break;
+
+ if (EatEOL(c))
+ break;
+
+ line += c;
+ }
+
+ return line;
+}
+
+wxString wxTextInputStream::ReadWord()
+{
+ wxString word;
+
+ if ( !m_input )
+ return word;
+
+ wxChar c = NextNonSeparators();
+ if ( !c )
+ return word;
+
+ word += c;
+
+ while ( !m_input.Eof() )
+ {
+ c = m_input.GetC();
+
+ if (!m_input)
+ break;
+
+ if (m_separators.Contains(c))
+ break;
+
+ if (EatEOL(c))
+ break;
+
+ word += c;
+ }
+
+ return word;
+}
+
+wxTextInputStream& wxTextInputStream::operator>>(wxString& word)
+{
+ word = ReadWord();
+ return *this;