From: Szabolcs Nagy Date: Thu, 5 Dec 2013 01:18:56 +0000 (+0000) Subject: fix fnmatch flag printing and add a few new (regression) test cases X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=fd0899849a938ac2fd224b1c7fe6c8b0e61e4990 fix fnmatch flag printing and add a few new (regression) test cases --- diff --git a/src/functional/fnmatch.c b/src/functional/fnmatch.c index e822456..beb79b9 100644 --- a/src/functional/fnmatch.c +++ b/src/functional/fnmatch.c @@ -23,15 +23,17 @@ static char *flagstr(const struct xlat *map, int flags) { 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); } @@ -116,6 +118,15 @@ struct { { "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)