diff options
author | 2019-03-25 23:13:40 +0100 | |
---|---|---|
committer | 2019-03-25 23:13:40 +0100 | |
commit | b380514764cf857469bae61c11143a19f79a74c5 (patch) | |
tree | 63c8012e262618f08a332da31dd714281aa2c5ed /src/emu/softlist_dev.cpp | |
parent | c24473ddff715ecec2e258a6eb38960cf8c8e98e (diff) |
Revert "conflict resolution (nw)"
This reverts commit c24473ddff715ecec2e258a6eb38960cf8c8e98e, reversing
changes made to 009cba4fb8102102168ef32870892438327f3705.
Diffstat (limited to 'src/emu/softlist_dev.cpp')
-rw-r--r-- | src/emu/softlist_dev.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp index 831fc3f6734..21dfb45ba09 100644 --- a/src/emu/softlist_dev.cpp +++ b/src/emu/softlist_dev.cpp @@ -113,15 +113,14 @@ void software_list_device::find_approx_matches(const std::string &name, int matc return; // initialize everyone's states - std::vector<double> penalty(matches); + std::vector<int> penalty(matches); for (int matchnum = 0; matchnum < matches; matchnum++) { - penalty[matchnum] = 2.0; + penalty[matchnum] = 9999; list[matchnum] = nullptr; } // iterate over our info (will cause a parse if needed) - std::u32string const search(ustr_from_utf8(normalize_unicode(name, unicode_normalization_form::D, true))); for (const software_info &swinfo : get_info()) { for (const software_part &swpart : swinfo.parts()) @@ -129,13 +128,13 @@ void software_list_device::find_approx_matches(const std::string &name, int matc if ((interface == nullptr || swpart.matches_interface(interface)) && is_compatible(swpart) == SOFTWARE_IS_COMPATIBLE) { // pick the best match between driver name and description - double const longpenalty = util::edit_distance(search, ustr_from_utf8(normalize_unicode(swinfo.longname(), unicode_normalization_form::D, true))); - double const shortpenalty = util::edit_distance(search, ustr_from_utf8(normalize_unicode(swinfo.shortname(), unicode_normalization_form::D, true))); - double const curpenalty = (std::min)(longpenalty, shortpenalty); + int longpenalty = driver_list::penalty_compare(name.c_str(), swinfo.longname().c_str()); + int shortpenalty = driver_list::penalty_compare(name.c_str(), swinfo.shortname().c_str()); + int curpenalty = std::min(longpenalty, shortpenalty); // make sure it isn't already in the table bool skip = false; - for (int matchnum = 0; !skip && (matchnum < matches) && list[matchnum]; matchnum++) + for (int matchnum = 0; matchnum < matches; matchnum++) { if ((penalty[matchnum] == curpenalty) && (swinfo.longname() == list[matchnum]->longname()) && (swinfo.shortname() == list[matchnum]->shortname())) skip = true; @@ -255,16 +254,18 @@ const software_info *software_list_device::find(const std::string &look_for) // find a match (will cause a parse if needed when calling get_info) const auto &info_list = get_info(); auto iter = std::find_if( - info_list.begin(), - info_list.end(), - [&look_for, iswild] (const software_info &info) - { - const char *shortname = info.shortname().c_str(); - return (iswild && core_strwildcmp(look_for.c_str(), shortname) == 0) - || core_stricmp(look_for.c_str(), shortname) == 0; - }); - - return iter != info_list.end() ? &*iter : nullptr; + info_list.begin(), + info_list.end(), + [&](const software_info &info) + { + const char *shortname = info.shortname().c_str(); + return (iswild && core_strwildcmp(look_for.c_str(), shortname) == 0) + || core_stricmp(look_for.c_str(), shortname) == 0; + }); + + return iter != info_list.end() + ? &*iter + : nullptr; } |