Commit e14f3c40 authored by Alexandre Julliard's avatar Alexandre Julliard

winemenubuilder: Use PathMatchSpec() instead of fnmatch().

parent 982a712c
...@@ -7481,7 +7481,6 @@ for ac_header in \ ...@@ -7481,7 +7481,6 @@ for ac_header in \
dlfcn.h \ dlfcn.h \
elf.h \ elf.h \
float.h \ float.h \
fnmatch.h \
getopt.h \ getopt.h \
gettext-po.h \ gettext-po.h \
grp.h \ grp.h \
...@@ -17902,7 +17901,6 @@ for ac_func in \ ...@@ -17902,7 +17901,6 @@ for ac_func in \
__res_getservers \ __res_getservers \
_spawnvp \ _spawnvp \
epoll_create \ epoll_create \
fnmatch \
fork \ fork \
fstatfs \ fstatfs \
futimens \ futimens \
......
...@@ -450,7 +450,6 @@ AC_CHECK_HEADERS(\ ...@@ -450,7 +450,6 @@ AC_CHECK_HEADERS(\
dlfcn.h \ dlfcn.h \
elf.h \ elf.h \
float.h \ float.h \
fnmatch.h \
getopt.h \ getopt.h \
gettext-po.h \ gettext-po.h \
grp.h \ grp.h \
...@@ -2132,7 +2131,6 @@ AC_CHECK_FUNCS(\ ...@@ -2132,7 +2131,6 @@ AC_CHECK_FUNCS(\
__res_getservers \ __res_getservers \
_spawnvp \ _spawnvp \
epoll_create \ epoll_create \
fnmatch \
fork \ fork \
fstatfs \ fstatfs \
futimens \ futimens \
......
...@@ -96,12 +96,6 @@ ...@@ -96,12 +96,6 @@
/* Define to 1 if you have the <float.h> header file. */ /* Define to 1 if you have the <float.h> header file. */
#undef HAVE_FLOAT_H #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. */ /* Define to 1 if you have the <fontconfig/fontconfig.h> header file. */
#undef HAVE_FONTCONFIG_FONTCONFIG_H #undef HAVE_FONTCONFIG_FONTCONFIG_H
......
...@@ -73,9 +73,6 @@ ...@@ -73,9 +73,6 @@
#endif #endif
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
#define COBJMACROS #define COBJMACROS
#define NONAMELESSUNION #define NONAMELESSUNION
...@@ -181,7 +178,6 @@ struct xdg_mime_type ...@@ -181,7 +178,6 @@ struct xdg_mime_type
{ {
char *mimeType; char *mimeType;
char *glob; char *glob;
char *lower_glob;
struct list entry; struct list entry;
}; };
...@@ -1936,7 +1932,7 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types) ...@@ -1936,7 +1932,7 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types)
int size = 0; int size = 0;
while (ret && (ret = next_line(globs_file, &line, &size)) && line) while (ret && (ret = next_line(globs_file, &line, &size)) && line)
{ {
char *pos, *l; char *pos;
struct xdg_mime_type *mime_type_entry = NULL; struct xdg_mime_type *mime_type_entry = NULL;
if (line[0] != '#' && (pos = strchr(line, ':'))) if (line[0] != '#' && (pos = strchr(line, ':')))
{ {
...@@ -1944,9 +1940,6 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types) ...@@ -1944,9 +1940,6 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types)
*pos = 0; *pos = 0;
mime_type_entry->mimeType = xstrdup(line); mime_type_entry->mimeType = xstrdup(line);
mime_type_entry->glob = xstrdup(pos + 1); 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); list_add_tail(mime_types, &mime_type_entry->entry);
} }
} }
...@@ -1965,7 +1958,6 @@ static void free_native_mime_types(struct list *native_mime_types) ...@@ -1965,7 +1958,6 @@ static void free_native_mime_types(struct list *native_mime_types)
{ {
list_remove(&mime_type_entry->entry); list_remove(&mime_type_entry->entry);
heap_free(mime_type_entry->glob); heap_free(mime_type_entry->glob);
heap_free(mime_type_entry->lower_glob);
heap_free(mime_type_entry->mimeType); heap_free(mime_type_entry->mimeType);
heap_free(mime_type_entry); heap_free(mime_type_entry);
} }
...@@ -2005,10 +1997,11 @@ static BOOL build_native_mime_types(const char *xdg_data_home, struct list *mime ...@@ -2005,10 +1997,11 @@ static BOOL build_native_mime_types(const char *xdg_data_home, struct list *mime
return ret; return ret;
} }
static BOOL match_glob(struct list *native_mime_types, const char *extension, static BOOL freedesktop_mime_type_for_extension(struct list *native_mime_types,
int ignoreGlobCase, char **match) const char *extensionA,
LPCWSTR extensionW,
char **match)
{ {
#ifdef HAVE_FNMATCH
struct xdg_mime_type *mime_type_entry; struct xdg_mime_type *mime_type_entry;
int matchLength = 0; int matchLength = 0;
...@@ -2016,46 +2009,20 @@ static BOOL match_glob(struct list *native_mime_types, const char *extension, ...@@ -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) 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 (PathMatchSpecA( extensionA, mime_type_entry->glob ))
if (fnmatch(glob, extension, 0) == 0)
{ {
if (*match == NULL || matchLength < strlen(glob)) if (*match == NULL || matchLength < strlen(mime_type_entry->glob))
{ {
*match = mime_type_entry->mimeType; *match = mime_type_entry->mimeType;
matchLength = strlen(glob); matchLength = strlen(mime_type_entry->glob);
} }
} }
} }
if (*match != NULL) *match = xstrdup(*match); if (*match != NULL) *match = xstrdup(*match);
#else
*match = NULL;
#endif
return TRUE; 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) static WCHAR* reg_get_valW(HKEY key, LPCWSTR subkey, LPCWSTR name)
{ {
DWORD size; DWORD size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment