From dccf44d752604d877a379290bda10644e0844682 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Feb 2001 06:11:59 +0000 Subject: 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) --- source3/utils/masktest.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source3/utils') 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)); } -- cgit