Commit 5c252e32 authored by Sven Neumann's avatar Sven Neumann

app: move duplicated code into a helper function

parent dbba8920
......@@ -115,6 +115,9 @@ static gboolean xcf_load_vectors (XcfInfo *info,
static gboolean xcf_load_vector (XcfInfo *info,
GimpImage *image);
static gboolean xcf_skip_unknown_prop (XcfInfo *info,
gsize size);
#define xcf_progress_update(info) G_STMT_START \
{ \
......@@ -661,21 +664,8 @@ xcf_load_image_props (XcfInfo *info,
g_printerr ("unexpected/unknown image property: %d (skipping)\n",
prop_type);
#endif
{
gsize size = prop_size;
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
}
if (! xcf_skip_unknown_prop (info, prop_size))
return FALSE;
break;
}
}
......@@ -873,21 +863,8 @@ xcf_load_layer_props (XcfInfo *info,
g_printerr ("unexpected/unknown layer property: %d (skipping)\n",
prop_type);
#endif
{
gsize size = prop_size;
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
}
if (! xcf_skip_unknown_prop (info, prop_size))
return FALSE;
break;
}
}
......@@ -1031,21 +1008,8 @@ xcf_load_channel_props (XcfInfo *info,
g_printerr ("unexpected/unknown channel property: %d (skipping)\n",
prop_type);
#endif
{
gsize size = prop_size;
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
}
if (! xcf_skip_unknown_prop (info, prop_size))
return FALSE;
break;
}
}
......@@ -1982,3 +1946,23 @@ xcf_load_vector (XcfInfo *info,
return TRUE;
}
static gboolean
xcf_skip_unknown_prop (XcfInfo *info,
gsize size)
{
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
return TRUE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment