From a84bd62ee648afbf1049fa8271671884ef224a03 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 1 Jun 2013 22:49:15 +0200 Subject: [PATCH] Uses pathcmp() where appropriate instead of fnmatch(). --- elem.c | 7 ++----- util.c | 4 ++++ util.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/elem.c b/elem.c index 175d391d..2b589590 100644 --- a/elem.c +++ b/elem.c @@ -260,15 +260,12 @@ int filter_content(tommy_list* contentlist, const char* path) struct snapraid_content* content = i->data; char tmp[PATH_MAX]; - /* FNM_PATHNAME because we are comparing full path */ - /* FNM_NOESCAPE because the pattern is also a path, surely without escape chars */ - /* FNM_CASEINSENSITIVE_FOR_WIN ignore case only in windows */ - if (fnmatch(content->content, path, FNM_PATHNAME | FNM_NOESCAPE | FNM_CASEINSENSITIVE_FOR_WIN) == 0) + if (pathcmp(content->content, path) == 0) return -1; /* exclude also the ".tmp" copy used to save it */ pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); - if (fnmatch(tmp, path, FNM_PATHNAME | FNM_NOESCAPE | FNM_CASEINSENSITIVE_FOR_WIN) == 0) + if (pathcmp(tmp, path) == 0) return -1; } diff --git a/util.c b/util.c index a7f9fe81..45199493 100644 --- a/util.c +++ b/util.c @@ -660,8 +660,12 @@ int pathcmp(const char* a, const char* b) #ifdef _WIN32 char ai[PATH_MAX]; char bi[PATH_MAX]; + + /* import to convert \ to / */ pathimport(ai, sizeof(ai), a); pathimport(bi, sizeof(bi), b); + + /* case insensitive compare in Windows */ return stricmp(ai, bi); #else return strcmp(a, b); diff --git a/util.h b/util.h index f2a26cb4..3354e7b2 100644 --- a/util.h +++ b/util.h @@ -336,7 +336,7 @@ void pathslash(char* dst, size_t size); /** * Compare two paths. - * In Windows it's case insentive. + * In Windows it's case insentive and assumes \ equal at /. */ int pathcmp(const char* a, const char* b);