Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 5, 2023
1 parent cb1cfd9 commit 96a4e56
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions src/xml/xmlparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,17 @@

namespace XML {

thread_local Common::UString kParseError;
static void errorFuncUString(void *ctx, const char *msg, ...) {
Common::UString *str = static_cast<Common::UString *>(ctx);
assert(str);

fprintf(stderr, "!!1 %d\n", STRINGBUFLEN);

char buf[STRINGBUFLEN];
va_list va;

va_start(va, msg);
vsnprintf(buf, STRINGBUFLEN, msg, va);
va_end(va);

fprintf(stderr, "!!2 %s\n", buf);
*str += buf;
}

Expand All @@ -80,54 +76,38 @@ static void deinitXML() {


XMLParser::XMLParser(Common::ReadStream &stream, bool makeLower, const Common::UString &fileName) {
fprintf(stderr, "FOO1\n");
initXML();

BOOST_SCOPE_EXIT(void) {
fprintf(stderr, "FOO13\n");
deinitXML();
fprintf(stderr, "FOO14\n");
} BOOST_SCOPE_EXIT_END

fprintf(stderr, "FOO2\n");

//kParseError.clear();
//xmlSetGenericErrorFunc(static_cast<void *>(&kParseError), errorFuncUString);
Common::UString parseError;
xmlSetGenericErrorFunc(static_cast<void *>(&parseError), errorFuncUString);

fprintf(stderr, "FOO3\n");
const int options = XML_PARSE_NOWARNING | XML_PARSE_NOBLANKS | XML_PARSE_NONET |
XML_PARSE_NSCLEAN | XML_PARSE_NOCDATA;

fprintf(stderr, "FOO4\n");
xmlDocPtr xml = xmlReadIO(readStream, closeStream, static_cast<void *>(&stream),
fileName.c_str(), 0, options);
fprintf(stderr, "FOO5\n");
if (!xml) {
Common::Exception e;

if (!parseError.empty())
e.add("%s", parseError.c_str());

e.add("XML document failed to parse");
fprintf(stderr, "FOO5.1\n");
throw e;
}
fprintf(stderr, "FOO6\n");

BOOST_SCOPE_EXIT( (&xml) ) {
fprintf(stderr, "FOO7\n");
xmlFreeDoc(xml);
fprintf(stderr, "FOO8\n");
} BOOST_SCOPE_EXIT_END
fprintf(stderr, "FOO9\n");

xmlNodePtr root = xmlDocGetRootElement(xml);
fprintf(stderr, "FOO10\n");
if (!root) {
fprintf(stderr, "FOO10.1\n");
if (!root)
throw Common::Exception("XML document has no root node");
}
fprintf(stderr, "FOO11\n");

_rootNode.reset(new XMLNode(*root, makeLower));
fprintf(stderr, "FOO12\n");
}

XMLParser::~XMLParser() {
Expand Down

0 comments on commit 96a4e56

Please sign in to comment.