#include #include "assert.h" #include "object.h" #include "types/composites/composites.h" #include "types/equality.h" #include "types/names.h" boolean match(const object template, const object thing) { assert(template.type == stringtype); const object string = (thing.type == nametype) ? stringfrom(thing) : thing; if (string.type != stringtype) return false; if (eq(template, string) || eq(template, string("*"))) return true; return (fnmatch( (cstring)nullterminated(template, memory(longestname + 1)).string, (cstring)nullterminated(string, memory(longestname+ 1)).string, 0 ) == 0); }