77#include < fstream>
88#include < sstream>
99#include < filesystem>
10+ #include < regex>
1011
1112static std::string rm_leading_dashes (const std::string & str) {
1213 size_t pos = 0 ;
@@ -16,6 +17,23 @@ static std::string rm_leading_dashes(const std::string & str) {
1617 return str.substr (pos);
1718}
1819
20+ static std::string canonical_tag (const std::string & tag) {
21+ static const std::regex re_tag (" [-.]([A-Z0-9_]+)$" , std::regex::icase);
22+ std::smatch m;
23+ if (std::regex_search (tag, m, re_tag)) {
24+ std::string canon = m[1 ].str ();
25+ for (char & c : canon) {
26+ c = (char ) std::toupper ((unsigned char ) c);
27+ }
28+ return canon;
29+ }
30+ std::string upper = tag;
31+ for (char & c : upper) {
32+ c = (char ) std::toupper ((unsigned char ) c);
33+ }
34+ return upper;
35+ }
36+
1937std::vector<std::string> common_preset::to_args (const std::string & bin_path) const {
2038 std::vector<std::string> args;
2139
@@ -270,11 +288,18 @@ common_presets common_preset_context::load_from_ini(const std::string & path, co
270288
271289 for (auto section : ini_data) {
272290 common_preset preset;
273- if (section.first .empty ()) {
274- preset.name = COMMON_PRESET_DEFAULT_NAME ;
275- } else {
276- preset.name = section.first ;
291+ std::string section_name = section.first .empty () ? std::string (COMMON_PRESET_DEFAULT_NAME ) : section.first ;
292+ if (section_name != " *" && section_name != COMMON_PRESET_DEFAULT_NAME ) {
293+ auto colon_idx = section_name.rfind (' :' );
294+ if (colon_idx != std::string::npos) {
295+ std::string tag = section_name.substr (colon_idx + 1 );
296+ std::string canon_tag = canonical_tag (tag);
297+ if (canon_tag != tag) {
298+ section_name = section_name.substr (0 , colon_idx + 1 ) + canon_tag;
299+ }
300+ }
277301 }
302+ preset.name = section_name;
278303 LOG_DBG (" loading preset: %s\n " , preset.name .c_str ());
279304 for (const auto & [key, value] : section.second ) {
280305 if (key == " version" ) {
0 commit comments