mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-05 23:48:44 +02:00
xdgmime: Update to upstream commit c2c814d4051f232
(Modulo the changes in https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/10 which are still under discussion. Plus the proposed warning fixes from https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/33.) Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: #3191
This commit is contained in:
@@ -6,23 +6,7 @@
|
||||
* Copyright (C) 2003,2004 Red Hat, Inc.
|
||||
* Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
|
||||
*
|
||||
* Licensed under the Academic Free License version 2.0
|
||||
* Or under the following terms:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -143,7 +127,7 @@ xdg_dir_time_list_free (XdgDirTimeList *list)
|
||||
|
||||
static int
|
||||
xdg_mime_init_from_directory (const char *directory,
|
||||
void *user_data)
|
||||
void *user_data __attribute__((__unused__)))
|
||||
{
|
||||
char *file_name;
|
||||
struct stat st;
|
||||
@@ -836,12 +820,12 @@ xdg_mime_is_super_type (const char *mime)
|
||||
int
|
||||
_xdg_mime_mime_type_subclass (const char *mime,
|
||||
const char *base,
|
||||
const char **seen)
|
||||
const char ***seen)
|
||||
{
|
||||
const char *umime, *ubase, *parent;
|
||||
const char **parents;
|
||||
const char **parents, **first_seen = NULL, **new_seen;
|
||||
|
||||
int first_seen = 0, i, ret = 0;
|
||||
int i, ret = 0;
|
||||
|
||||
if (_caches)
|
||||
return _xdg_mime_cache_mime_type_subclass (mime, base, NULL);
|
||||
@@ -870,8 +854,8 @@ _xdg_mime_mime_type_subclass (const char *mime,
|
||||
|
||||
if (!seen)
|
||||
{
|
||||
seen = calloc (1, sizeof (char *));
|
||||
first_seen = 1;
|
||||
first_seen = calloc (1, sizeof (char *));
|
||||
seen = &first_seen;
|
||||
}
|
||||
|
||||
parents = _xdg_mime_parent_list_lookup (parent_list, umime);
|
||||
@@ -880,12 +864,15 @@ _xdg_mime_mime_type_subclass (const char *mime,
|
||||
parent = *parents;
|
||||
|
||||
/* Detect and avoid buggy circular relationships */
|
||||
for (i = 0; seen[i] != NULL; i++)
|
||||
if (parent == seen[i])
|
||||
for (i = 0; (*seen)[i] != NULL; i++)
|
||||
if (parent == (*seen)[i])
|
||||
goto next_parent;
|
||||
seen = realloc (seen, (i + 2) * sizeof (char *));
|
||||
seen[i] = parent;
|
||||
seen[i + 1] = NULL;
|
||||
new_seen = realloc (*seen, (i + 2) * sizeof (char *));
|
||||
if (!new_seen)
|
||||
goto done;
|
||||
new_seen[i] = parent;
|
||||
new_seen[i + 1] = NULL;
|
||||
*seen = new_seen;
|
||||
|
||||
if (_xdg_mime_mime_type_subclass (parent, ubase, seen))
|
||||
{
|
||||
@@ -898,8 +885,7 @@ _xdg_mime_mime_type_subclass (const char *mime,
|
||||
}
|
||||
|
||||
done:
|
||||
if (first_seen)
|
||||
free (seen);
|
||||
free (first_seen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -919,6 +905,8 @@ xdg_mime_list_mime_parents (const char *mime)
|
||||
char **result;
|
||||
int i, n;
|
||||
|
||||
xdg_mime_init ();
|
||||
|
||||
if (_caches)
|
||||
return _xdg_mime_cache_list_mime_parents (mime);
|
||||
|
||||
|
Reference in New Issue
Block a user