+ string best;
+ unsigned best_size = 0;
+ for(const string &n: names)
+ if(match_name(n))
+ {
+ /* TODO Do full parse and alias resolution here? Otherwise x86 and
+ x86_64 are treated as equally good, even though the latter is more
+ specific. */
+ unsigned size = 1;
+ for(char c: n)
+ size += (c=='-');
+
+ if(size>best_size)
+ {
+ best = n;
+ best_size = size;
+ }
+ }
+
+ 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=='-');