glib r6860 - in branches/glib-2-16/gio: . xdgmime
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r6860 - in branches/glib-2-16/gio: . xdgmime
- Date: Wed, 16 Apr 2008 23:00:30 +0100 (BST)
Author: matthiasc
Date: Wed Apr 16 23:00:30 2008
New Revision: 6860
URL: http://svn.gnome.org/viewvc/glib?rev=6860&view=rev
Log:
2008-04-16 Matthias Clasen <mclasen redhat com>
* xdgmime/xdgmime.c: Rework the timestamp checking code
to protect against duplicate directories in XDG_DATA_DIRS.
Fixes fd.o bug 12513, reported by Joe Shaw.
Modified:
branches/glib-2-16/gio/ChangeLog
branches/glib-2-16/gio/xdgmime/xdgmime.c
Modified: branches/glib-2-16/gio/xdgmime/xdgmime.c
==============================================================================
--- branches/glib-2-16/gio/xdgmime/xdgmime.c (original)
+++ branches/glib-2-16/gio/xdgmime/xdgmime.c Wed Apr 16 23:00:30 2008
@@ -93,17 +93,26 @@
typedef int (*XdgDirectoryFunc) (const char *directory,
void *user_data);
-static XdgDirTimeList *
-xdg_dir_time_list_new (void)
+static void
+xdg_dir_time_list_add (char *file_name,
+ time_t mtime)
{
- XdgDirTimeList *retval;
-
- retval = calloc (1, sizeof (XdgDirTimeList));
- retval->checked = XDG_CHECKED_UNCHECKED;
+ XdgDirTimeList *list;
- return retval;
+ for (list = dir_time_list; list; list = list->next)
+ {
+ if (strcmp (list->directory_name, file_name) == 0)
+ return;
+ }
+
+ list = calloc (1, sizeof (XdgDirTimeList));
+ list->checked = XDG_CHECKED_UNCHECKED;
+ list->directory_name = file_name;
+ list->mtime = mtime;
+ list->next = dir_time_list;
+ dir_time_list = list;
}
-
+
static void
xdg_dir_time_list_free (XdgDirTimeList *list)
{
@@ -123,7 +132,6 @@
{
char *file_name;
struct stat st;
- XdgDirTimeList *list;
assert (directory != NULL);
@@ -135,11 +143,7 @@
if (cache != NULL)
{
- list = xdg_dir_time_list_new ();
- list->directory_name = file_name;
- list->mtime = st.st_mtime;
- list->next = dir_time_list;
- dir_time_list = list;
+ xdg_dir_time_list_add (file_name, st.st_mtime);
_caches = realloc (_caches, sizeof (XdgMimeCache *) * (n_caches + 2));
_caches[n_caches] = cache;
@@ -156,12 +160,7 @@
if (stat (file_name, &st) == 0)
{
_xdg_mime_glob_read_from_file (global_hash, file_name);
-
- list = xdg_dir_time_list_new ();
- list->directory_name = file_name;
- list->mtime = st.st_mtime;
- list->next = dir_time_list;
- dir_time_list = list;
+ xdg_dir_time_list_add (file_name, st.st_mtime);
}
else
{
@@ -173,12 +172,7 @@
if (stat (file_name, &st) == 0)
{
_xdg_mime_magic_read_from_file (global_magic, file_name);
-
- list = xdg_dir_time_list_new ();
- list->directory_name = file_name;
- list->mtime = st.st_mtime;
- list->next = dir_time_list;
- dir_time_list = list;
+ xdg_dir_time_list_add (file_name, st.st_mtime);
}
else
{
@@ -296,12 +290,11 @@
for (list = dir_time_list; list; list = list->next)
{
- if (! strcmp (list->directory_name, file_path) &&
- st.st_mtime == list->mtime)
+ if (! strcmp (list->directory_name, file_path))
{
- if (list->checked == XDG_CHECKED_UNCHECKED)
+ if (st.st_mtime == list->mtime)
list->checked = XDG_CHECKED_VALID;
- else if (list->checked == XDG_CHECKED_VALID)
+ else
list->checked = XDG_CHECKED_INVALID;
return (list->checked != XDG_CHECKED_VALID);
@@ -685,7 +678,7 @@
int
xdg_mime_media_type_equal (const char *mime_a,
- const char *mime_b)
+ const char *mime_b)
{
char *sep;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]