mirror of https://github.com/GNOME/gimp.git
return the number of bytes that have been read from the file.
2007-07-05 Sven Neumann <sven@gimp.org> * app/xcf/xcf-read.c (xcf_read_int32) (xcf_read_int8): return the number of bytes that have been read from the file. * app/xcf/xcf-load.c (xcf_load_prop): return FALSE when reading fails. svn path=/trunk/; revision=22873
This commit is contained in:
parent
792de8539e
commit
4512af8de1
|
@ -1,3 +1,10 @@
|
|||
2007-07-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/xcf/xcf-read.c (xcf_read_int32) (xcf_read_int8): return the
|
||||
number of bytes that have been read from the file.
|
||||
|
||||
* app/xcf/xcf-load.c (xcf_load_prop): return FALSE when reading fails.
|
||||
|
||||
2007-07-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* tools/pdbgen/pdb.pl (arg_parse): allow the use of constants when
|
||||
|
|
|
@ -297,7 +297,7 @@ xcf_load_image_props (XcfInfo *info,
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
if (!xcf_load_prop (info, &prop_type, &prop_size))
|
||||
if (! xcf_load_prop (info, &prop_type, &prop_size))
|
||||
return FALSE;
|
||||
|
||||
switch (prop_type)
|
||||
|
@ -381,8 +381,10 @@ xcf_load_image_props (XcfInfo *info,
|
|||
nguides = prop_size / (4 + 1);
|
||||
for (i = 0; i < nguides; i++)
|
||||
{
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) &position, 1);
|
||||
info->cp += xcf_read_int8 (info->fp, (guint8 *) &orientation, 1);
|
||||
info->cp += xcf_read_int32 (info->fp,
|
||||
(guint32 *) &position, 1);
|
||||
info->cp += xcf_read_int8 (info->fp,
|
||||
(guint8 *) &orientation, 1);
|
||||
|
||||
/* skip -1 guides from old XCFs */
|
||||
if (position < 0)
|
||||
|
@ -617,7 +619,7 @@ xcf_load_layer_props (XcfInfo *info,
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
if (!xcf_load_prop (info, &prop_type, &prop_size))
|
||||
if (! xcf_load_prop (info, &prop_type, &prop_size))
|
||||
return FALSE;
|
||||
|
||||
switch (prop_type)
|
||||
|
@ -715,6 +717,7 @@ xcf_load_layer_props (XcfInfo *info,
|
|||
gimp_item_parasite_attach (GIMP_ITEM (layer), p);
|
||||
gimp_parasite_free (p);
|
||||
}
|
||||
|
||||
if (info->cp - base != prop_size)
|
||||
gimp_message (info->gimp, G_OBJECT (info->progress),
|
||||
GIMP_MESSAGE_WARNING,
|
||||
|
@ -763,7 +766,7 @@ xcf_load_channel_props (XcfInfo *info,
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
if (!xcf_load_prop (info, &prop_type, &prop_size))
|
||||
if (! xcf_load_prop (info, &prop_type, &prop_size))
|
||||
return FALSE;
|
||||
|
||||
switch (prop_type)
|
||||
|
@ -857,6 +860,7 @@ xcf_load_channel_props (XcfInfo *info,
|
|||
gimp_item_parasite_attach (GIMP_ITEM (*channel), p);
|
||||
gimp_parasite_free (p);
|
||||
}
|
||||
|
||||
if (info->cp - base != prop_size)
|
||||
gimp_message (info->gimp, G_OBJECT (info->progress),
|
||||
GIMP_MESSAGE_WARNING,
|
||||
|
@ -896,8 +900,16 @@ xcf_load_prop (XcfInfo *info,
|
|||
PropType *prop_type,
|
||||
guint32 *prop_size)
|
||||
{
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) prop_type, 1);
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) prop_size, 1);
|
||||
if (G_UNLIKELY (xcf_read_int32 (info->fp, (guint32 *) prop_type, 1) != 4))
|
||||
return FALSE;
|
||||
|
||||
info->cp += 4;
|
||||
|
||||
if (G_UNLIKELY (xcf_read_int32 (info->fp, (guint32 *) prop_size, 1) != 4))
|
||||
return FALSE;
|
||||
|
||||
info->cp += 4;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ xcf_read_int32 (FILE *fp,
|
|||
guint32 *data,
|
||||
gint count)
|
||||
{
|
||||
guint total = count;
|
||||
guint total = 0;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
xcf_read_int8 (fp, (guint8 *) data, count * 4);
|
||||
total += xcf_read_int8 (fp, (guint8 *) data, count * 4);
|
||||
|
||||
while (count--)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ xcf_read_int32 (FILE *fp,
|
|||
}
|
||||
}
|
||||
|
||||
return total * 4;
|
||||
return total;
|
||||
}
|
||||
|
||||
guint
|
||||
|
@ -63,15 +63,17 @@ xcf_read_int8 (FILE *fp,
|
|||
guint8 *data,
|
||||
gint count)
|
||||
{
|
||||
guint total = count;
|
||||
guint total = 0;
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
gint bytes = fread ((char *) data, sizeof (char), count, fp);
|
||||
gint bytes = fread ((char *) data, sizeof (char), count, fp);
|
||||
|
||||
if (bytes <= 0) /* something bad happened */
|
||||
break;
|
||||
|
||||
total += bytes;
|
||||
|
||||
count -= bytes;
|
||||
data += bytes;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue