done = (len < BUFSIZE);
if (!XML_Parse(parser, buf, len, done))
{
+ wxString error(XML_ErrorString(XML_GetErrorCode(parser)),
+ *wxConvCurrent);
wxLogError(_("XML parsing error: '%s' at line %d"),
- XML_ErrorString(XML_GetErrorCode(parser)),
+ error.c_str(),
XML_GetCurrentLineNumber(parser));
ok = false;
break;
if (ok)
{
- SetVersion(ctx.version);
- SetFileEncoding(ctx.encoding);
+ if (!ctx.version.IsEmpty())
+ SetVersion(ctx.version);
+ if (!ctx.encoding.IsEmpty())
+ SetFileEncoding(ctx.encoding);
SetRoot(ctx.root);
}
+ else
+ {
+ delete ctx.root;
+ }
XML_ParserFree(parser);
#if !wxUSE_UNICODE
{
if (str.IsEmpty()) return;
#if wxUSE_UNICODE
- const wxWX2MBbuf buf(str.mb_str(
-#ifdef __MWERKS__
- *(convFile ? convFile : &wxConvUTF8)
-#else
- convFile ? *convFile : wxConvUTF8
-#endif
- ));
+ const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
stream.Write((const char*)buf, strlen((const char*)buf));
#else
if ( convFile == NULL )