+ string best;
+ unsigned best_quality = 0;
+ for(const string &n: names)
+ {
+ unsigned quality;
+ if(match_name(n, &quality))
+ if(quality>best_quality)
+ {
+ best = n;
+ best_quality = quality;
+ }
+ }
+
+ return best;
+}
+
+template<typename T>
+void Architecture::add_pattern(const string &pat)
+{
+ filename_patterns[typeid(T).name()].push_back(Pattern(pat));
+}
+
+void Architecture::resolve_aliases(vector<string> &parts)
+{
+ for(unsigned i=0; i<parts.size(); ++i)
+ {
+ const string &part = parts[i];
+ const char *replace = 0;
+ for(unsigned j=0; (!replace && aliases[j]); j+=2)
+ if(part==aliases[j])
+ replace = aliases[j+1];
+
+ if(replace)
+ {
+ bool has_dash = false;
+ for(const char *c=replace; (!has_dash && *c); ++c)
+ has_dash = (*c=='-');