mirror of
https://github.com/holub/mame
synced 2025-04-28 11:11:48 +03:00
Merge pull request #1129 from ajrhacker/softlist_valid
Cure software lists of validity checking errors (nw)
This commit is contained in:
commit
5bfa83100a
@ -153,7 +153,7 @@ Demonstration Tape (included with the VZ300)
|
|||||||
<software name="hamsam">
|
<software name="hamsam">
|
||||||
<description>Hamburger Sam</description>
|
<description>Hamburger Sam</description>
|
||||||
<year>????</year>
|
<year>????</year>
|
||||||
<publisher></publisher>
|
<publisher><unknown></publisher>
|
||||||
<part name="cass1" interface="vtech1_cass">
|
<part name="cass1" interface="vtech1_cass">
|
||||||
<dataarea name="cass" size="5109472">
|
<dataarea name="cass" size="5109472">
|
||||||
<rom name="hamsam.wav" size="5109472" crc="7aed86a7" sha1="b5061edb1401cea4aee97d8cd92c582c9c14e66b" offset="0" />
|
<rom name="hamsam.wav" size="5109472" crc="7aed86a7" sha1="b5061edb1401cea4aee97d8cd92c582c9c14e66b" offset="0" />
|
||||||
@ -201,7 +201,7 @@ Demonstration Tape (included with the VZ300)
|
|||||||
<software name="missile">
|
<software name="missile">
|
||||||
<description>Missile</description>
|
<description>Missile</description>
|
||||||
<year>????</year>
|
<year>????</year>
|
||||||
<publisher></publisher>
|
<publisher><unknown></publisher>
|
||||||
<part name="cass1" interface="vtech1_cass">
|
<part name="cass1" interface="vtech1_cass">
|
||||||
<dataarea name="cass" size="5109776">
|
<dataarea name="cass" size="5109776">
|
||||||
<rom name="missile.wav" size="5109776" crc="55a1fda4" sha1="1de495534447cee16d3db22b043d53b6d15f05fe" offset="0" />
|
<rom name="missile.wav" size="5109776" crc="55a1fda4" sha1="1de495534447cee16d3db22b043d53b6d15f05fe" offset="0" />
|
||||||
|
@ -56,6 +56,7 @@ private:
|
|||||||
|
|
||||||
// internal helpers
|
// internal helpers
|
||||||
template <typename T> std::vector<std::string> parse_attributes(const char **attributes, const T &attrlist);
|
template <typename T> std::vector<std::string> parse_attributes(const char **attributes, const T &attrlist);
|
||||||
|
bool parse_name_and_value(const char **attributes, std::string &name, std::string &value);
|
||||||
void add_rom_entry(const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags);
|
void add_rom_entry(const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags);
|
||||||
|
|
||||||
// expat callbacks
|
// expat callbacks
|
||||||
@ -645,7 +646,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
|
|||||||
osd_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo.longname().c_str(), swinfo.shortname().c_str());
|
osd_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo.longname().c_str(), swinfo.shortname().c_str());
|
||||||
|
|
||||||
bool is_clone = false;
|
bool is_clone = false;
|
||||||
if (swinfo.parentname().empty())
|
if (!swinfo.parentname().empty())
|
||||||
{
|
{
|
||||||
is_clone = true;
|
is_clone = true;
|
||||||
if (swinfo.parentname() == swinfo.shortname())
|
if (swinfo.parentname() == swinfo.shortname())
|
||||||
@ -659,7 +660,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
|
|||||||
|
|
||||||
if (swinfo2 == nullptr)
|
if (swinfo2 == nullptr)
|
||||||
osd_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo.parentname().c_str(), swinfo.shortname().c_str());
|
osd_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo.parentname().c_str(), swinfo.shortname().c_str());
|
||||||
else if (swinfo2->parentname().empty())
|
else if (!swinfo2->parentname().empty())
|
||||||
osd_printf_error("%s: %s is a clone of a clone\n", filename(), swinfo.shortname().c_str());
|
osd_printf_error("%s: %s is a clone of a clone\n", filename(), swinfo.shortname().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,6 +808,40 @@ std::vector<std::string> softlist_parser::parse_attributes(const char **attribut
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// parse_name_and_value - helper to parse "name"
|
||||||
|
// and "value" attribute pairs (allowing the
|
||||||
|
// latter to be defined as an empty string)
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
bool softlist_parser::parse_name_and_value(const char **attributes, std::string &name, std::string &value)
|
||||||
|
{
|
||||||
|
bool found_value = false;
|
||||||
|
|
||||||
|
// iterate over attribute/value pairs
|
||||||
|
for( ; attributes[0]; attributes += 2)
|
||||||
|
{
|
||||||
|
// if found, set the corresponding output entry to the value
|
||||||
|
if (strcmp(attributes[0], "name") == 0)
|
||||||
|
{
|
||||||
|
name = attributes[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strcmp(attributes[0], "value") == 0)
|
||||||
|
{
|
||||||
|
value = attributes[1];
|
||||||
|
found_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not found, report an unknown attribute
|
||||||
|
else
|
||||||
|
unknown_attribute(attributes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return !name.empty() && found_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// add_rom_entry - append a new ROM entry to the
|
// add_rom_entry - append a new ROM entry to the
|
||||||
// current part's list
|
// current part's list
|
||||||
@ -1011,11 +1046,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu
|
|||||||
// <info name='' value=''>
|
// <info name='' value=''>
|
||||||
else if (strcmp(tagname, "info") == 0)
|
else if (strcmp(tagname, "info") == 0)
|
||||||
{
|
{
|
||||||
static const char *attrnames[] = { "name", "value" };
|
std::string infoname, infovalue;
|
||||||
auto attrvalues = parse_attributes(attributes, attrnames);
|
|
||||||
|
|
||||||
if (!attrvalues[0].empty() && !attrvalues[1].empty())
|
if (parse_name_and_value(attributes, infoname, infovalue))
|
||||||
m_current_info->m_other_info.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]));
|
m_current_info->m_other_info.emplace_back(std::move(infoname), std::move(infovalue));
|
||||||
else
|
else
|
||||||
parse_error("Incomplete other_info definition");
|
parse_error("Incomplete other_info definition");
|
||||||
}
|
}
|
||||||
@ -1023,11 +1057,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu
|
|||||||
// <sharedfeat name='' value=''>
|
// <sharedfeat name='' value=''>
|
||||||
else if (strcmp(tagname, "sharedfeat") == 0)
|
else if (strcmp(tagname, "sharedfeat") == 0)
|
||||||
{
|
{
|
||||||
static const char *attrnames[] = { "name", "value" };
|
std::string featname, featvalue;
|
||||||
auto attrvalues = parse_attributes(attributes, attrnames);
|
|
||||||
|
|
||||||
if (!attrvalues[0].empty() && !attrvalues[1].empty())
|
if (parse_name_and_value(attributes, featname, featvalue))
|
||||||
m_current_info->m_shared_info.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]));
|
m_current_info->m_shared_info.emplace_back(std::move(featname), std::move(featvalue));
|
||||||
else
|
else
|
||||||
parse_error("Incomplete sharedfeat definition");
|
parse_error("Incomplete sharedfeat definition");
|
||||||
}
|
}
|
||||||
@ -1122,11 +1155,10 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu
|
|||||||
// <feature name='' value=''>
|
// <feature name='' value=''>
|
||||||
else if (strcmp(tagname, "feature") == 0)
|
else if (strcmp(tagname, "feature") == 0)
|
||||||
{
|
{
|
||||||
static const char *attrnames[] = { "name", "value" };
|
std::string featname, featvalue;
|
||||||
auto attrvalues = parse_attributes(attributes, attrnames);
|
|
||||||
|
|
||||||
if (!attrvalues[0].empty())
|
if (parse_name_and_value(attributes, featname, featvalue))
|
||||||
m_current_part->m_featurelist.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]));
|
m_current_part->m_featurelist.emplace_back(std::move(featname), std::move(featvalue));
|
||||||
else
|
else
|
||||||
parse_error("Incomplete feature definition");
|
parse_error("Incomplete feature definition");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user