render.cpp: print a warning and continue on encountering malformed XML in a layout file (nw)

This commit is contained in:
Vas Crabb 2019-09-08 22:13:02 +10:00
parent 68d38ecac6
commit fde41f3fad
2 changed files with 31 additions and 7 deletions

View File

@ -2057,7 +2057,27 @@ bool render_target::load_layout_file(const char *dirname, const char *filename)
return false;
// read the file
util::xml::file::ptr rootnode(util::xml::file::read(layoutfile, nullptr));
util::xml::parse_options parseopt;
util::xml::parse_error parseerr;
parseopt.error = &parseerr;
util::xml::file::ptr rootnode(util::xml::file::read(layoutfile, &parseopt));
if (!rootnode)
{
if (parseerr.error_message)
{
osd_printf_warning(
"Error parsing XML file '%s' at line %d column %d: %s, ignoring\n",
filename,
parseerr.error_line,
parseerr.error_column,
parseerr.error_message);
}
else
{
osd_printf_warning("Error parsing XML file '%s', ignorning\n", filename);
}
return false;
}
// if we didn't get a properly-formatted XML file, record a warning and exit
if (!load_layout_file(m_manager.machine().root_device(), dirname, *rootnode))

View File

@ -45,18 +45,22 @@ enum
/* extended error information from parsing */
struct parse_error
{
const char * error_message;
int error_line;
int error_column;
parse_error() = default;
const char * error_message = nullptr;
int error_line = 0;
int error_column = 0;
};
// parsing options
struct parse_options
{
parse_error * error;
void (*init_parser)(XML_ParserStruct *parser);
uint32_t flags;
parse_options() = default;
parse_error * error = nullptr;
void (*init_parser)(XML_ParserStruct *parser) = nullptr;
uint32_t flags = 0;
};