+ const wxStreamError err = inStream.GetLastError();
+
+ if ( err != wxSTREAM_NO_ERROR && err != wxSTREAM_EOF )
+ {
+ wxLogError(_("Error reading config options."));
+ break;
+ }
+ }
+ while ( !inStream.Eof() );
+
+#if wxUSE_UNICODE
+ size_t len;
+ str = conv.cMB2WC((char *)buf.GetData(), buf.GetDataLen(), &len);
+ if ( !len && buf.GetDataLen() )
+ {
+ wxLogError(_("Failed to read config options."));
+ }
+#else // !wxUSE_UNICODE
+ // no need for conversion
+ str.assign((char *)buf.GetData(), buf.GetDataLen());
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
+ }
+
+
+ // translate everything to the current (platform-dependent) line
+ // termination character
+ str = wxTextBuffer::Translate(str);
+
+ wxMemoryText memText;
+
+ // Now we can add the text to the memory text. To do this we extract line
+ // by line from the translated string, until we've reached the end.
+ //
+ // VZ: all this is horribly inefficient, we should do the translation on
+ // the fly in one pass saving both memory and time (TODO)
+
+ const wxChar *pEOL = wxTextBuffer::GetEOL(wxTextBuffer::typeDefault);
+ const size_t EOLLen = wxStrlen(pEOL);
+
+ int posLineStart = str.Find(pEOL);
+ while ( posLineStart != -1 )
+ {
+ wxString line(str.Left(posLineStart));
+
+ memText.AddLine(line);
+
+ str = str.Mid(posLineStart + EOLLen);
+
+ posLineStart = str.Find(pEOL);
+ }
+
+ // also add whatever we have left in the translated string.
+ if ( !str.empty() )
+ memText.AddLine(str);
+
+ // Finally we can parse it all.
+ Parse(memText, true /* local */);
+
+ SetRootPath();
+ ResetDirty();