summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/softlist_dev.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-04-16 05:05:16 +1000
committer Vas Crabb <vas@vastheman.com>2020-04-16 14:04:06 +1000
commit1a5c013c330fd1a6b3d21d9bbbaf512539ae4503 (patch)
treeb3ff6b9f247bdb2f721346a6adae7157d0a66c90 /src/emu/softlist_dev.cpp
parent94ddd2d427700c5802e00adda0d3373941d06bba (diff)
(nw) softlist_dev.cpp: validate ROM labels
The free-for-all on labels in software lists is not working. There's no consistency, labels are getting excessively long, people are starting to use non-ASCII characters in labels making it harder for others to type them when manipulating files on the command line, and there's too much markup being put in labels. The length limit is 127 characters, same as for labels in MAME itself. This should be long enough to be descriptive. Remember that the Win32 path limit is 260 characters, and many applications and frameworks have issues with longer paths, including Windows Explorer and the .NET framework. Labels are used as filenames, so concessions need to be made for this. I have not abbreviated excessively long labels myself - they're currently causing 135 validity errors. Someone else can fix them. Printable ASCII characters are allowed, with a few exceptions. The exceptions are limited to characters most likely to cause issues for interactive shells and scripts: * ! - csh event substitution (very difficult to escape properly) * $ - sh varibale expansion * % - csh job control, cmd variable expansion * / - UNIX directory separator * : - sh path separator, Windows drive qualifier * \ - sh escape, Windows directory separator Most of the labels that had to be edited were using ! for markup, or using ! and % for titles in labels. Strangely, titles in labels are often forced to lower case, despite this never being enforced for software lists. There are also various other edits to titles used for labels, such as moving articles to the end (with or without a comma), or replacing spaces with underscores. As I already said, there's no consistency at all. There is far too much markup in labels. They're even being used for notes in some cases (e.g. at least one case where a dumper's name is in the label). The XML schema supports metadata - use it. For example, you can use part_id for an unrestricted display name for a software part. You can also use XML comments for notes. And while on the topic of metadata, vgmplay.xml is putting the same thing in the part_id as well as the label. The part_id should have the actual title, not the title mangled to make it more suitable for use as a filename. Addressing this would be a lot of work, given how large the file is. For now, empty data areas in software lists cause a verbose message rather than a validation warning. There are thousands of software lists using empty data areas to indicate the size/width of cartridge RAM/EEPROM/etc.
Diffstat (limited to 'src/emu/softlist_dev.cpp')
-rw-r--r--src/emu/softlist_dev.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp
index c175234f7a5..b264a3c4069 100644
--- a/src/emu/softlist_dev.cpp
+++ b/src/emu/softlist_dev.cpp
@@ -425,6 +425,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
auto const valid_name_char = [] (char ch) { return ((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'z')) || (ch == '_'); };
auto const valid_tag_char = [] (char ch) { return ((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'z')) || strchr("$.:_", u8(ch)); };
auto const valid_year_char = [] (char ch) { return isdigit(u8(ch)) || (ch == '?') || (ch == '+'); };
+ auto const valid_label_char = [] (char ch) { return (ch >= ' ') && (ch <= '~') && !strchr("!$%/:\\", u8(ch)); };
softlist_map names;
softlist_map descriptions;
@@ -526,6 +527,10 @@ void software_list_device::internal_validity_check(validity_checker &valid)
{
if (ROMENTRY_ISREGION(romp)) // if this is a region, make sure it's valid, and record the length
{
+ // if we haven't seen any items since the last region, print a warning
+ if (!items_since_region)
+ osd_printf_verbose("%s: %s part %s has empty data area '%s' (warning)\n", filename(), shortname, part.name(), last_region_name);
+
// reset our region tracking states
items_since_region = (ROMREGION_ISERASE(romp) || ROMREGION_ISDISKDATA(romp)) ? 1 : 0;
//last_region_name = romp->name().c_str();
@@ -547,6 +552,12 @@ void software_list_device::internal_validity_check(validity_checker &valid)
// track the last filename we found
last_name = romp->name().c_str();
+ // validate the name
+ if (romp->name().length() > 127)
+ osd_printf_error("%s: %s part %s ROM label '%s' exceeds maximum 127 characters\n", filename(), shortname, part.name(), romp->name());
+ if (std::find_if_not(romp->name().begin(), romp->name().end(), valid_label_char) != romp->name().end())
+ osd_printf_error("%s: %s part %s ROM label '%s' contains invalid characters\n", filename(), shortname, part.name(), romp->name());
+
// make sure the hash is valid
util::hash_collection hashes;
if (!hashes.from_internal_string(romp->hashdata().c_str()))
@@ -561,6 +572,10 @@ void software_list_device::internal_validity_check(validity_checker &valid)
osd_printf_error("%s: %s part %s ROM '%s' extends past the defined data area\n", filename(), shortname, part.name(), last_name);
}
}
+
+ // if we haven't seen any items since the last region, print a warning
+ if (!items_since_region)
+ osd_printf_verbose("%s: %s part %s has empty data area '%s' (warning)\n", filename(), shortname, part.name(), last_region_name);
}
}
}