Merge branch 'xdgmime_update' into 'main'

Updating xdgmime

See merge request GNOME/glib!2029
This commit is contained in:
Philip Withnall 2021-09-27 11:50:48 +00:00
commit 60173d0a38
17 changed files with 160 additions and 112 deletions

View File

@ -13,4 +13,5 @@ xdgmime_lib = static_library('xdgmime',
sources : xdgmime_sources, sources : xdgmime_sources,
include_directories : [configinc], include_directories : [configinc],
pic : true, pic : true,
c_args : [ '-DXDG_PREFIX=_gio_xdg' ] + glib_hidden_visibility_args) c_args : [ '-DHAVE_CONFIG_H',
'-DXDG_PREFIX=_gio_xdg' ] + glib_hidden_visibility_args)

View File

@ -20,10 +20,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xdgmime.h" #include "xdgmime.h"
#include "xdgmimeint.h" #include "xdgmimeint.h"
@ -134,7 +138,8 @@ xdg_dir_time_list_free (XdgDirTimeList *list)
} }
static int static int
xdg_mime_init_from_directory (const char *directory) xdg_mime_init_from_directory (const char *directory,
void *user_data)
{ {
char *file_name; char *file_name;
struct stat st; struct stat st;
@ -400,10 +405,11 @@ xdg_check_file (const char *file_path,
static int static int
xdg_check_dir (const char *directory, xdg_check_dir (const char *directory,
int *invalid_dir_list) void *user_data)
{ {
int invalid, exists; int invalid, exists;
char *file_name; char *file_name;
int* invalid_dir_list = user_data;
assert (directory != NULL); assert (directory != NULL);
@ -458,8 +464,7 @@ xdg_check_dirs (void)
for (list = dir_time_list; list; list = list->next) for (list = dir_time_list; list; list = list->next)
list->checked = XDG_CHECKED_UNCHECKED; list->checked = XDG_CHECKED_UNCHECKED;
xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_check_dir, xdg_run_command_on_dirs (xdg_check_dir, &invalid_dir_list);
&invalid_dir_list);
if (invalid_dir_list) if (invalid_dir_list)
return TRUE; return TRUE;
@ -515,8 +520,7 @@ xdg_mime_init (void)
icon_list = _xdg_mime_icon_list_new (); icon_list = _xdg_mime_icon_list_new ();
generic_icon_list = _xdg_mime_icon_list_new (); generic_icon_list = _xdg_mime_icon_list_new ();
xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_mime_init_from_directory, xdg_run_command_on_dirs (xdg_mime_init_from_directory, NULL);
NULL);
need_reread = FALSE; need_reread = FALSE;
} }
@ -621,13 +625,13 @@ xdg_mime_get_mime_type_for_file (const char *file_name,
mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL,
mime_types, n); mime_types, n);
if (!mime_type)
mime_type = _xdg_binary_or_text_fallback (data, bytes_read);
free (data); free (data);
fclose (file); fclose (file);
if (mime_type) return mime_type;
return mime_type;
return _xdg_binary_or_text_fallback(data, bytes_read);
} }
const char * const char *

View File

@ -20,7 +20,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */

View File

@ -20,10 +20,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xdgmimealias.h" #include "xdgmimealias.h"
#include "xdgmimeint.h" #include "xdgmimeint.h"

View File

@ -20,7 +20,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_ALIAS_H__ #ifndef __XDG_MIME_ALIAS_H__

View File

