Alexandre Julliard : winemenubuilder: Use PathMatchSpec() instead of fnmatch().
Alexandre Julliard
julliard at winehq.org
Fri Oct 1 18:02:21 CDT 2021
Module: wine
Branch: master
Commit: e14f3c40cdf4eb638951c12396f94a9a0919d71e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e14f3c40cdf4eb638951c12396f94a9a0919d71e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Oct 1 09:36:17 2021 +0200
winemenubuilder: Use PathMatchSpec() instead of fnmatch().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
configure | 2 --
configure.ac | 2 --
include/config.h.in | 6 ----
programs/winemenubuilder/winemenubuilder.c | 49 +++++-------------------------
4 files changed, 8 insertions(+), 51 deletions(-)
diff --git a/configure b/configure
index eca83982196..038391a4439 100755
--- a/configure
+++ b/configure
@@ -7481,7 +7481,6 @@ for ac_header in \
dlfcn.h \
elf.h \
float.h \
- fnmatch.h \
getopt.h \
gettext-po.h \
grp.h \
@@ -17902,7 +17901,6 @@ for ac_func in \
__res_getservers \
_spawnvp \
epoll_create \
- fnmatch \
fork \
fstatfs \
futimens \
diff --git a/configure.ac b/configure.ac
index 7ed1e73eb6d..da80562c445 100644
--- a/configure.ac
+++ b/configure.ac
@@ -450,7 +450,6 @@ AC_CHECK_HEADERS(\
dlfcn.h \
elf.h \
float.h \
- fnmatch.h \
getopt.h \
gettext-po.h \
grp.h \
@@ -2132,7 +2131,6 @@ AC_CHECK_FUNCS(\
__res_getservers \
_spawnvp \
epoll_create \
- fnmatch \
fork \
fstatfs \
futimens \
diff --git a/include/config.h.in b/include/config.h.in
index dac43f7840e..80cc9c3a47f 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -96,12 +96,6 @@
/* Define to 1 if you have the <float.h> header file. */
#undef HAVE_FLOAT_H
-/* Define to 1 if you have the `fnmatch' function. */
-#undef HAVE_FNMATCH
-
-/* Define to 1 if you have the <fnmatch.h> header file. */
-#undef HAVE_FNMATCH_H
-
/* Define to 1 if you have the <fontconfig/fontconfig.h> header file. */
#undef HAVE_FONTCONFIG_FONTCONFIG_H
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 06f3cb50705..a4f1ee26e9c 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -73,9 +73,6 @@
#endif
#include <errno.h>
#include <stdarg.h>
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif
#define COBJMACROS
#define NONAMELESSUNION
@@ -181,7 +178,6 @@ struct xdg_mime_type
{
char *mimeType;
char *glob;
- char *lower_glob;
struct list entry;
};
@@ -1936,7 +1932,7 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types)
int size = 0;
while (ret && (ret = next_line(globs_file, &line, &size)) && line)
{
- char *pos, *l;
+ char *pos;
struct xdg_mime_type *mime_type_entry = NULL;
if (line[0] != '#' && (pos = strchr(line, ':')))
{
@@ -1944,9 +1940,6 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types)
*pos = 0;
mime_type_entry->mimeType = xstrdup(line);
mime_type_entry->glob = xstrdup(pos + 1);
- mime_type_entry->lower_glob = xstrdup(pos + 1);
- for (l = mime_type_entry->lower_glob; *l; l++)
- *l = tolower(*l);
list_add_tail(mime_types, &mime_type_entry->entry);
}
}
@@ -1965,7 +1958,6 @@ static void free_native_mime_types(struct list *native_mime_types)
{
list_remove(&mime_type_entry->entry);
heap_free(mime_type_entry->glob);
- heap_free(mime_type_entry->lower_glob);
heap_free(mime_type_entry->mimeType);
heap_free(mime_type_entry);
}
@@ -2005,10 +1997,11 @@ static BOOL build_native_mime_types(const char *xdg_data_home, struct list *mime
return ret;
}
-static BOOL match_glob(struct list *native_mime_types, const char *extension,
- int ignoreGlobCase, char **match)
+static BOOL freedesktop_mime_type_for_extension(struct list *native_mime_types,
+ const char *extensionA,
+ LPCWSTR extensionW,
+ char **match)
{
-#ifdef HAVE_FNMATCH
struct xdg_mime_type *mime_type_entry;
int matchLength = 0;
@@ -2016,46 +2009,20 @@ static BOOL match_glob(struct list *native_mime_types, const char *extension,
LIST_FOR_EACH_ENTRY(mime_type_entry, native_mime_types, struct xdg_mime_type, entry)
{
- const char *glob = ignoreGlobCase ? mime_type_entry->lower_glob : mime_type_entry->glob;
- if (fnmatch(glob, extension, 0) == 0)
+ if (PathMatchSpecA( extensionA, mime_type_entry->glob ))
{
- if (*match == NULL || matchLength < strlen(glob))
+ if (*match == NULL || matchLength < strlen(mime_type_entry->glob))
{
*match = mime_type_entry->mimeType;
- matchLength = strlen(glob);
+ matchLength = strlen(mime_type_entry->glob);
}
}
}
if (*match != NULL) *match = xstrdup(*match);
-#else
- *match = NULL;
-#endif
return TRUE;
}
-static BOOL freedesktop_mime_type_for_extension(struct list *native_mime_types,
- const char *extensionA,
- LPCWSTR extensionW,
- char **mime_type)
-{
- WCHAR *lower_extensionW;
- char *lower_extensionA;
- INT len;
- BOOL ret = match_glob(native_mime_types, extensionA, 0, mime_type);
- if (ret == FALSE || *mime_type != NULL)
- return ret;
- len = strlenW(extensionW);
- lower_extensionW = xmalloc((len + 1)*sizeof(WCHAR));
- memcpy(lower_extensionW, extensionW, (len + 1)*sizeof(WCHAR));
- strlwrW(lower_extensionW);
- lower_extensionA = wchars_to_utf8_chars(lower_extensionW);
- ret = match_glob(native_mime_types, lower_extensionA, 1, mime_type);
- heap_free(lower_extensionA);
- heap_free(lower_extensionW);
- return ret;
-}
-
static WCHAR* reg_get_valW(HKEY key, LPCWSTR subkey, LPCWSTR name)
{
DWORD size;
More information about the wine-cvs
mailing list