COMMON: Remove vfprintf call from XML parser
This commit is contained in:
parent
ac1c2124e5
commit
a6e5b97e9f
5 changed files with 35 additions and 43 deletions
|
@ -23,9 +23,6 @@
|
|||
// FIXME: Avoid using fprintf
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
|
||||
|
||||
// FIXME: Avoid using vfprintf
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf
|
||||
|
||||
|
||||
#include "common/xmlparser.h"
|
||||
#include "common/archive.h"
|
||||
|
@ -83,7 +80,7 @@ void XMLParser::close() {
|
|||
_stream = 0;
|
||||
}
|
||||
|
||||
bool XMLParser::parserError(const char *errorString, ...) {
|
||||
bool XMLParser::parserError(const Common::String &errStr) {
|
||||
_state = kParserError;
|
||||
|
||||
const int startPosition = _stream->pos();
|
||||
|
@ -134,12 +131,7 @@ bool XMLParser::parserError(const char *errorString, ...) {
|
|||
fprintf(stderr, "%c", _stream->readByte());
|
||||
|
||||
fprintf(stderr, "\n\nParser error: ");
|
||||
|
||||
va_list args;
|
||||
va_start(args, errorString);
|
||||
vfprintf(stderr, errorString, args);
|
||||
va_end(args);
|
||||
|
||||
fprintf(stderr, "%s", errStr.c_str());
|
||||
fprintf(stderr, "\n\n");
|
||||
|
||||
return false;
|
||||
|
@ -181,16 +173,16 @@ bool XMLParser::parseActiveKey(bool closed) {
|
|||
|
||||
for (List<XMLKeyLayout::XMLKeyProperty>::const_iterator i = key->layout->properties.begin(); i != key->layout->properties.end(); ++i) {
|
||||
if (i->required && !localMap.contains(i->name))
|
||||
return parserError("Missing required property '%s' inside key '%s'", i->name.c_str(), key->name.c_str());
|
||||
return parserError("Missing required property '" + i->name + "' inside key '" + key->name + "'");
|
||||
else if (localMap.contains(i->name))
|
||||
keyCount--;
|
||||
}
|
||||
|
||||
if (keyCount > 0)
|
||||
return parserError("Unhandled property inside key '%s'.", key->name.c_str());
|
||||
return parserError("Unhandled property inside key '" + key->name + "'.");
|
||||
|
||||
} else {
|
||||
return parserError("Unexpected key in the active scope ('%s').", key->name.c_str());
|
||||
return parserError("Unexpected key in the active scope ('" + key->name + "').");
|
||||
}
|
||||
|
||||
// check if any of the parents must be ignored.
|
||||
|
@ -205,7 +197,7 @@ bool XMLParser::parseActiveKey(bool closed) {
|
|||
// when keyCallback() fails, a parserError() must be set.
|
||||
// We set it manually in that case.
|
||||
if (_state != kParserError)
|
||||
parserError("Unhandled exception when parsing '%s' key.", key->name.c_str());
|
||||
parserError("Unhandled exception when parsing '" + key->name + "' key.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -395,7 +387,7 @@ bool XMLParser::parse() {
|
|||
case kParserNeedPropertyName:
|
||||
if (activeClosure) {
|
||||
if (!closeKey()) {
|
||||
parserError("Missing data when closing key '%s'.", _activeKey.top()->name.c_str());
|
||||
parserError("Missing data when closing key '" + _activeKey.top()->name + "'.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue