summaryrefslogtreecommitdiff
path: root/gtk/xdgmime/xdgmimemagic.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/xdgmime/xdgmimemagic.c')
-rw-r--r--gtk/xdgmime/xdgmimemagic.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gtk/xdgmime/xdgmimemagic.c b/gtk/xdgmime/xdgmimemagic.c
index b98c1e7321..352886d0f6 100644
--- a/gtk/xdgmime/xdgmimemagic.c
+++ b/gtk/xdgmime/xdgmimemagic.c
@@ -268,7 +268,7 @@ _xdg_mime_magic_parse_header (FILE *magic_file, XdgMimeMagicMatch *match)
if (c != ':')
return XDG_MIME_MAGIC_ERROR;
- buffer = _xdg_mime_magic_read_to_newline (magic_file, &end_of_file);
+ buffer = (char *)_xdg_mime_magic_read_to_newline (magic_file, &end_of_file);
if (end_of_file)
return XDG_MIME_MAGIC_EOF;
@@ -520,8 +520,7 @@ _xdg_mime_magic_matchlet_compare_to_data (XdgMimeMagicMatchlet *matchlet,
size_t len)
{
int i, j;
-
- for (i = matchlet->offset; i <= matchlet->offset + matchlet->range_length; i++)
+ for (i = matchlet->offset; i < matchlet->offset + matchlet->range_length; i++)
{
int valid_matchlet = TRUE;
@@ -657,16 +656,20 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
size_t len)
{
XdgMimeMagicMatch *match;
+ const char *mime_type;
+ mime_type = NULL;
for (match = mime_magic->match_list; match; match = match->next)
{
if (_xdg_mime_magic_match_compare_to_data (match, data, len))
{
- return match->mime_type;
+ if ((mime_type == NULL) || (xdg_mime_mime_type_subclass (match->mime_type, mime_type))) {
+ mime_type = match->mime_type;
+ }
}
}
- return NULL;
+ return mime_type;
}
static void