{
static char buf[1000];
char *sep;
+ int n;
if (!flags) {
sprintf(buf, "0");
return buf;
}
+ n = 0;
sep = "";
for (; map->str; map++) {
if (map->val && (flags & map->val) == map->val) {
- sprintf(buf, "%s%s", sep, map->str);
+ n += sprintf(buf+n, "%s%s", sep, map->str);
sep = "|";
flags &= ~(map->val);
}
{ "a?b", "a.b", FNM_PATHNAME|FNM_PERIOD, 0 },
{ "a*b", "a.b", FNM_PATHNAME|FNM_PERIOD, 0 },
{ "a[.]b", "a.b", FNM_PATHNAME|FNM_PERIOD, 0 },
+
+ /* posix 2008 is unclear about these cases */
+ { "\\", "\\", 0, 0 },
+ { "\\", "", 0, FNM_NOMATCH },
+
+ /* musl bug fixed in da0fcdb8e913ca7cdf8931328f2b37e93309b2c5 */
+ { "/", "\0", FNM_PATHNAME, FNM_NOMATCH },
+ /* musl bug fixed in 6ec82a3b58ee1b873ff0dfad8fa9d41c3d25dcc0 */
+ { "\\/", "/", FNM_PATHNAME, 0 },
};
int main(void)
r = fnmatch(tests[i].pattern, tests[i].string, tests[i].flags);
x = tests[i].expected;
if (r != x && (r != FNM_NOMATCH || x != -FNM_NOMATCH)) {
- error("fnmatch(\"%s\", \"%s\", %s) failed, got %d want %d\n",
+ t_error("fnmatch(\"%s\", \"%s\", %s) failed, got %d want %d\n",
tests[i].pattern, tests[i].string,
flagstr(fnmatch_flags, tests[i].flags),
r, x);
}
}
- return test_status;
+ return t_status;
}