XML code fixes (patch #815196 -- backported to 2.4)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@24013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -538,8 +538,10 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
|
|||||||
done = (len < BUFSIZE);
|
done = (len < BUFSIZE);
|
||||||
if (!XML_Parse(parser, buf, len, done))
|
if (!XML_Parse(parser, buf, len, done))
|
||||||
{
|
{
|
||||||
|
wxString error(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
|
*wxConvCurrent);
|
||||||
wxLogError(_("XML parsing error: '%s' at line %d"),
|
wxLogError(_("XML parsing error: '%s' at line %d"),
|
||||||
XML_ErrorString(XML_GetErrorCode(parser)),
|
error.c_str(),
|
||||||
XML_GetCurrentLineNumber(parser));
|
XML_GetCurrentLineNumber(parser));
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
break;
|
break;
|
||||||
@@ -548,10 +550,16 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
|
|||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
SetVersion(ctx.version);
|
if (!ctx.version.IsEmpty())
|
||||||
SetFileEncoding(ctx.encoding);
|
SetVersion(ctx.version);
|
||||||
|
if (!ctx.encoding.IsEmpty())
|
||||||
|
SetFileEncoding(ctx.encoding);
|
||||||
SetRoot(ctx.root);
|
SetRoot(ctx.root);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete ctx.root;
|
||||||
|
}
|
||||||
|
|
||||||
XML_ParserFree(parser);
|
XML_ParserFree(parser);
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
@@ -575,7 +583,7 @@ inline static void OutputString(wxOutputStream& stream, const wxString& str,
|
|||||||
{
|
{
|
||||||
if (str.IsEmpty()) return;
|
if (str.IsEmpty()) return;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8));
|
const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
|
||||||
stream.Write((const char*)buf, strlen((const char*)buf));
|
stream.Write((const char*)buf, strlen((const char*)buf));
|
||||||
#else
|
#else
|
||||||
if ( convFile == NULL )
|
if ( convFile == NULL )
|
||||||
|
@@ -538,8 +538,10 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
|
|||||||
done = (len < BUFSIZE);
|
done = (len < BUFSIZE);
|
||||||
if (!XML_Parse(parser, buf, len, done))
|
if (!XML_Parse(parser, buf, len, done))
|
||||||
{
|
{
|
||||||
|
wxString error(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
|
*wxConvCurrent);
|
||||||
wxLogError(_("XML parsing error: '%s' at line %d"),
|
wxLogError(_("XML parsing error: '%s' at line %d"),
|
||||||
XML_ErrorString(XML_GetErrorCode(parser)),
|
error.c_str(),
|
||||||
XML_GetCurrentLineNumber(parser));
|
XML_GetCurrentLineNumber(parser));
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
break;
|
break;
|
||||||
@@ -548,10 +550,16 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding)
|
|||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
SetVersion(ctx.version);
|
if (!ctx.version.IsEmpty())
|
||||||
SetFileEncoding(ctx.encoding);
|
SetVersion(ctx.version);
|
||||||
|
if (!ctx.encoding.IsEmpty())
|
||||||
|
SetFileEncoding(ctx.encoding);
|
||||||
SetRoot(ctx.root);
|
SetRoot(ctx.root);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete ctx.root;
|
||||||
|
}
|
||||||
|
|
||||||
XML_ParserFree(parser);
|
XML_ParserFree(parser);
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
@@ -575,7 +583,7 @@ inline static void OutputString(wxOutputStream& stream, const wxString& str,
|
|||||||
{
|
{
|
||||||
if (str.IsEmpty()) return;
|
if (str.IsEmpty()) return;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
const wxWX2MBbuf buf(str.mb_str(convFile ? *convFile : wxConvUTF8));
|
const wxWX2MBbuf buf(str.mb_str(*(convFile ? convFile : &wxConvUTF8)));
|
||||||
stream.Write((const char*)buf, strlen((const char*)buf));
|
stream.Write((const char*)buf, strlen((const char*)buf));
|
||||||
#else
|
#else
|
||||||
if ( convFile == NULL )
|
if ( convFile == NULL )
|
||||||
|
Reference in New Issue
Block a user