mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-01 18:48:29 +00:00
winemenubuilder: Use PathMatchSpec() instead of fnmatch().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
982a712c4d
commit
e14f3c40cd
2
configure
vendored
2
configure
vendored
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue