summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/info.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/info.cpp')
-rw-r--r--src/frontend/mame/info.cpp51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp
index fa836b27abe..05037fda65d 100644
--- a/src/frontend/mame/info.cpp
+++ b/src/frontend/mame/info.cpp
@@ -189,8 +189,9 @@ const char info_xml_creator::s_dtd_string[] =
// info_xml_creator - constructor
//-------------------------------------------------
-info_xml_creator::info_xml_creator(emu_options const &options)
- : m_output(nullptr)
+info_xml_creator::info_xml_creator(emu_options const &options, bool dtd)
+ : m_output(nullptr),
+ m_dtd(dtd)
{
}
@@ -209,12 +210,12 @@ void info_xml_creator::output(FILE *out, std::vector<std::string> const &pattern
// track which patterns match machines
driver_enumerator drivlist(m_lookup_options);
std::vector<bool> matched(patterns.size(), false);
- auto const included = [&patterns, &drivlist, &matched] () -> bool
+ size_t exact_matches = 0;
+ auto const included = [&patterns, &drivlist, &matched, &exact_matches] (char const *const name) -> bool
{
if (patterns.empty())
return true;
- char const *const name = drivlist.driver().name;
bool result = false;
auto it = matched.begin();
for (std::string const &pat : patterns)
@@ -222,7 +223,12 @@ void info_xml_creator::output(FILE *out, std::vector<std::string> const &pattern
if (!core_strwildcmp(pat.c_str(), name))
{
result = true;
- *it = true;
+ if (!*it)
+ {
+ *it = true;
+ if (!core_iswildstr(pat.c_str()))
+ ++exact_matches;
+ }
}
++it;
}
@@ -233,7 +239,7 @@ void info_xml_creator::output(FILE *out, std::vector<std::string> const &pattern
bool first = true;
while (drivlist.next())
{
- if (included())
+ if (included(drivlist.driver().name))
{
if (first)
{
@@ -241,6 +247,24 @@ void info_xml_creator::output(FILE *out, std::vector<std::string> const &pattern
first = false;
}
output_one(drivlist, devfilter.get());
+
+ // stop looking if we found everything specified
+ if (!patterns.empty() && exact_matches == patterns.size())
+ break;
+ }
+ }
+
+ // iterate through the device types if not everything matches a driver
+ if (!patterns.empty() && exact_matches != patterns.size())
+ {
+ for (device_type type : registered_device_types)
+ {
+ if (included(type.shortname()))
+ {
+ devfilter->insert(&type);
+ if (exact_matches == patterns.size())
+ break;
+ }
}
}
@@ -302,13 +326,16 @@ void info_xml_creator::output(FILE *out, driver_enumerator &drivlist, bool nodev
void info_xml_creator::output_header()
{
- // output the DTD
- fprintf(m_output, "<?xml version=\"1.0\"?>\n");
- std::string dtd(s_dtd_string);
- strreplace(dtd, "__XML_ROOT__", XML_ROOT);
- strreplace(dtd, "__XML_TOP__", XML_TOP);
+ if (m_dtd)
+ {
+ // output the DTD
+ fprintf(m_output, "<?xml version=\"1.0\"?>\n");
+ std::string dtd(s_dtd_string);
+ strreplace(dtd, "__XML_ROOT__", XML_ROOT);
+ strreplace(dtd, "__XML_TOP__", XML_TOP);
- fprintf(m_output, "%s\n\n", dtd.c_str());
+ fprintf(m_output, "%s\n\n", dtd.c_str());
+ }
// top-level tag
fprintf(m_output, "<%s build=\"%s\" debug=\""