Whitespace fixes

This commit is contained in:
Matthias Clasen 2014-12-12 16:50:19 -05:00
parent b6acc8f2c5
commit 0dfbcd60c9
2 changed files with 197 additions and 197 deletions

View File

@ -21,50 +21,50 @@
#include <gdk-pixbuf/gdk-pixdata.h>
#define VERBOSE(x)
#define VERBOSE(x)
#define check(name,condition) \
if (!(condition)) \
{ \
VERBOSE(g_print ("bad %s\n", (name))); \
return FALSE; \
}
}
static inline gboolean
get_uint16 (CacheInfo *info,
guint32 offset,
static inline gboolean
get_uint16 (CacheInfo *info,
guint32 offset,
guint16 *value)
{
if (offset < info->cache_size)
{
*value = GUINT16_FROM_BE(*(guint16*)(info->cache + offset));
if (offset < info->cache_size)
{
*value = GUINT16_FROM_BE(*(guint16*)(info->cache + offset));
return TRUE;
}
else
{
else
{
*value = 0;
return FALSE;
}
return FALSE;
}
}
static inline gboolean
get_uint32 (CacheInfo *info,
guint32 offset,
static inline gboolean
get_uint32 (CacheInfo *info,
guint32 offset,
guint32 *value)
{
if (offset < info->cache_size)
{
*value = GUINT32_FROM_BE(*(guint32*)(info->cache + offset));
if (offset < info->cache_size)
{
*value = GUINT32_FROM_BE(*(guint32*)(info->cache + offset));
return TRUE;
}
else
{
else
{
*value = 0;
return FALSE;
}
return FALSE;
}
}
static gboolean
static gboolean
check_version (CacheInfo *info)
{
guint16 major, minor;
@ -75,20 +75,20 @@ check_version (CacheInfo *info)
return TRUE;
}
static gboolean
check_string (CacheInfo *info,
static gboolean
check_string (CacheInfo *info,
guint32 offset)
{
check ("string offset", offset < info->cache_size);
if (info->flags & CHECK_STRINGS)
if (info->flags & CHECK_STRINGS)
{
gint i;
gchar c;
/* assume no string is longer than 1k */
for (i = 0; i < 1024; i++)
{
for (i = 0; i < 1024; i++)
{
check ("string offset", offset + i < info->cache_size)
c = *(info->cache + offset + i);
if (c == '\0')
@ -101,20 +101,20 @@ check_string (CacheInfo *info,
return TRUE;
}
static gboolean
check_string_utf8 (CacheInfo *info,
static gboolean
check_string_utf8 (CacheInfo *info,
guint32 offset)
{
check ("string offset", offset < info->cache_size);
if (info->flags & CHECK_STRINGS)
if (info->flags & CHECK_STRINGS)
{
gint i;
gchar c;
/* assume no string is longer than 1k */
for (i = 0; i < 1024; i++)
{
for (i = 0; i < 1024; i++)
{
check ("string offset", offset + i < info->cache_size)
c = *(info->cache + offset + i);
if (c == '\0')
@ -127,16 +127,16 @@ check_string_utf8 (CacheInfo *info,
return TRUE;
}
static gboolean
check_directory_list (CacheInfo *info,
static gboolean
check_directory_list (CacheInfo *info,
guint32 offset)
{
guint32 directory_offset;
gint i;
check ("offset, directory list", get_uint32 (info, offset, &info->n_directories));
for (i = 0; i < info->n_directories; i++)
for (i = 0; i < info->n_directories; i++)
{
check ("offset, directory", get_uint32 (info, offset + 4 + 4 * i, &directory_offset));
if (!check_string (info, directory_offset))
@ -146,8 +146,8 @@ check_directory_list (CacheInfo *info,
return TRUE;
}
static gboolean
check_pixel_data (CacheInfo *info,
static gboolean
check_pixel_data (CacheInfo *info,
guint32 offset)
{
guint32 type;
@ -159,20 +159,20 @@ check_pixel_data (CacheInfo *info,
check ("pixel data type", type == 0);
check ("pixel data length", offset + 8 + length < info->cache_size);
if (info->flags & CHECK_PIXBUFS)
if (info->flags & CHECK_PIXBUFS)
{
GdkPixdata data;
GdkPixdata data;
check ("pixel data", gdk_pixdata_deserialize (&data, length,
(const guint8*)info->cache + offset + 8,
(const guint8*)info->cache + offset + 8,
NULL));
}
return TRUE;
}
static gboolean
check_embedded_rect (CacheInfo *info,
static gboolean
check_embedded_rect (CacheInfo *info,
guint32 offset)
{
check ("embedded rect", offset + 4 < info->cache_size);
@ -180,28 +180,28 @@ check_embedded_rect (CacheInfo *info,
return TRUE;
}
static gboolean
check_attach_point_list (CacheInfo *info,
static gboolean
check_attach_point_list (CacheInfo *info,
guint32 offset)
{
guint32 n_attach_points;
check ("offset, attach point list", get_uint32 (info, offset, &n_attach_points));
check ("attach points", offset + 4 + 4 * n_attach_points < info->cache_size);
check ("attach points", offset + 4 + 4 * n_attach_points < info->cache_size);
return TRUE;
}
static gboolean
check_display_name_list (CacheInfo *info,
static gboolean
check_display_name_list (CacheInfo *info,
guint32 offset)
{
guint32 n_display_names, ofs;
gint i;
check ("offset, display name list",
check ("offset, display name list",
get_uint32 (info, offset, &n_display_names));
for (i = 0; i < n_display_names; i++)
for (i = 0; i < n_display_names; i++)
{
get_uint32(info, offset + 4 + 8 * i, &ofs);
if (!check_string (info, ofs))
@ -210,38 +210,38 @@ check_display_name_list (CacheInfo *info,
if (!check_string_utf8 (info, ofs))
return FALSE;
}
return TRUE;
return TRUE;
}
static gboolean
check_meta_data (CacheInfo *info,
static gboolean
check_meta_data (CacheInfo *info,
guint32 offset)
{
guint32 embedded_rect_offset;
guint32 attach_point_list_offset;
guint32 display_name_list_offset;
check ("offset, embedded rect",
check ("offset, embedded rect",
get_uint32 (info, offset, &embedded_rect_offset));
check ("offset, attach point list",
check ("offset, attach point list",
get_uint32 (info, offset + 4, &attach_point_list_offset));
check ("offset, display name list",
check ("offset, display name list",
get_uint32 (info, offset + 8, &display_name_list_offset));
if (embedded_rect_offset != 0)
if (embedded_rect_offset != 0)
{
if (!check_embedded_rect (info, embedded_rect_offset))
return FALSE;
}
if (attach_point_list_offset != 0)
if (attach_point_list_offset != 0)
{
if (!check_attach_point_list (info, attach_point_list_offset))
return FALSE;
}
if (display_name_list_offset != 0)
if (display_name_list_offset != 0)
{
if (!check_display_name_list (info, display_name_list_offset))
return FALSE;
@ -250,8 +250,8 @@ check_meta_data (CacheInfo *info,
return TRUE;
}
static gboolean
check_image_data (CacheInfo *info,
static gboolean
check_image_data (CacheInfo *info,
guint32 offset)
{
guint32 pixel_data_offset;
@ -260,22 +260,22 @@ check_image_data (CacheInfo *info,
check ("offset, pixel data", get_uint32 (info, offset, &pixel_data_offset));
check ("offset, meta data", get_uint32 (info, offset + 4, &meta_data_offset));
if (pixel_data_offset != 0)
if (pixel_data_offset != 0)
{
if (!check_pixel_data (info, pixel_data_offset))
return FALSE;
}
if (meta_data_offset != 0)
if (meta_data_offset != 0)
{
if (!check_meta_data (info, meta_data_offset))
return FALSE;
}
return TRUE;
}
static gboolean
check_image (CacheInfo *info,
static gboolean
check_image (CacheInfo *info,
guint32 offset)
{
guint16 index;
@ -284,13 +284,13 @@ check_image (CacheInfo *info,
check ("offset, image index", get_uint16 (info, offset, &index));
check ("offset, image flags", get_uint16 (info, offset + 2, &flags));
check ("offset, image data offset",
check ("offset, image data offset",
get_uint32 (info, offset + 4, &image_data_offset));
check ("image index", index < info->n_directories);
check ("image flags", flags < 16);
if (image_data_offset != 0)
if (image_data_offset != 0)
{
if (!check_image_data (info, image_data_offset))
return FALSE;
@ -299,16 +299,16 @@ check_image (CacheInfo *info,
return TRUE;
}
static gboolean
check_image_list (CacheInfo *info,
static gboolean
check_image_list (CacheInfo *info,
guint32 offset)
{
guint32 n_images;
gint i;
check ("offset, image list", get_uint32 (info, offset, &n_images));
for (i = 0; i < n_images; i++)
for (i = 0; i < n_images; i++)
{
if (!check_image (info, offset + 4 + 8 * i))
return FALSE;
@ -317,8 +317,8 @@ check_image_list (CacheInfo *info,
return TRUE;
}
static gboolean
check_icon (CacheInfo *info,
static gboolean
check_icon (CacheInfo *info,
guint32 offset)
{
guint32 chain_offset;
@ -327,14 +327,14 @@ check_icon (CacheInfo *info,
check ("offset, icon chain", get_uint32 (info, offset, &chain_offset));
check ("offset, icon name", get_uint32 (info, offset + 4, &name_offset));
check ("offset, icon image list", get_uint32 (info, offset + 8,
check ("offset, icon image list", get_uint32 (info, offset + 8,
&image_list_offset));
if (!check_string (info, name_offset))
return FALSE;
if (!check_image_list (info, image_list_offset))
return FALSE;
if (chain_offset != 0xffffffff)
if (chain_offset != 0xffffffff)
{
if (!check_icon (info, chain_offset))
return FALSE;
@ -343,8 +343,8 @@ check_icon (CacheInfo *info,
return TRUE;
}
static gboolean
check_hash (CacheInfo *info,
static gboolean
check_hash (CacheInfo *info,
guint32 offset)
{
guint32 n_buckets, icon_offset;
@ -352,11 +352,11 @@ check_hash (CacheInfo *info,
check ("offset, hash size", get_uint32 (info, offset, &n_buckets));
for (i = 0; i < n_buckets; i++)
for (i = 0; i < n_buckets; i++)
{
check ("offset, hash chain",
check ("offset, hash chain",
get_uint32 (info, offset + 4 + 4 * i, &icon_offset));
if (icon_offset != 0xffffffff)
if (icon_offset != 0xffffffff)
{
if (!check_icon (info, icon_offset))
return FALSE;
@ -368,7 +368,7 @@ check_hash (CacheInfo *info,
/**
* _gtk_icon_cache_validate:
* @info: a CacheInfo structure
* @info: a CacheInfo structure
*
* Validates the icon cache passed in the @cache and
* @cache_size fields of the @info structure. The
@ -376,11 +376,11 @@ check_hash (CacheInfo *info,
* cache do not point outside the mapped area, that
* strings look reasonable, and that pixbufs can
* be deserialized. The amount of validation can
* be controlled with the @flags field.
* be controlled with the @flags field.
*
* Returns: %TRUE if the cache is valid
*/
gboolean
gboolean
_gtk_icon_cache_validate (CacheInfo *info)
{
guint32 hash_offset;

View File

@ -74,7 +74,7 @@ static gchar *var_name = "-";
static GStatBuf cache_stat;
static gboolean cache_up_to_date;
static int check_dir_mtime (const char *dir,
static int check_dir_mtime (const char *dir,
const GStatBuf *sb,
int tf)
{
@ -97,7 +97,7 @@ is_cache_up_to_date (const gchar *path)
cache_path = g_build_filename (path, CACHE_NAME, NULL);
retval = g_stat (cache_path, &cache_stat);
g_free (cache_path);
if (retval < 0)
{
/* Cache file not found */
@ -118,11 +118,11 @@ is_cache_up_to_date (const gchar *path)
{
GStatBuf path_stat, cache_stat;
gchar *cache_path;
int retval;
int retval;
retval = g_stat (path, &path_stat);
if (retval < 0)
if (retval < 0)
{
/* We can't stat the path,
* assume we have a updated cache */
@ -132,7 +132,7 @@ is_cache_up_to_date (const gchar *path)
cache_path = g_build_filename (path, CACHE_NAME, NULL);
retval = g_stat (cache_path, &cache_stat);
g_free (cache_path);
if (retval < 0)
{
/* Cache file not found */
@ -154,14 +154,14 @@ has_theme_index (const gchar *path)
index_path = g_build_filename (path, "index.theme", NULL);
result = g_file_test (index_path, G_FILE_TEST_IS_REGULAR);
g_free (index_path);
return result;
}
typedef struct
typedef struct
{
GdkPixdata pixdata;
gboolean has_pixdata;
@ -169,14 +169,14 @@ typedef struct
guint size;
} ImageData;
typedef struct
typedef struct
{
int has_embedded_rect;
int x0, y0, x1, y1;
int n_attach_points;
int *attach_points;
int n_display_names;
char **display_names;
@ -206,7 +206,7 @@ foreach_remove_func (gpointer key, gpointer value, gpointer user_data)
Image *image = (Image *)value;
GHashTable *files = user_data;
GList *list;
gboolean free_key = FALSE;
gboolean free_key = FALSE;
if (image->flags == HAS_ICON_FILE)
{
@ -220,13 +220,13 @@ foreach_remove_func (gpointer key, gpointer value, gpointer user_data)
list = g_hash_table_lookup (files, key);
if (list)
free_key = TRUE;
list = g_list_prepend (list, value);
g_hash_table_insert (files, key, list);
if (free_key)
g_free (key);
return TRUE;
}
@ -244,7 +244,7 @@ load_icon_data (const char *path)
gchar **keys;
gsize n_keys;
IconData *data;
icon_file = g_key_file_new ();
g_key_file_set_list_separator (icon_file, ',');
g_key_file_load_from_file (icon_file, path, G_KEY_FILE_KEEP_TRANSLATIONS, &error);
@ -258,7 +258,7 @@ load_icon_data (const char *path)
data = g_new0 (IconData, 1);
ivalues = g_key_file_get_integer_list (icon_file,
ivalues = g_key_file_get_integer_list (icon_file,
"Icon Data", "EmbeddedTextRectangle",
&length, NULL);
if (ivalues)
@ -271,15 +271,15 @@ load_icon_data (const char *path)
data->x1 = ivalues[2];
data->y1 = ivalues[3];
}
g_free (ivalues);
}
str = g_key_file_get_string (icon_file, "Icon Data", "AttachPoints", NULL);
if (str)
{
split = g_strsplit (str, "|", -1);
data->n_attach_points = g_strv_length (split);
data->attach_points = g_new (int, 2 * data->n_attach_points);
@ -296,23 +296,23 @@ load_icon_data (const char *path)
}
i++;
}
g_strfreev (split);
g_free (str);
}
keys = g_key_file_get_keys (icon_file, "Icon Data", &n_keys, &error);
data->display_names = g_new0 (gchar *, 2 * n_keys + 1);
data->display_names = g_new0 (gchar *, 2 * n_keys + 1);
data->n_display_names = 0;
for (i = 0; i < n_keys; i++)
{
gchar *lang, *name;
if (g_str_has_prefix (keys[i], "DisplayName"))
{
gchar *open, *close = NULL;
open = strchr (keys[i], '[');
if (open)
@ -321,18 +321,18 @@ load_icon_data (const char *path)
if (open && close)
{
lang = g_strndup (open + 1, close - open - 1);
name = g_key_file_get_locale_string (icon_file,
name = g_key_file_get_locale_string (icon_file,
"Icon Data", "DisplayName",
lang, NULL);
}
else
{
lang = g_strdup ("C");
name = g_key_file_get_string (icon_file,
name = g_key_file_get_string (icon_file,
"Icon Data", "DisplayName",
NULL);
}
data->display_names[2 * data->n_display_names] = lang;
data->display_names[2 * data->n_display_names + 1] = name;
data->n_display_names++;
@ -340,12 +340,12 @@ load_icon_data (const char *path)
}
g_strfreev (keys);
g_key_file_free (icon_file);
/* -1 means not computed yet, the real value depends
* on string pool state, and will be computed
* later
* on string pool state, and will be computed
* later
*/
data->size = -1;
@ -436,7 +436,7 @@ follow_links (const gchar *path)
while (g_file_test (path2, G_FILE_TEST_IS_SYMLINK))
{
target = g_file_read_link (path2, NULL);
if (target)
{
if (g_path_is_absolute (target))
@ -465,10 +465,10 @@ follow_links (const gchar *path)
}
static void
maybe_cache_image_data (Image *image,
maybe_cache_image_data (Image *image,
const gchar *path)
{
if (!index_only && !image->image_data &&
if (!index_only && !image->image_data &&
(g_str_has_suffix (path, ".png") || g_str_has_suffix (path, ".xpm")))
{
GdkPixbuf *pixbuf;
@ -483,7 +483,7 @@ maybe_cache_image_data (Image *image,
ImageData *idata2;
canonicalize_filename (path2);
idata2 = g_hash_table_lookup (image_data_hash, path2);
if (idata && idata2 && idata != idata2)
@ -499,20 +499,20 @@ maybe_cache_image_data (Image *image,
idata = idata2;
}
}
if (!idata)
{
idata = g_new0 (ImageData, 1);
g_hash_table_insert (image_data_hash, g_strdup (path), idata);
if (path2)
g_hash_table_insert (image_data_hash, g_strdup (path2), idata);
g_hash_table_insert (image_data_hash, g_strdup (path2), idata);
}
if (!idata->has_pixdata)
{
pixbuf = gdk_pixbuf_new_from_file (path, NULL);
if (pixbuf)
if (pixbuf)
{
gdk_pixdata_from_pixbuf (&idata->pixdata, pixbuf, FALSE);
idata->size = idata->pixdata.length + 8;
@ -543,7 +543,7 @@ maybe_cache_icon_data (Image *image,
IconData *idata2;
canonicalize_filename (path2);
idata2 = g_hash_table_lookup (icon_data_hash, path2);
if (idata && idata2 && idata != idata2)
@ -559,13 +559,13 @@ maybe_cache_icon_data (Image *image,
idata = idata2;
}
}
if (!idata)
{
idata = load_icon_data (path);
g_hash_table_insert (icon_data_hash, g_strdup (path), idata);
if (path2)
g_hash_table_insert (icon_data_hash, g_strdup (path2), idata);
g_hash_table_insert (icon_data_hash, g_strdup (path2), idata);
}
image->icon_data = idata;
@ -592,9 +592,9 @@ replace_backslashes_with_slashes (gchar *path)
}
static GList *
scan_directory (const gchar *base_path,
const gchar *subdir,
GHashTable *files,
scan_directory (const gchar *base_path,
const gchar *subdir,
GHashTable *files,
GList *directories,
gint depth)
{
@ -604,15 +604,15 @@ scan_directory (const gchar *base_path,
gchar *dir_path;
gboolean dir_added = FALSE;
guint dir_index = 0xffff;
dir_path = g_build_path ("/", base_path, subdir, NULL);
/* FIXME: Use the gerror */
dir = g_dir_open (dir_path, 0, NULL);
if (!dir)
return directories;
dir_hash = g_hash_table_new (g_str_hash, g_str_equal);
while ((name = g_dir_read_name (dir)))
@ -634,7 +634,7 @@ scan_directory (const gchar *base_path,
subsubdir = g_build_path ("/", subdir, name, NULL);
else
subsubdir = g_strdup (name);
directories = scan_directory (base_path, subsubdir, files,
directories = scan_directory (base_path, subsubdir, files,
directories, depth + 1);
g_free (subsubdir);
@ -656,18 +656,18 @@ scan_directory (const gchar *base_path,
flags |= HAS_SUFFIX_XPM;
else if (g_str_has_suffix (name, ".icon"))
flags |= HAS_ICON_FILE;
if (flags == 0)
continue;
basename = g_strdup (name);
dot = strrchr (basename, '.');
*dot = '\0';
image = g_hash_table_lookup (dir_hash, basename);
if (!image)
{
if (!dir_added)
if (!dir_added)
{
dir_added = TRUE;
if (subdir)
@ -678,17 +678,17 @@ scan_directory (const gchar *base_path,
else
dir_index = 0xffff;
}
image = g_new0 (Image, 1);
image->dir_index = dir_index;
g_hash_table_insert (dir_hash, g_strdup (basename), image);
}
image->flags |= flags;
maybe_cache_image_data (image, path);
maybe_cache_icon_data (image, path);
g_free (basename);
}
@ -699,7 +699,7 @@ scan_directory (const gchar *base_path,
/* Move dir into the big file hash */
g_hash_table_foreach_remove (dir_hash, foreach_remove_func, files);
g_hash_table_destroy (dir_hash);
return directories;
@ -739,7 +739,7 @@ convert_to_hash (gpointer key, gpointer value, gpointer user_data)
HashContext *context = user_data;
guint hash;
HashNode *node;
hash = icon_name_hash (key) % context->size;
node = g_new0 (HashNode, 1);
@ -751,12 +751,12 @@ convert_to_hash (gpointer key, gpointer value, gpointer user_data)
node->next = context->nodes[hash];
context->nodes[hash] = node;
return TRUE;
}
static GHashTable *string_pool = NULL;
static int
find_string (const gchar *n)
{
@ -774,9 +774,9 @@ write_string (FILE *cache, const gchar *n)
{
gchar *s;
int i, l;
l = ALIGN_VALUE (strlen (n) + 1, 4);
s = g_malloc0 (l);
strcpy (s, n);
@ -785,7 +785,7 @@ write_string (FILE *cache, const gchar *n)
g_free (s);
return i == 1;
}
static gboolean
@ -794,7 +794,7 @@ write_card16 (FILE *cache, guint16 n)
int i;
n = GUINT16_TO_BE (n);
i = fwrite ((char *)&n, 2, 1, cache);
return i == 1;
@ -806,7 +806,7 @@ write_card32 (FILE *cache, guint32 n)
int i;
n = GUINT32_TO_BE (n);
i = fwrite ((char *)&n, 4, 1, cache);
return i == 1;
@ -834,7 +834,7 @@ write_image_data (FILE *cache, ImageData *image_data, int offset)
}
i = fwrite (s, len, 1, cache);
g_free (s);
return i == 1;
@ -851,15 +851,15 @@ write_icon_data (FILE *cache, IconData *icon_data, int offset)
{
if (!write_card32 (cache, ofs))
return FALSE;
ofs += 8;
}
}
else
{
if (!write_card32 (cache, 0))
return FALSE;
}
if (icon_data->n_attach_points > 0)
{
if (!write_card32 (cache, ofs))
@ -897,12 +897,12 @@ write_icon_data (FILE *cache, IconData *icon_data, int offset)
{
if (!write_card32 (cache, icon_data->n_attach_points))
return FALSE;
for (j = 0; j < 2 * icon_data->n_attach_points; j++)
{
if (!write_card16 (cache, icon_data->attach_points[j]))
return FALSE;
}
}
}
if (icon_data->n_display_names > 0)
@ -921,7 +921,7 @@ write_icon_data (FILE *cache, IconData *icon_data, int offset)
tmp2 = tmp;
tmp += ALIGN_VALUE (strlen (icon_data->display_names[j]) + 1, 4);
/* We're playing a little game with negative
* offsets here to handle duplicate strings in
* offsets here to handle duplicate strings in
* the array.
*/
add_string (icon_data->display_names[j], -tmp2);
@ -950,7 +950,7 @@ write_icon_data (FILE *cache, IconData *icon_data, int offset)
return FALSE;
}
}
}
}
return TRUE;
}
@ -972,7 +972,7 @@ get_image_meta_data_size (Image *image)
/* The complication with storing the size in both
* IconData and Image is necessary since we attribute
* the size of the IconData only to the first Image
* using it (at which time it is written out in the
* using it (at which time it is written out in the
* cache). Later Images just refer to the written out
* IconData via the offset.
*/
@ -1000,7 +1000,7 @@ get_image_meta_data_size (Image *image)
data->size += 4 + 8 * data->n_display_names;
for (i = 0; data->display_names[i]; i++)
{
{
int poolv;
if ((poolv = find_string (data->display_names[i])) == 0)
{
@ -1014,7 +1014,7 @@ get_image_meta_data_size (Image *image)
add_string (data->display_names[i], -1);
}
}
}
}
image->icon_data_size = data->size;
data->size = 0;
@ -1032,13 +1032,13 @@ get_image_pixel_data_size (Image *image)
/* The complication with storing the size in both
* ImageData and Image is necessary since we attribute
* the size of the ImageData only to the first Image
* using it (at which time it is written out in the
* using it (at which time it is written out in the
* cache). Later Images just refer to the written out
* ImageData via the offset.
*/
if (image->pixel_data_size == 0)
{
if (image->image_data &&
if (image->image_data &&
image->image_data->has_pixdata)
{
image->pixel_data_size = image->image_data->size;
@ -1055,14 +1055,14 @@ static gint
get_image_data_size (Image *image)
{
gint len;
len = 0;
len += get_image_pixel_data_size (image);
len += get_image_meta_data_size (image);
/* Even if len is zero, we need to reserve space to
* write the ImageData, unless this is an .svg without
* write the ImageData, unless this is an .svg without
* .icon, in which case both image_data and icon_data
* are NULL.
*/
@ -1089,7 +1089,7 @@ get_single_node_size (HashNode *node, int *node_size, int *image_data_size)
/* Image list */
*node_size += 4 + g_list_length (node->image_list) * 8;
/* Image data */
*image_data_size = 0;
for (list = node->image_list; list; list = list->next)
@ -1263,7 +1263,7 @@ write_hash_table (FILE *cache, HashContext *context, int *new_offset)
offset += 4;
node_offset = offset + context->size * 4;
/* Just write zeros here, we will rewrite this later */
/* Just write zeros here, we will rewrite this later */
for (i = 0; i < context->size; i++)
{
if (!write_card32 (cache, 0))
@ -1321,16 +1321,16 @@ write_dir_index (FILE *cache, int offset, GList *directories)
for (d = directories; d; d = d->next)
{
dir = d->data;
tmp2 = find_string (dir);
if (tmp2 == 0 || tmp2 == -1)
{
tmp2 = tmp;
tmp += ALIGN_VALUE (strlen (dir) + 1, 4);
/* We're playing a little game with negative
* offsets here to handle duplicate strings in
* the array, even though that should not
* offsets here to handle duplicate strings in
* the array, even though that should not
* really happen for the directory index.
*/
add_string (dir, -tmp2);
@ -1355,12 +1355,12 @@ write_dir_index (FILE *cache, int offset, GList *directories)
{
tmp2 = -tmp2;
g_assert (tmp2 == ftell (cache));
add_string (dir, tmp2);
add_string (dir, tmp2);
if (!write_string (cache, dir))
return FALSE;
}
}
return TRUE;
}
@ -1375,7 +1375,7 @@ write_file (FILE *cache, GHashTable *files, GList *directories)
*/
context.size = g_spaced_primes_closest (g_hash_table_size (files) / 3);
context.nodes = g_new0 (HashNode *, context.size);
g_hash_table_foreach_remove (files, convert_to_hash, &context);
/* Now write the file */
@ -1398,7 +1398,7 @@ write_file (FILE *cache, GHashTable *files, GList *directories)
g_printerr (_("Failed to write folder index\n"));
return FALSE;
}
rewind (cache);
if (!write_header (cache, new_offset))
@ -1406,7 +1406,7 @@ write_file (FILE *cache, GHashTable *files, GList *directories)
g_printerr (_("Failed to rewrite header\n"));
return FALSE;
}
return TRUE;
}
@ -1425,12 +1425,12 @@ validate_file (const gchar *file)
info.n_directories = 0;
info.flags = CHECK_OFFSETS|CHECK_STRINGS|CHECK_PIXBUFS;
if (!_gtk_icon_cache_validate (&info))
if (!_gtk_icon_cache_validate (&info))
{
g_mapped_file_unref (map);
return FALSE;
}
g_mapped_file_unref (map);
return TRUE;
@ -1508,12 +1508,12 @@ opentmp:
g_printerr (_("Failed to write cache file: %s\n"), g_strerror (errno));
exit (1);
}
files = g_hash_table_new (g_str_hash, g_str_equal);
image_data_hash = g_hash_table_new (g_str_hash, g_str_equal);
icon_data_hash = g_hash_table_new (g_str_hash, g_str_equal);
string_pool = g_hash_table_new (g_str_hash, g_str_equal);
directories = scan_directory (path, NULL, files, NULL, 0);
if (g_hash_table_size (files) == 0)
@ -1525,7 +1525,7 @@ opentmp:
g_unlink (cache_path);
exit (0);
}
/* FIXME: Handle failure */
if (!write_file (cache, files, directories))
{
@ -1624,11 +1624,11 @@ write_csource (const gchar *path)
cache_path = g_build_filename (path, CACHE_NAME, NULL);
if (!g_file_get_contents (cache_path, &data, &len, NULL))
exit (1);
g_printf ("#ifdef __SUNPRO_C\n");
g_printf ("#pragma align 4 (%s)\n", var_name);
g_printf ("#pragma align 4 (%s)\n", var_name);
g_printf ("#endif\n");
g_printf ("#ifdef __GNUC__\n");
g_printf ("static const guint8 %s[] __attribute__ ((__aligned__ (4))) = \n", var_name);
g_printf ("#else\n");
@ -1644,7 +1644,7 @@ write_csource (const gchar *path)
if (i % 12 == 11)
g_printf ("\n");
}
g_printf ("0x%02x\n};\n", (guint8)data[i]);
}
@ -1673,13 +1673,13 @@ printerr_handler (const gchar *string)
gchar *result;
result = g_convert_with_fallback (string, -1, charset, "UTF-8", "?", NULL, NULL, NULL);
if (result)
{
fputs (result, stderr);
g_free (result);
}
fflush (stderr);
}
}
@ -1695,7 +1695,7 @@ main (int argc, char **argv)
return 0;
g_set_printerr_handler (printerr_handler);
setlocale (LC_ALL, "");
#ifdef ENABLE_NLS
@ -1709,12 +1709,12 @@ main (int argc, char **argv)
g_option_context_add_main_entries (context, args, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, NULL);
path = argv[1];
#ifdef G_OS_WIN32
path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL);
#endif
if (validate)
{
gchar *file = g_build_filename (path, CACHE_NAME, NULL);
@ -1731,7 +1731,7 @@ main (int argc, char **argv)
g_printerr (_("Not a valid icon cache: %s\n"), file);
exit (1);
}
else
else
{
exit (0);
}
@ -1751,7 +1751,7 @@ main (int argc, char **argv)
return 1;
}
if (!force_update && is_cache_up_to_date (path))
return 0;