diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-03-28 19:32:07 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-03-28 19:32:07 +0000 |
commit | 0e832d57fc5cf4bc8a9d99f5341bc77ec44a5c2d (patch) | |
tree | 0dbbc4bedd1ed939f02106636b2345946b145cbb /gtk/xdgmime | |
parent | 2b874b2438fbe03b11dcc309577bda0f698f6406 (diff) | |
download | gtk+-0e832d57fc5cf4bc8a9d99f5341bc77ec44a5c2d.tar.gz |
Sync to latest upstream, including fixes for matching against multiple
2005-03-28 Matthias Clasen <mclasen@redhat.com>
* xdgmimeglob.c: Sync to latest upstream,
including fixes for matching against multiple
extensions (eg .tar.gz) and for suffix
patterns which don't start with a dot.
Diffstat (limited to 'gtk/xdgmime')
-rw-r--r-- | gtk/xdgmime/ChangeLog | 7 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmimeglob.c | 23 |
2 files changed, 25 insertions, 5 deletions
diff --git a/gtk/xdgmime/ChangeLog b/gtk/xdgmime/ChangeLog index 02bf61bdac..95860cf60d 100644 --- a/gtk/xdgmime/ChangeLog +++ b/gtk/xdgmime/ChangeLog @@ -1,3 +1,10 @@ +2005-03-28 Matthias Clasen <mclasen@redhat.com> + + * xdgmimeglob.c: Sync to latest upstream, + including fixes for matching against multiple + extensions (eg .tar.gz) and for suffix + patterns which don't start with a dot. + Sat Mar 19 23:52:33 2005 Manish Singh <yosh@gimp.org> * xdgmimeglob.c (_xdg_glob_hash_insert_text): cast away the constness diff --git a/gtk/xdgmime/xdgmimeglob.c b/gtk/xdgmime/xdgmimeglob.c index e99eb834df..d1f3f1940c 100644 --- a/gtk/xdgmime/xdgmimeglob.c +++ b/gtk/xdgmime/xdgmimeglob.c @@ -241,8 +241,7 @@ _xdg_glob_hash_insert_text (XdgGlobHashNode *glob_hash_node, text = _xdg_utf8_next_char (text); if (*text == '\000') { - if (node->mime_type) - free ((void *) node->mime_type); + free ((void *) node->mime_type); node->mime_type = mime_type; } else @@ -290,6 +289,10 @@ _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash, XdgGlobList *list; const char *mime_type; const char *ptr; + char stopchars[128]; + int i; + XdgGlobHashNode *node; + /* First, check the literals */ assert (file_name != NULL); @@ -298,16 +301,26 @@ _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash, if (strcmp ((const char *)list->data, file_name) == 0) return list->mime_type; - ptr = strchr (file_name, '.'); - if (ptr) + i = 0; + for (node = glob_hash->simple_node; node; node = node->next) + { + if (node->character < 128) + stopchars[i++] = (char)node->character; + } + stopchars[i] = '\0'; + + ptr = strpbrk (file_name, stopchars); + while (ptr) { mime_type = (_xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, ptr, FALSE)); if (mime_type != NULL) return mime_type; - + mime_type = (_xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, ptr, TRUE)); if (mime_type != NULL) return mime_type; + + ptr = strpbrk (ptr + 1, stopchars); } /* FIXME: Not UTF-8 safe */ |