projects
/
libc-test
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7db6246
)
fix fnmatch flag printing and add a few new (regression) test cases
author
Szabolcs Nagy
<nsz@port70.net>
Thu, 5 Dec 2013 01:18:56 +0000
(
01:18
+0000)
committer
Szabolcs Nagy
<nsz@port70.net>
Thu, 5 Dec 2013 01:18:56 +0000
(
01:18
+0000)
src/functional/fnmatch.c
patch
|
blob
|
history
diff --git
a/src/functional/fnmatch.c
b/src/functional/fnmatch.c
index
e822456
..
beb79b9
100644
(file)
--- 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;
{
static char buf[1000];
char *sep;
+ int n;
if (!flags) {
sprintf(buf, "0");
return buf;
}
if (!flags) {
sprintf(buf, "0");
return buf;
}
+ n = 0;
sep = "";
for (; map->str; map++) {
if (map->val && (flags & map->val) == map->val) {
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);
}
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 },
{ "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)
};
int main(void)