summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-02-27 12:04:49 +0000
committerAndrew Tridgell <tridge@samba.org>2001-02-27 12:04:49 +0000
commit1d67fe4dbee99ec1113abbc5ebb19d4e8c67e414 (patch)
tree7eca0ba6842738840895cf88ad0ac2fc5cb4fb38 /source3/utils
parentacaf04b7cc831b06128c64e15dc35308a61e18a0 (diff)
downloadsamba-1d67fe4dbee99ec1113abbc5ebb19d4e8c67e414.tar.gz
samba-1d67fe4dbee99ec1113abbc5ebb19d4e8c67e414.tar.bz2
samba-1d67fe4dbee99ec1113abbc5ebb19d4e8c67e414.zip
better handling of '.'
better verbose print (This used to be commit 1f8b8a7189fb8c142801d679cf53c586aee74740)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/masktest.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/source3/utils/masktest.c b/source3/utils/masktest.c
index 7e0757e32a..4dd8f3ef06 100644
--- a/source3/utils/masktest.c
+++ b/source3/utils/masktest.c
@@ -40,12 +40,19 @@ 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;
+ if (strcmp(p,"?")==0 && strcmp(n,".")==0) goto match;
while ((c = *p++)) {
switch (c) {
+ case '.':
+ if (!strchr(p,'.') && !*n && ms_fnmatch_lanman_core(p, n)==0)
+ goto match;
+ if (*n != '.') goto nomatch;
+ n++;
+ break;
+
case '?':
- if (*n == '.' || ! *n) return ms_fnmatch_lanman_core(p, n);
+ if ((*n == '.' && n[1] != '.') || ! *n) goto next;
n++;
break;
@@ -55,7 +62,7 @@ int ms_fnmatch_lanman_core(char *pattern, char *string)
if (ms_fnmatch_lanman_core(p, n) == 0) goto match;
goto nomatch;
}
- if (! *n) return ms_fnmatch_lanman_core(p, n);
+ if (! *n) goto next;
n++;
break;
@@ -90,11 +97,14 @@ int ms_fnmatch_lanman_core(char *pattern, char *string)
if (! *n) goto match;
-
nomatch:
if (verbose) printf("NOMATCH pattern=[%s] string=[%s]\n", pattern, string);
return -1;
+next:
+ if (ms_fnmatch_lanman_core(p, n) == 0) goto match;
+ goto nomatch;
+
match:
if (verbose) printf("MATCH pattern=[%s] string=[%s]\n", pattern, string);
return 0;
@@ -102,19 +112,11 @@ int ms_fnmatch_lanman_core(char *pattern, char *string)
int ms_fnmatch_lanman(char *pattern, char *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;
+ if (!strpbrk(pattern, "?*<>\"")) {
+ return strcmp(pattern, string);
}
- ret = ms_fnmatch_lanman_core(pattern, string);
- free(pattern);
- return ret;
+ return ms_fnmatch_lanman_core(pattern, string);
}
static BOOL reg_match_one(char *pattern, char *file)