summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2021-09-27 11:50:48 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2021-09-27 11:50:48 +0000
commit60173d0a387b45016684be8846c291dabd0aa5e8 (patch)
treea5beab86ffd2f5019a0f9c775619f8ccc24066f4
parent1bfac1e4743fad363e3411c22df8775c419cff47 (diff)
parent2f98cbe483699a2246204d2a035c837a8b6d22d5 (diff)
downloadglib-60173d0a387b45016684be8846c291dabd0aa5e8.tar.gz
Merge branch 'xdgmime_update' into 'main'
Updating xdgmime See merge request GNOME/glib!2029
-rw-r--r--gio/xdgmime/meson.build3
-rw-r--r--gio/xdgmime/xdgmime.c28
-rw-r--r--gio/xdgmime/xdgmime.h4
-rw-r--r--gio/xdgmime/xdgmimealias.c8
-rw-r--r--gio/xdgmime/xdgmimealias.h4
-rw-r--r--gio/xdgmime/xdgmimecache.c139
-rw-r--r--gio/xdgmime/xdgmimecache.h4
-rw-r--r--gio/xdgmime/xdgmimeglob.c10
-rw-r--r--gio/xdgmime/xdgmimeglob.h4
-rw-r--r--gio/xdgmime/xdgmimeicon.c9
-rw-r--r--gio/xdgmime/xdgmimeicon.h4
-rw-r--r--gio/xdgmime/xdgmimeint.c10
-rw-r--r--gio/xdgmime/xdgmimeint.h4
-rw-r--r--gio/xdgmime/xdgmimemagic.c22
-rw-r--r--gio/xdgmime/xdgmimemagic.h4
-rw-r--r--gio/xdgmime/xdgmimeparent.c9
-rw-r--r--gio/xdgmime/xdgmimeparent.h4
17 files changed, 159 insertions, 111 deletions
diff --git a/gio/xdgmime/meson.build b/gio/xdgmime/meson.build
index d107f71bb..4c8a552a2 100644
--- a/gio/xdgmime/meson.build
+++ b/gio/xdgmime/meson.build
@@ -13,4 +13,5 @@ xdgmime_lib = static_library('xdgmime',
sources : xdgmime_sources,
include_directories : [configinc],
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)
diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c
index 9bb93f791..770a4dd0b 100644
--- a/gio/xdgmime/xdgmime.c
+++ b/gio/xdgmime/xdgmime.c
@@ -20,10 +20,14 @@
* 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, 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 "xdgmimeint.h"
@@ -134,7 +138,8 @@ xdg_dir_time_list_free (XdgDirTimeList *list)
}
static int
-xdg_mime_init_from_directory (const char *directory)
+xdg_mime_init_from_directory (const char *directory,
+ void *user_data)
{
char *file_name;
struct stat st;
@@ -400,10 +405,11 @@ xdg_check_file (const char *file_path,
static int
xdg_check_dir (const char *directory,
- int *invalid_dir_list)
+ void *user_data)
{
int invalid, exists;
char *file_name;
+ int* invalid_dir_list = user_data;
assert (directory != NULL);
@@ -458,8 +464,7 @@ xdg_check_dirs (void)
for (list = dir_time_list; list; list = list->next)
list->checked = XDG_CHECKED_UNCHECKED;
- xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_check_dir,
- &invalid_dir_list);
+ xdg_run_command_on_dirs (xdg_check_dir, &invalid_dir_list);
if (invalid_dir_list)
return TRUE;
@@ -515,8 +520,7 @@ xdg_mime_init (void)
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,
- NULL);
+ xdg_run_command_on_dirs (xdg_mime_init_from_directory, NULL);
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_types, n);
+ if (!mime_type)
+ mime_type = _xdg_binary_or_text_fallback (data, bytes_read);
+
free (data);
fclose (file);
- if (mime_type)
- return mime_type;
-
- return _xdg_binary_or_text_fallback(data, bytes_read);
+ return mime_type;
}
const char *
diff --git a/gio/xdgmime/xdgmime.h b/gio/xdgmime/xdgmime.h
index b175de107..92dbc3422 100644
--- a/gio/xdgmime/xdgmime.h
+++ b/gio/xdgmime/xdgmime.h
@@ -20,7 +20,9 @@
* 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, 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.
*/
diff --git a/gio/xdgmime/xdgmimealias.c b/gio/xdgmime/xdgmimealias.c
index bf95bc0d3..265191aab 100644
--- a/gio/xdgmime/xdgmimealias.c
+++ b/gio/xdgmime/xdgmimealias.c
@@ -20,10 +20,14 @@
* 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, 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 "xdgmimeint.h"
diff --git a/gio/xdgmime/xdgmimealias.h b/gio/xdgmime/xdgmimealias.h
index 46cbc99c3..2178b8b48 100644
--- a/gio/xdgmime/xdgmimealias.h
+++ b/gio/xdgmime/xdgmimealias.h
@@ -20,7 +20,9 @@
* 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, 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__
diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c
index 769b57836..3818180ae 100644
--- a/gio/xdgmime/xdgmimecache.c
+++ b/gio/xdgmime/xdgmimecache.c
@@ -19,10 +19,14 @@
* 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, 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 <stdlib.h>
@@ -39,7 +43,7 @@
#ifdef HAVE_MMAP
#include <sys/mman.h>
#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
#include <sys/stat.h>
@@ -117,9 +121,9 @@ _xdg_mime_cache_new_from_file (const char *file_name)
int minor;
/* Open the file and map it into memory */
- do
+ do {
fd = open (file_name, O_RDONLY|_O_BINARY, 0);
- while (fd == -1 && errno == EINTR);
+ } while (fd == -1 && errno == EINTR);
if (fd < 0)
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 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++)
{
@@ -199,16 +203,9 @@ cache_magic_matchlet_compare_to_data (XdgMimeCache *cache,
}
else
{
- for (j = 0; j < data_length; j++)
- {
- if (((unsigned char *)cache->buffer)[data_offset + j] != ((unsigned char *) data)[j + i])
- {
- valid_matchlet = FALSE;
- break;
- }
- }
+ valid_matchlet = memcmp(cache->buffer + data_offset, (unsigned char *)data + i, data_length) == 0;
}
-
+
if (valid_matchlet)
return TRUE;
}
@@ -225,7 +222,7 @@ cache_magic_matchlet_compare (XdgMimeCache *cache,
xdg_uint32_t n_children = GET_UINT32 (cache->buffer, offset + 24);
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))
{
@@ -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 matchlet_offset = GET_UINT32 (cache->buffer, offset + 12);
- int i;
+ xdg_uint32_t i;
for (i = 0; i < n_matchlets; i++)
{
@@ -275,15 +272,13 @@ static const char *
cache_magic_lookup_data (XdgMimeCache *cache,
const void *data,
size_t len,
- int *prio,
- const char *mime_types[],
- int n_mime_types)
+ int *prio)
{
xdg_uint32_t list_offset;
xdg_uint32_t n_entries;
xdg_uint32_t offset;
- int j, n;
+ xdg_uint32_t j;
*prio = 0;
@@ -299,21 +294,6 @@ cache_magic_lookup_data (XdgMimeCache *cache,
data, len, prio);
if (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;
@@ -428,12 +408,14 @@ cache_glob_lookup_literal (const char *file_name,
static int
cache_glob_lookup_fnmatch (const char *file_name,
MimeWeight mime_types[],
- int n_mime_types)
+ int n_mime_types,
+ int case_sensitive_check)
{
const char *mime_type;
const char *ptr;
- int i, j, n;
+ int i, n;
+ xdg_uint32_t j;
n = 0;
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 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 case_sensitive = weight & 0x100;
weight = weight & 0xff;
ptr = cache->buffer + offset;
mime_type = cache->buffer + mimetype_offset;
-
- /* FIXME: Not UTF-8 safe */
- if (fnmatch (ptr, file_name, 0) == 0)
+ if (case_sensitive_check || !case_sensitive)
{
- mime_types[n].mime = mime_type;
- mime_types[n].weight = weight;
- n++;
+ /* FIXME: Not UTF-8 safe */
+ if (fnmatch (ptr, file_name, 0) == 0)
+ {
+ 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 case_sensitive;
- int min, max, mid, n, i;
+ xdg_uint32_t i;
+ int min, max, mid, n;
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);
offset = GET_UINT32 (cache->buffer, list_offset + 4);
- n += cache_glob_node_lookup_suffix (cache,
- n_entries, offset,
- file_name, len,
- ignore_case,
- mime_types + n,
- n_mime_types - n);
- if (n == n_mime_types)
- break;
+ n = cache_glob_node_lookup_suffix (cache,
+ n_entries, offset,
+ file_name, len,
+ ignore_case,
+ mime_types,
+ n_mime_types);
+ if (n > 0)
+ return n;
}
- return n;
+ return 0;
}
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)
n += cache_glob_lookup_suffix (file_name, len, TRUE, mimes + n, n_mimes - n);
- free (lower_case);
-
/* Last, try fnmatch */
+ if (n == 0)
+ n = cache_glob_lookup_fnmatch (lower_case, mimes, n_mimes, FALSE);
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);
+ free (lower_case);
+
qsort (mimes, n, sizeof (MimeWeight), compare_mime_weight);
if (n_mime_types < n)
@@ -743,8 +731,7 @@ cache_get_mime_type_for_data (const void *data,
if (cache->buffer == NULL)
continue;
- match = cache_magic_lookup_data (cache, data, len, &prio,
- mime_types, n_mime_types);
+ match = cache_magic_lookup_data (cache, data, len, &prio);
if (prio > priority)
{
priority = prio;
@@ -754,14 +741,27 @@ cache_get_mime_type_for_data (const void *data,
if (result_prio)
*result_prio = priority;
-
+
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++)
{
if (mime_types[n])
- return mime_types[n];
+ return mime_types[n];
}
return NULL;
@@ -844,7 +844,7 @@ _xdg_mime_cache_get_mime_type_for_file (const char *file_name,
mime_types, n);
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);
fclose (file);
@@ -905,7 +905,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
{
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);
ubase = _xdg_mime_cache_unalias_mime_type (base);
@@ -995,7 +996,8 @@ _xdg_mime_cache_unalias_mime_type (const char *mime)
char **
_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 **result;
@@ -1120,6 +1122,7 @@ dump_glob_node (XdgMimeCache *cache,
xdg_uint32_t mime_offset;
xdg_uint32_t n_children;
xdg_uint32_t child_offset;
+ xdg_uint32_t k;
int i;
character = GET_UINT32 (cache->buffer, offset);
@@ -1134,15 +1137,15 @@ dump_glob_node (XdgMimeCache *cache,
printf ("\n");
if (child_offset)
{
- for (i = 0; i < n_children; i++)
- dump_glob_node (cache, child_offset + 20 * i, depth + 1);
+ for (k = 0; k < n_children; k++)
+ dump_glob_node (cache, child_offset + 20 * k, depth + 1);
}
}
void
_xdg_mime_cache_glob_dump (void)
{
- int i, j;
+ xdg_uint32_t i, j;
for (i = 0; _caches[i]; i++)
{
XdgMimeCache *cache = _caches[i];
diff --git a/gio/xdgmime/xdgmimecache.h b/gio/xdgmime/xdgmimecache.h
index 2723c5396..fdce80f64 100644
--- a/gio/xdgmime/xdgmimecache.h
+++ b/gio/xdgmime/xdgmimecache.h
@@ -19,7 +19,9 @@
* 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, 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__
diff --git a/gio/xdgmime/xdgmimeglob.c b/gio/xdgmime/xdgmimeglob.c
index c18762e9a..a4c80c51d 100644
--- a/gio/xdgmime/xdgmimeglob.c
+++ b/gio/xdgmime/xdgmimeglob.c
@@ -20,10 +20,14 @@
* 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, 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 "xdgmimeint.h"
@@ -86,7 +90,7 @@ _xdg_glob_list_new (void)
return new_element;
}
-/* Frees glob_list and all of it's children */
+/* Frees glob_list and all of its children */
static void
_xdg_glob_list_free (XdgGlobList *glob_list)
{
diff --git a/gio/xdgmime/xdgmimeglob.h b/gio/xdgmime/xdgmimeglob.h
index 79ccdc292..523e5f242 100644
--- a/gio/xdgmime/xdgmimeglob.h
+++ b/gio/xdgmime/xdgmimeglob.h
@@ -20,7 +20,9 @@
* 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, 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__
diff --git a/gio/xdgmime/xdgmimeicon.c b/gio/xdgmime/xdgmimeicon.c
index a2f4dd2a7..715832231 100644
--- a/gio/xdgmime/xdgmimeicon.c
+++ b/gio/xdgmime/xdgmimeicon.c
@@ -19,10 +19,14 @@
* 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, 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 "xdgmimeint.h"
@@ -178,3 +182,4 @@ _xdg_mime_icon_list_dump (XdgIconList *list)
}
#endif
+
diff --git a/gio/xdgmime/xdgmimeicon.h b/gio/xdgmime/xdgmimeicon.h
index 6141a8668..1718cb4c0 100644
--- a/gio/xdgmime/xdgmimeicon.h
+++ b/gio/xdgmime/xdgmimeicon.h
@@ -19,7 +19,9 @@
* 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, 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__
diff --git a/gio/xdgmime/xdgmimeint.c b/gio/xdgmime/xdgmimeint.c
index 35c3635e2..5e4513c50 100644
--- a/gio/xdgmime/xdgmimeint.c
+++ b/gio/xdgmime/xdgmimeint.c
@@ -20,10 +20,14 @@
* 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, 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 <ctype.h>
@@ -189,7 +193,7 @@ const char *
_xdg_binary_or_text_fallback(const void *data, size_t len)
{
unsigned char *chardata;
- int i;
+ size_t i;
chardata = (unsigned char *) data;
for (i = 0; i < 128 && i < len; ++i)
diff --git a/gio/xdgmime/xdgmimeint.h b/gio/xdgmime/xdgmimeint.h
index c9270139e..9a8256d17 100644
--- a/gio/xdgmime/xdgmimeint.h
+++ b/gio/xdgmime/xdgmimeint.h
@@ -20,7 +20,9 @@
* 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, 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__
diff --git a/gio/xdgmime/xdgmimemagic.c b/gio/xdgmime/xdgmimemagic.c
index 51be9722b..c68e27bed 100644
--- a/gio/xdgmime/xdgmimemagic.c
+++ b/gio/xdgmime/xdgmimemagic.c
@@ -20,10 +20,14 @@
* 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, 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 "xdgmimemagic.h"
@@ -316,7 +320,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
int c;
int end_of_file;
int indent = 0;
- int bytes_read;
+ size_t bytes_read;
assert (magic_file != NULL);
@@ -403,7 +407,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
return XDG_MIME_MAGIC_ERROR;
}
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);
if (feof (magic_file))
@@ -423,7 +427,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
return XDG_MIME_MAGIC_ERROR;
}
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);
if (feof (magic_file))
@@ -461,7 +465,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
_xdg_mime_magic_matchlet_free (matchlet);
return XDG_MIME_MAGIC_EOF;
}
- if (matchlet->range_length == -1)
+ if (matchlet->range_length == (unsigned int) -1)
{
_xdg_mime_magic_matchlet_free (matchlet);
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 */
if (matchlet->word_size > 1)
{
-#if LITTLE_ENDIAN
- int i;
-#endif
+ unsigned int i;
if (matchlet->value_length % matchlet->word_size != 0)
{
_xdg_mime_magic_matchlet_free (matchlet);
@@ -522,7 +524,7 @@ _xdg_mime_magic_matchlet_compare_to_data (XdgMimeMagicMatchlet *matchlet,
const void *data,
size_t len)
{
- int i, j;
+ unsigned int i, j;
for (i = matchlet->offset; i < matchlet->offset + matchlet->range_length; i++)
{
int valid_matchlet = TRUE;
diff --git a/gio/xdgmime/xdgmimemagic.h b/gio/xdgmime/xdgmimemagic.h
index c990acee8..eb06a81f8 100644
--- a/gio/xdgmime/xdgmimemagic.h
+++ b/gio/xdgmime/xdgmimemagic.h
@@ -20,7 +20,9 @@
* 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, 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__
diff --git a/gio/xdgmime/xdgmimeparent.c b/gio/xdgmime/xdgmimeparent.c
index b06b749d4..c636f4a9c 100644
--- a/gio/xdgmime/xdgmimeparent.c
+++ b/gio/xdgmime/xdgmimeparent.c
@@ -20,10 +20,14 @@
* 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, 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 "xdgmimeint.h"
@@ -215,3 +219,4 @@ _xdg_mime_parent_list_dump (XdgParentList *list)
}
#endif
+
diff --git a/gio/xdgmime/xdgmimeparent.h b/gio/xdgmime/xdgmimeparent.h
index e3cdad5bf..a95533e15 100644
--- a/gio/xdgmime/xdgmimeparent.h
+++ b/gio/xdgmime/xdgmimeparent.h
@@ -20,7 +20,9 @@
* 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, 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__