[devel] Expand tabs and use consistent whitespace in pngrutil.c
This commit is contained in:
parent
16908a1d78
commit
72cda2db72
94
pngrutil.c
94
pngrutil.c
@ -232,7 +232,8 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
|||||||
if (output != 0 && output_size > count)
|
if (output != 0 && output_size > count)
|
||||||
{
|
{
|
||||||
int copy = output_size - count;
|
int copy = output_size - count;
|
||||||
if (avail < copy) copy = avail;
|
if (avail < copy)
|
||||||
|
copy = avail;
|
||||||
png_memcpy(output + count, png_ptr->zbuf, copy);
|
png_memcpy(output + count, png_ptr->zbuf, copy);
|
||||||
}
|
}
|
||||||
count += avail;
|
count += avail;
|
||||||
@ -284,7 +285,7 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
|||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 0 means an error - notice that this code simple ignores
|
/* 0 means an error - notice that this code simply ignores
|
||||||
* zero length compressed chunks as a result.
|
* zero length compressed chunks as a result.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
@ -316,7 +317,8 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
png_size_t expanded_size = png_inflate(png_ptr,
|
png_size_t expanded_size = png_inflate(png_ptr,
|
||||||
(png_bytep)(png_ptr->chunkdata + prefix_size),
|
(png_bytep)(png_ptr->chunkdata + prefix_size),
|
||||||
chunklength - prefix_size,
|
chunklength - prefix_size,
|
||||||
0/*output*/, 0/*output size*/);
|
0, /*output*/
|
||||||
|
0); /*output size*/
|
||||||
|
|
||||||
/* Now check the limits on this chunk - if the limit fails the
|
/* Now check the limits on this chunk - if the limit fails the
|
||||||
* compressed data will be removed, the prefix will remain.
|
* compressed data will be removed, the prefix will remain.
|
||||||
@ -372,7 +374,8 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
char umsg[50];
|
char umsg[50];
|
||||||
|
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
png_snprintf(umsg, sizeof umsg, "Unknown zTXt compression type %d", comp_type);
|
png_snprintf(umsg, sizeof umsg,
|
||||||
|
"Unknown zTXt compression type %d", comp_type);
|
||||||
png_warning(png_ptr, umsg);
|
png_warning(png_ptr, umsg);
|
||||||
#else
|
#else
|
||||||
png_warning(png_ptr, "Unknown zTXt compression type");
|
png_warning(png_ptr, "Unknown zTXt compression type");
|
||||||
@ -560,7 +563,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If we actually NEED the PLTE chunk (ie for a paletted image), we do
|
/* If we actually need the PLTE chunk (ie for a paletted image), we do
|
||||||
* whatever the normal CRC configuration tells us. However, if we
|
* whatever the normal CRC configuration tells us. However, if we
|
||||||
* have an RGB image, the PLTE can be considered ancillary, so
|
* have an RGB image, the PLTE can be considered ancillary, so
|
||||||
* we will act as though it is.
|
* we will act as though it is.
|
||||||
@ -575,9 +578,10 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
||||||
{
|
{
|
||||||
/* If we don't want to use the data from an ancillary chunk,
|
/* If we don't want to use the data from an ancillary chunk,
|
||||||
we have two options: an error abort, or a warning and we
|
* we have two options: an error abort, or a warning and we
|
||||||
ignore the data in this chunk (which should be OK, since
|
* ignore the data in this chunk (which should be OK, since
|
||||||
it's considered ancillary for a RGB or RGBA image). */
|
* it's considered ancillary for a RGB or RGBA image).
|
||||||
|
*/
|
||||||
if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
|
if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||||
@ -1108,9 +1112,9 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
/* Check the profile_size recorded in the first 32 bits of the ICC profile */
|
/* Check the profile_size recorded in the first 32 bits of the ICC profile */
|
||||||
pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
|
pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
|
||||||
profile_size = ((*(pC ))<<24) |
|
profile_size = ((*(pC )) << 24) |
|
||||||
((*(pC + 1))<<16) |
|
((*(pC + 1)) << 16) |
|
||||||
((*(pC + 2))<< 8) |
|
((*(pC + 2)) << 8) |
|
||||||
((*(pC + 3)) );
|
((*(pC + 3)) );
|
||||||
|
|
||||||
if (profile_size < profile_length)
|
if (profile_size < profile_length)
|
||||||
@ -1224,7 +1228,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_palette.depth = *entry_start++;
|
new_palette.depth = *entry_start++;
|
||||||
entry_size = (new_palette.depth == 8 ? 6 : 10);
|
entry_size = (new_palette.depth == 8? 6 : 10);
|
||||||
data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata));
|
data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata));
|
||||||
|
|
||||||
/* Integrity-check the data length */
|
/* Integrity-check the data length */
|
||||||
@ -1453,7 +1457,8 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
/* We convert the index value into RGB components so that we can allow
|
/* We convert the index value into RGB components so that we can allow
|
||||||
* arbitrary RGB values for background when we have transparency, and
|
* arbitrary RGB values for background when we have transparency, and
|
||||||
* so it is easy to determine the RGB values of the background color
|
* so it is easy to determine the RGB values of the background color
|
||||||
* from the info_ptr struct. */
|
* from the info_ptr struct.
|
||||||
|
*/
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
png_ptr->background.index = buf[0];
|
png_ptr->background.index = buf[0];
|
||||||
@ -1687,7 +1692,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
endptr = png_ptr->chunkdata + slength;
|
endptr = png_ptr->chunkdata + slength;
|
||||||
|
|
||||||
/* We need to have at least 12 bytes after the purpose string
|
/* We need to have at least 12 bytes after the purpose string
|
||||||
in order to get the parameter information. */
|
* in order to get the parameter information.
|
||||||
|
*/
|
||||||
if (endptr <= buf + 12)
|
if (endptr <= buf + 12)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Invalid pCAL data");
|
png_warning(png_ptr, "Invalid pCAL data");
|
||||||
@ -1705,7 +1711,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
png_debug(3, "Checking pCAL equation type and number of parameters");
|
png_debug(3, "Checking pCAL equation type and number of parameters");
|
||||||
/* Check that we have the right number of parameters for known
|
/* Check that we have the right number of parameters for known
|
||||||
equation types. */
|
* equation types.
|
||||||
|
*/
|
||||||
if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||
|
if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||
|
||||||
(type == PNG_EQUATION_BASE_E && nparams != 3) ||
|
(type == PNG_EQUATION_BASE_E && nparams != 3) ||
|
||||||
(type == PNG_EQUATION_ARBITRARY && nparams != 3) ||
|
(type == PNG_EQUATION_ARBITRARY && nparams != 3) ||
|
||||||
@ -2091,7 +2098,8 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
/* We will no doubt have problems with chunks even half this size, but
|
/* We will no doubt have problems with chunks even half this size, but
|
||||||
there is no hard and fast rule to tell us where to stop. */
|
* there is no hard and fast rule to tell us where to stop.
|
||||||
|
*/
|
||||||
if (length > (png_uint_32)65535L)
|
if (length > (png_uint_32)65535L)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
|
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
|
||||||
@ -2212,7 +2220,8 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
/* We will no doubt have problems with chunks even half this size, but
|
/* We will no doubt have problems with chunks even half this size, but
|
||||||
there is no hard and fast rule to tell us where to stop. */
|
* there is no hard and fast rule to tell us where to stop.
|
||||||
|
*/
|
||||||
if (length > (png_uint_32)65535L)
|
if (length > (png_uint_32)65535L)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
|
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
|
||||||
@ -2320,10 +2329,11 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is called when we haven't found a handler for a
|
/* This function is called when we haven't found a handler for a
|
||||||
chunk. If there isn't a problem with the chunk itself (ie bad
|
* chunk. If there isn't a problem with the chunk itself (ie bad
|
||||||
chunk name, CRC, or a critical chunk), the chunk is silently ignored
|
* chunk name, CRC, or a critical chunk), the chunk is silently ignored
|
||||||
-- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
|
* -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
|
||||||
case it will be saved away to be written out later. */
|
* case it will be saved away to be written out later.
|
||||||
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||||
{
|
{
|
||||||
@ -2435,10 +2445,11 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called to verify that a chunk name is valid.
|
/* This function is called to verify that a chunk name is valid.
|
||||||
This function can't have the "critical chunk check" incorporated
|
* This function can't have the "critical chunk check" incorporated
|
||||||
into it, since in the future we will need to be able to call user
|
* into it, since in the future we will need to be able to call user
|
||||||
functions to handle unknown critical chunks after we check that
|
* functions to handle unknown critical chunks after we check that
|
||||||
the chunk name itself is valid. */
|
* the chunk name itself is valid.
|
||||||
|
*/
|
||||||
|
|
||||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||||
|
|
||||||
@ -2454,15 +2465,16 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Combines the row recently read in with the existing pixels in the
|
/* Combines the row recently read in with the existing pixels in the
|
||||||
row. This routine takes care of alpha and transparency if requested.
|
* row. This routine takes care of alpha and transparency if requested.
|
||||||
This routine also handles the two methods of progressive display
|
* This routine also handles the two methods of progressive display
|
||||||
of interlaced images, depending on the mask value.
|
* of interlaced images, depending on the mask value.
|
||||||
The mask value describes which pixels are to be combined with
|
* The mask value describes which pixels are to be combined with
|
||||||
the row. The pattern always repeats every 8 pixels, so just 8
|
* the row. The pattern always repeats every 8 pixels, so just 8
|
||||||
bits are needed. A one indicates the pixel is to be combined,
|
* bits are needed. A one indicates the pixel is to be combined,
|
||||||
a zero indicates the pixel is to be skipped. This is in addition
|
* a zero indicates the pixel is to be skipped. This is in addition
|
||||||
to any alpha or transparency value associated with the pixel. If
|
* to any alpha or transparency value associated with the pixel. If
|
||||||
you want all pixels to be combined, pass 0xff (255) in mask. */
|
* you want all pixels to be combined, pass 0xff (255) in mask.
|
||||||
|
*/
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
||||||
@ -2666,10 +2678,6 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
/* OLD pre-1.0.9 interface:
|
|
||||||
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|
||||||
png_uint_32 transformations)
|
|
||||||
*/
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_read_interlace(png_structp png_ptr)
|
png_do_read_interlace(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
@ -2986,9 +2994,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
|||||||
pb = abs(pc);
|
pb = abs(pc);
|
||||||
pc = abs(p + pc);
|
pc = abs(p + pc);
|
||||||
#else
|
#else
|
||||||
pa = p < 0 ? -p : p;
|
pa = p < 0? -p : p;
|
||||||
pb = pc < 0 ? -pc : pc;
|
pb = pc < 0? -pc : pc;
|
||||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
pc = (p + pc) < 0? -(p + pc) : p + pc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3000,7 +3008,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
|||||||
p = c;
|
p = c;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;
|
p = (pa <= pb && pa <= pc)? a : (pb <= pc) ? b : c;
|
||||||
|
|
||||||
*rp = (png_byte)(((int)(*rp) + p) & 0xff);
|
*rp = (png_byte)(((int)(*rp) + p) & 0xff);
|
||||||
rp++;
|
rp++;
|
||||||
@ -3117,7 +3125,7 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret != Z_OK)
|
if (ret != Z_OK)
|
||||||
png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
|
png_error(png_ptr, png_ptr->zstream.msg? png_ptr->zstream.msg :
|
||||||
"Decompression Error");
|
"Decompression Error");
|
||||||
|
|
||||||
if (!(png_ptr->zstream.avail_out))
|
if (!(png_ptr->zstream.avail_out))
|
||||||
|
Loading…
Reference in New Issue
Block a user