diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-02-27 06:11:59 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-02-27 06:11:59 +0000 |
commit | dccf44d752604d877a379290bda10644e0844682 (patch) | |
tree | 4edf9fcf4246a199d47738f681c3fb61d4108397 | |
parent | 54f5661b439af0ab86cce0d5bf8dc79faec7d7ac (diff) | |
download | samba-dccf44d752604d877a379290bda10644e0844682.tar.gz samba-dccf44d752604d877a379290bda10644e0844682.tar.bz2 samba-dccf44d752604d877a379290bda10644e0844682.zip |
almost there with lanman1 wildcards. We now seem to correctly handle
'<', '>', '"' and '?' when combined with '.'. The '*' character is
proving troublesome.
(This used to be commit 0a55d9a17b5d98c7e151bb2ee014cfb0b3660400)
-rw-r--r-- | source3/utils/masktest.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/source3/utils/masktest.c b/source3/utils/masktest.c index a5b4888b0e..072f9eb16f 100644 --- a/source3/utils/masktest.c +++ b/source3/utils/masktest.c @@ -40,11 +40,12 @@ int ms_fnmatch_lanman_core(char *pattern, char *string) char *p = pattern, *n = string; char c; + if (strcmp(p,"?")==0 && strcmp(n,".")==0) return 0; + while ((c = *p++)) { switch (c) { case '?': - //if (! *n) return -1; - if (! *n) return ms_fnmatch_lanman_core(p, n); + if (*n == '.' || ! *n) return ms_fnmatch_lanman_core(p, n); n++; break; @@ -101,7 +102,19 @@ int ms_fnmatch_lanman_core(char *pattern, char *string) int ms_fnmatch_lanman(char *pattern, char *string) { - return ms_fnmatch_lanman_core(pattern, string); + int ret; + pattern = strdup(pattern); + + /* it appears that '.' at the end of a pattern is stripped if the + pattern contains any wildcard characters. Bizarre */ + if (strpbrk(pattern, "?*<>\"")) { + int len = strlen(pattern); + if (len > 0 && pattern[len-1] == '.') pattern[len-1] = 0; + } + + ret = ms_fnmatch_lanman_core(pattern, string); + free(pattern); + return ret; } static BOOL reg_match_one(char *pattern, char *file) @@ -293,7 +306,7 @@ static void testpair(struct cli_state *cli, char *mask, char *file) res2 = reg_test(mask, long_name, short_name); - if (showall || strcmp(res1, res2)) { + if (showall || strcmp(res1+2, res2+2)) { DEBUG(0,("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n", res1, res2, count, mask, file, long_name, short_name)); } |