Synced xdgmime with upstream

master
Yevgen Muntyan 2006-05-07 04:03:00 -05:00
parent 650b54bdf8
commit 841231d0b2
4 changed files with 57 additions and 18 deletions

View File

@ -292,16 +292,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" name="GAP source" create="template" >
<type icon="source" ext="g" create="template" name="GAP source" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" name="C Source" create="template" >
<type icon="source_c" ext="c" create="template" name="C Source" >
<descr>A new empty C file.</descr>
</type>
</filetypes>

View File

@ -1,3 +1,29 @@
2006-03-02 Christian Neumair <chris@gnome-de.org>
* src/xdgmimeglob.c: (_xdg_glob_hash_insert_text),
(_xdg_glob_hash_append_glob): Don't strdup the MIME type when passing
it to _xdg_glob_hash_insert_text, but let the function itself figure
out whether string duplication is needed. Fixes #5993.
Thanks to Martin Wehner.
2006-02-25 Christian Neumair <chris@gnome-de.org>
* src/xdgmimemagic.c: (_xdg_mime_magic_lookup_data): Make
priority equality check more robust so that it works for three or more
matches. Also allow matchlets with 0 priority.
2006-02-19 Christian Neumair <chris@gnome-de.org>
* src/xdgmimemagic.c: (_xdg_mime_magic_lookup_data): When two
unrelated MIME types with equal priorities match, don't assume one of
them matches.
http://bugzilla.gnome.org/show_bug.cgi?id=331719
2006-01-03 Christian Neumair <chris@gnome-de.org>
* src/xdgmimemagic.c: (_xdg_mime_magic_lookup_data): Also consider
match priority for the returned MIME type.
2005-12-01 Christian Neumair <chris@gnome-de.org>
* src/xdgmime.c: (xdg_mime_get_mime_type_from_file_name):

View File

@ -247,7 +247,7 @@ _xdg_glob_hash_insert_text (XdgGlobHashNode *glob_hash_node,
{
XdgGlobHashNode *child;
int found_node = FALSE;
child = node->child;
while (child && child->character == '\0')
{
@ -263,7 +263,7 @@ _xdg_glob_hash_insert_text (XdgGlobHashNode *glob_hash_node,
{
child = _xdg_glob_hash_node_new ();
child->character = '\000';
child->mime_type = mime_type;
child->mime_type = strdup (mime_type);
child->child = NULL;
child->next = node->child;
node->child = child;
@ -272,7 +272,7 @@ _xdg_glob_hash_insert_text (XdgGlobHashNode *glob_hash_node,
}
else
{
node->mime_type = mime_type;
node->mime_type = strdup (mime_type);
}
}
else
@ -308,13 +308,13 @@ _xdg_glob_hash_node_lookup_file_name (XdgGlobHashNode *glob_hash_node,
if (*file_name == '\000')
{
n = 0;
if (node->mime_type)
mime_types[n++] = node->mime_type;
if (node->mime_type)
mime_types[n++] = node->mime_type;
node = node->child;
while (n < n_mime_types && node && node->character == 0)
{
if (node->mime_type)
mime_types[n++] = node->mime_type;
if (node->mime_type)
mime_types[n++] = node->mime_type;
node = node->next;
}
}
@ -365,7 +365,7 @@ _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
stopchars[i++] = (char)node->character;
}
stopchars[i] = '\0';
ptr = strpbrk (file_name, stopchars);
while (ptr)
{
@ -373,12 +373,12 @@ _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
mime_types, n_mime_types);
if (n > 0)
return n;
n = _xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, ptr, TRUE,
mime_types, n_mime_types);
if (n > 0)
return n;
ptr = strpbrk (ptr + 1, stopchars);
}
@ -477,7 +477,7 @@ _xdg_glob_hash_append_glob (XdgGlobHash *glob_hash,
glob_hash->literal_list = _xdg_glob_list_append (glob_hash->literal_list, strdup (glob), strdup (mime_type));
break;
case XDG_GLOB_SIMPLE:
glob_hash->simple_node = _xdg_glob_hash_insert_text (glob_hash->simple_node, glob + 1, strdup (mime_type));
glob_hash->simple_node = _xdg_glob_hash_insert_text (glob_hash->simple_node, glob + 1, mime_type);
break;
case XDG_GLOB_FULL:
glob_hash->full_list = _xdg_glob_list_append (glob_hash->full_list, strdup (glob), strdup (mime_type));

View File

@ -660,15 +660,28 @@ _xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
XdgMimeMagicMatch *match;
const char *mime_type;
int n;
int priority;
int had_match;
mime_type = NULL;
priority = 0;
had_match = 0;
for (match = mime_magic->match_list; match; match = match->next)
{
if (_xdg_mime_magic_match_compare_to_data (match, data, len))
{
if ((mime_type == NULL) || (xdg_mime_mime_type_subclass (match->mime_type, mime_type))) {
mime_type = match->mime_type;
}
if (!had_match || match->priority > priority ||
(mime_type != NULL && xdg_mime_mime_type_subclass (match->mime_type, mime_type)))
{
mime_type = match->mime_type;
priority = match->priority;
}
else if (had_match && match->priority == priority)
/* multiple unrelated patterns with the same priority matched,
* so we can't tell what type this is. */
mime_type = NULL;
had_match = 1;
}
else
{