@ -19,10 +19,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -39,7 +43,7 @@
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
#include <sys/mman.h> #include <sys/mman.h>
#else #else
#warning Building xdgmime without MMAP support. Binary "mime.info" cache files will not be used. #warning Building xdgmime without MMAP support. Binary "mime.cache" files will not be used.
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -117,9 +121,9 @@ _xdg_mime_cache_new_from_file (const char *file_name)
int minor; int minor;
/* Open the file and map it into memory */ /* Open the file and map it into memory */
do do {
fd = open (file_name, O_RDONLY|_O_BINARY, 0); fd = open (file_name, O_RDONLY|_O_BINARY, 0);
while (fd == -1 && errno == EINTR); } while (fd == -1 && errno == EINTR);
if (fd < 0) if (fd < 0)
return NULL; return NULL;
@ -176,7 +180,7 @@ cache_magic_matchlet_compare_to_data (XdgMimeCache *cache,
xdg_uint32_t data_offset = GET_UINT32 (cache->buffer, offset + 16); xdg_uint32_t data_offset = GET_UINT32 (cache->buffer, offset + 16);
xdg_uint32_t mask_offset = GET_UINT32 (cache->buffer, offset + 20); xdg_uint32_t mask_offset = GET_UINT32 (cache->buffer, offset + 20);
int i, j; xdg_uint32_t i, j;
for (i = range_start; i < range_start + range_length; i++) for (i = range_start; i < range_start + range_length; i++)
{ {
@ -199,14 +203,7 @@ cache_magic_matchlet_compare_to_data (XdgMimeCache *cache,
} }
else else
{ {
for (j = 0; j < data_length; j++) valid_matchlet = memcmp(cache->buffer + data_offset, (unsigned char *)data + i, data_length) == 0;
{
if (((unsigned char *)cache->buffer)[data_offset + j] != ((unsigned char *) data)[j + i])
{
valid_matchlet = FALSE;
break;
}
}
} }
if (valid_matchlet) if (valid_matchlet)
@ -225,7 +222,7 @@ cache_magic_matchlet_compare (XdgMimeCache *cache,
xdg_uint32_t n_children = GET_UINT32 (cache->buffer, offset + 24); xdg_uint32_t n_children = GET_UINT32 (cache->buffer, offset + 24);
xdg_uint32_t child_offset = GET_UINT32 (cache->buffer, offset + 28); xdg_uint32_t child_offset = GET_UINT32 (cache->buffer, offset + 28);
int i; xdg_uint32_t i;
if (cache_magic_matchlet_compare_to_data (cache, offset, data, len)) if (cache_magic_matchlet_compare_to_data (cache, offset, data, len))
{ {
@ -255,7 +252,7 @@ cache_magic_compare_to_data (XdgMimeCache *cache,
xdg_uint32_t n_matchlets = GET_UINT32 (cache->buffer, offset + 8); xdg_uint32_t n_matchlets = GET_UINT32 (cache->buffer, offset + 8);
xdg_uint32_t matchlet_offset = GET_UINT32 (cache->buffer, offset + 12); xdg_uint32_t matchlet_offset = GET_UINT32 (cache->buffer, offset + 12);
int i; xdg_uint32_t i;
for (i = 0; i < n_matchlets; i++) for (i = 0; i < n_matchlets; i++)
{ {
@ -275,15 +272,13 @@ static const char *
cache_magic_lookup_data (XdgMimeCache *cache, cache_magic_lookup_data (XdgMimeCache *cache,
const void *data, const void *data,
size_t len, size_t len,
int *prio, int *prio)
const char *mime_types[],
int n_mime_types)
{ {
xdg_uint32_t list_offset; xdg_uint32_t list_offset;
xdg_uint32_t n_entries; xdg_uint32_t n_entries;
xdg_uint32_t offset; xdg_uint32_t offset;
int j, n; xdg_uint32_t j;
*prio = 0; *prio = 0;
@ -299,21 +294,6 @@ cache_magic_lookup_data (XdgMimeCache *cache,
data, len, prio); data, len, prio);
if (match) if (match)
return match; return match;
else
{
xdg_uint32_t mimetype_offset;
const char *non_match;
mimetype_offset = GET_UINT32 (cache->buffer, offset + 16 * j + 4);
non_match = cache->buffer + mimetype_offset;
for (n = 0; n < n_mime_types; n++)
{
if (mime_types[n] &&
_xdg_mime_mime_type_equal (mime_types[n], non_match))
mime_types[n] = NULL;
}
}
} }
return NULL; return NULL;
@ -428,12 +408,14 @@ cache_glob_lookup_literal (const char *file_name,
static int static int
cache_glob_lookup_fnmatch (const char *file_name, cache_glob_lookup_fnmatch (const char *file_name,
MimeWeight mime_types[], MimeWeight mime_types[],
int n_mime_types) int n_mime_types,
int case_sensitive_check)
{ {
const char *mime_type; const char *mime_type;
const char *ptr; const char *ptr;
int i, j, n; int i, n;
xdg_uint32_t j;
n = 0; n = 0;
for (i = 0; _caches[i]; i++) for (i = 0; _caches[i]; i++)
@ -454,16 +436,19 @@ cache_glob_lookup_fnmatch (const char *file_name,
xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j); xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j);
xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j + 4); xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j + 4);
int weight = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j + 8); int weight = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j + 8);
int case_sensitive = weight & 0x100;
weight = weight & 0xff; weight = weight & 0xff;
ptr = cache->buffer + offset; ptr = cache->buffer + offset;
mime_type = cache->buffer + mimetype_offset; mime_type = cache->buffer + mimetype_offset;
if (case_sensitive_check || !case_sensitive)
/* FIXME: Not UTF-8 safe */
if (fnmatch (ptr, file_name, 0) == 0)
{ {
mime_types[n].mime = mime_type; /* FIXME: Not UTF-8 safe */
mime_types[n].weight = weight; if (fnmatch (ptr, file_name, 0) == 0)
n++; {
mime_types[n].mime = mime_type;
mime_types[n].weight = weight;
n++;
}
} }
} }
@ -492,7 +477,8 @@ cache_glob_node_lookup_suffix (XdgMimeCache *cache,
int weight; int weight;
int case_sensitive; int case_sensitive;
int min, max, mid, n, i; xdg_uint32_t i;
int min, max, mid, n;
character = file_name[len - 1]; character = file_name[len - 1];
@ -578,17 +564,17 @@ cache_glob_lookup_suffix (const char *file_name,
n_entries = GET_UINT32 (cache->buffer, list_offset); n_entries = GET_UINT32 (cache->buffer, list_offset);
offset = GET_UINT32 (cache->buffer, list_offset + 4); offset = GET_UINT32 (cache->buffer, list_offset + 4);
n += cache_glob_node_lookup_suffix (cache, n = cache_glob_node_lookup_suffix (cache,
n_entries, offset, n_entries, offset,
file_name, len, file_name, len,
ignore_case, ignore_case,
mime_types + n, mime_types,
n_mime_types - n); n_mime_types);
if (n == n_mime_types) if (n > 0)
break; return n;
} }
return n; return 0;
} }
static int compare_mime_weight (const void *a, const void *b) static int compare_mime_weight (const void *a, const void *b)
@ -680,14 +666,16 @@ cache_glob_lookup_file_name (const char *file_name,
if (n < 2) if (n < 2)
n += cache_glob_lookup_suffix (file_name, len, TRUE, mimes + n, n_mimes - n); n += cache_glob_lookup_suffix (file_name, len, TRUE, mimes + n, n_mimes - n);
free (lower_case);
/* Last, try fnmatch */ /* Last, try fnmatch */
if (n == 0)
n = cache_glob_lookup_fnmatch (lower_case, mimes, n_mimes, FALSE);
if (n < 2) if (n < 2)
n += cache_glob_lookup_fnmatch (file_name, mimes + n, n_mimes - n); n += cache_glob_lookup_fnmatch (file_name, mimes + n, n_mimes - n, TRUE);
n = filter_out_dupes (mimes, n); n = filter_out_dupes (mimes, n);
free (lower_case);
qsort (mimes, n, sizeof (MimeWeight), compare_mime_weight); qsort (mimes, n, sizeof (MimeWeight), compare_mime_weight);
if (n_mime_types < n) if (n_mime_types < n)
@ -743,8 +731,7 @@ cache_get_mime_type_for_data (const void *data,
if (cache->buffer == NULL) if (cache->buffer == NULL)
continue; continue;
match = cache_magic_lookup_data (cache, data, len, &prio, match = cache_magic_lookup_data (cache, data, len, &prio);
mime_types, n_mime_types);
if (prio > priority) if (prio > priority)
{ {
priority = prio; priority = prio;
@ -756,12 +743,25 @@ cache_get_mime_type_for_data (const void *data,
*result_prio = priority; *result_prio = priority;
if (priority > 0) if (priority > 0)
return mime_type; {
/* Pick glob-result R where mime_type inherits from R */
for (n = 0; n < n_mime_types; n++)
{
if (mime_types[n] && _xdg_mime_cache_mime_type_subclass(mime_types[n], mime_type))
return mime_types[n];
}
if (n == 0)
{
/* No globs: return magic match */
return mime_type;
}
}
/* Pick first glob result, as fallback */
for (n = 0; n < n_mime_types; n++) for (n = 0; n < n_mime_types; n++)
{ {
if (mime_types[n]) if (mime_types[n])
return mime_types[n]; return mime_types[n];
} }
return NULL; return NULL;
@ -844,7 +844,7 @@ _xdg_mime_cache_get_mime_type_for_file (const char *file_name,
mime_types, n); mime_types, n);
if (!mime_type) if (!mime_type)
mime_type = _xdg_binary_or_text_fallback(data, bytes_read); mime_type = _xdg_binary_or_text_fallback (data, bytes_read);
free (data); free (data);
fclose (file); fclose (file);
@ -905,7 +905,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
{ {
const char *umime, *ubase; const char *umime, *ubase;
int i, j, min, max, med, cmp; xdg_uint32_t j;
int i, min, max, med, cmp;
umime = _xdg_mime_cache_unalias_mime_type (mime); umime = _xdg_mime_cache_unalias_mime_type (mime);
ubase = _xdg_mime_cache_unalias_mime_type (base); ubase = _xdg_mime_cache_unalias_mime_type (base);
@ -995,7 +996,8 @@ _xdg_mime_cache_unalias_mime_type (const char *mime)
char ** char **
_xdg_mime_cache_list_mime_parents (const char *mime) _xdg_mime_cache_list_mime_parents (const char *mime)
{ {
int i, j, k, l, p; int i, l, p;
xdg_uint32_t j, k;
char *all_parents[128]; /* we'll stop at 128 */ char *all_parents[128]; /* we'll stop at 128 */
char **result; char **result;
@ -1120,6 +1122,7 @@ dump_glob_node (XdgMimeCache *cache,
xdg_uint32_t mime_offset; xdg_uint32_t mime_offset;
xdg_uint32_t n_children; xdg_uint32_t n_children;
xdg_uint32_t child_offset; xdg_uint32_t child_offset;
xdg_uint32_t k;
int i; int i;
character = GET_UINT32 (cache->buffer, offset); character = GET_UINT32 (cache->buffer, offset);
@ -1134,15 +1137,15 @@ dump_glob_node (XdgMimeCache *cache,
printf ("\n"); printf ("\n");
if (child_offset) if (child_offset)
{ {
for (i = 0; i < n_children; i++) for (k = 0; k < n_children; k++)
dump_glob_node (cache, child_offset + 20 * i, depth + 1); dump_glob_node (cache, child_offset + 20 * k, depth + 1);
} }
} }
void void
_xdg_mime_cache_glob_dump (void) _xdg_mime_cache_glob_dump (void)
{ {
int i, j; xdg_uint32_t i, j;
for (i = 0; _caches[i]; i++) for (i = 0; _caches[i]; i++)
{ {
XdgMimeCache *cache = _caches[i]; XdgMimeCache *cache = _caches[i];

View File

@ -19,7 +19,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_CACHE_H__ #ifndef __XDG_MIME_CACHE_H__

View File

@ -20,10 +20,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xdgmimeglob.h" #include "xdgmimeglob.h"
#include "xdgmimeint.h" #include "xdgmimeint.h"
@ -86,7 +90,7 @@ _xdg_glob_list_new (void)
return new_element; return new_element;
} }
/* Frees glob_list and all of it's children */ /* Frees glob_list and all of its children */
static void static void
_xdg_glob_list_free (XdgGlobList *glob_list) _xdg_glob_list_free (XdgGlobList *glob_list)
{ {

View File

@ -20,7 +20,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_GLOB_H__ #ifndef __XDG_MIME_GLOB_H__

View File

@ -19,10 +19,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xdgmimeicon.h" #include "xdgmimeicon.h"
#include "xdgmimeint.h" #include "xdgmimeint.h"
@ -178,3 +182,4 @@ _xdg_mime_icon_list_dump (XdgIconList *list)
} }
#endif #endif

View File

@ -19,7 +19,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_ICON_H__ #ifndef __XDG_MIME_ICON_H__

View File

@ -20,10 +20,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xdgmimeint.h" #include "xdgmimeint.h"
#include <ctype.h> #include <ctype.h>
@ -189,7 +193,7 @@ const char *
_xdg_binary_or_text_fallback(const void *data, size_t len) _xdg_binary_or_text_fallback(const void *data, size_t len)
{ {
unsigned char *chardata; unsigned char *chardata;
int i; size_t i;
chardata = (unsigned char *) data; chardata = (unsigned char *) data;
for (i = 0; i < 128 && i < len; ++i) for (i = 0; i < 128 && i < len; ++i)

View File

@ -20,7 +20,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_INT_H__ #ifndef __XDG_MIME_INT_H__

View File

@ -20,10 +20,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <assert.h> #include <assert.h>
#include "xdgmimemagic.h" #include "xdgmimemagic.h"
@ -316,7 +320,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
int c; int c;
int end_of_file; int end_of_file;
int indent = 0; int indent = 0;
int bytes_read; size_t bytes_read;
assert (magic_file != NULL); assert (magic_file != NULL);
@ -403,7 +407,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
return XDG_MIME_MAGIC_ERROR; return XDG_MIME_MAGIC_ERROR;
} }
bytes_read = fread (matchlet->value, 1, matchlet->value_length, magic_file); bytes_read = fread (matchlet->value, 1, matchlet->value_length, magic_file);
if (bytes_read != matchlet->value_length) if (bytes_read != (size_t) matchlet->value_length)
{ {
_xdg_mime_magic_matchlet_free (matchlet); _xdg_mime_magic_matchlet_free (matchlet);
if (feof (magic_file)) if (feof (magic_file))
@ -423,7 +427,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
return XDG_MIME_MAGIC_ERROR; return XDG_MIME_MAGIC_ERROR;
} }
bytes_read = fread (matchlet->mask, 1, matchlet->value_length, magic_file); bytes_read = fread (matchlet->mask, 1, matchlet->value_length, magic_file);
if (bytes_read != matchlet->value_length) if (bytes_read != (size_t) matchlet->value_length)
{ {
_xdg_mime_magic_matchlet_free (matchlet); _xdg_mime_magic_matchlet_free (matchlet);
if (feof (magic_file)) if (feof (magic_file))
@ -461,7 +465,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
_xdg_mime_magic_matchlet_free (matchlet); _xdg_mime_magic_matchlet_free (matchlet);
return XDG_MIME_MAGIC_EOF; return XDG_MIME_MAGIC_EOF;
} }
if (matchlet->range_length == -1) if (matchlet->range_length == (unsigned int) -1)
{ {
_xdg_mime_magic_matchlet_free (matchlet); _xdg_mime_magic_matchlet_free (matchlet);
return XDG_MIME_MAGIC_ERROR; return XDG_MIME_MAGIC_ERROR;
@ -475,9 +479,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
/* We clean up the matchlet, byte swapping if needed */ /* We clean up the matchlet, byte swapping if needed */
if (matchlet->word_size > 1) if (matchlet->word_size > 1)
{ {
#if LITTLE_ENDIAN unsigned int i;
int i;
#endif
if (matchlet->value_length % matchlet->word_size != 0) if (matchlet->value_length % matchlet->word_size != 0)
{ {
_xdg_mime_magic_matchlet_free (matchlet); _xdg_mime_magic_matchlet_free (matchlet);
@ -522,7 +524,7 @@ _xdg_mime_magic_matchlet_compare_to_data (XdgMimeMagicMatchlet *matchlet,
const void *data, const void *data,
size_t len) size_t len)
{ {
int i, j; unsigned 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; int valid_matchlet = TRUE;

View File

@ -20,7 +20,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_MAGIC_H__ #ifndef __XDG_MIME_MAGIC_H__

View File

@ -20,10 +20,14 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include "config.h" #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xdgmimeparent.h" #include "xdgmimeparent.h"
#include "xdgmimeint.h" #include "xdgmimeint.h"
@ -215,3 +219,4 @@ _xdg_mime_parent_list_dump (XdgParentList *list)
} }
#endif #endif

View File

@ -20,7 +20,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>. * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#ifndef __XDG_MIME_PARENT_H__ #ifndef __XDG_MIME_PARENT_H__