mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Clean up some conditional compilation of parts of statements
and fixed some indentation
This commit is contained in:
parent
3a866cb451
commit
daf4b9dd18
10
pngget.c
10
pngget.c
@ -1151,19 +1151,19 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
if (png_ptr->read_struct)
|
if (png_ptr->read_struct)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
return png_ptr->IDAT_read_size;
|
return png_ptr->IDAT_read_size;
|
||||||
#else
|
#else
|
||||||
return PNG_IDAT_READ_SIZE;
|
return PNG_IDAT_READ_SIZE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
else
|
else
|
||||||
return png_ptr->zbuffer_size;
|
return png_ptr->zbuffer_size;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
pngmem.c
15
pngmem.c
@ -81,11 +81,11 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
|||||||
/* Some compilers complain that this is always true. However, it
|
/* Some compilers complain that this is always true. However, it
|
||||||
* can be false when integer overflow happens.
|
* can be false when integer overflow happens.
|
||||||
*/
|
*/
|
||||||
if (size > 0 && size <= PNG_SIZE_MAX
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
# ifdef PNG_MAX_MALLOC_64K
|
if (size > 0 && size <= PNG_SIZE_MAX && size <= 65536U)
|
||||||
&& size <= 65536U
|
#else
|
||||||
# endif
|
if (size > 0 && size <= PNG_SIZE_MAX)
|
||||||
)
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||||
@ -226,8 +226,11 @@ png_free(png_const_structrp png_ptr, png_voidp ptr)
|
|||||||
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||||
|
|
||||||
else
|
else
|
||||||
#endif /* USER_MEM */
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
#else
|
||||||
|
free(ptr);
|
||||||
|
#endif /* USER_MEM */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
61
pngread.c
61
pngread.c
@ -189,7 +189,7 @@ png_read_chunk_header(png_structrp png_ptr)
|
|||||||
static void
|
static void
|
||||||
png_read_sequential_unknown(png_structrp png_ptr, png_inforp info_ptr)
|
png_read_sequential_unknown(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
# ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
/* Read the data for an unknown chunk. The read buffer is used: */
|
/* Read the data for an unknown chunk. The read buffer is used: */
|
||||||
png_bytep buffer = png_read_buffer(png_ptr, png_ptr->chunk_length,
|
png_bytep buffer = png_read_buffer(png_ptr, png_ptr->chunk_length,
|
||||||
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)); /* error if critical */
|
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)); /* error if critical */
|
||||||
@ -202,10 +202,10 @@ png_read_sequential_unknown(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else /* out of memory on an ancillary chunk; skip the chunk */
|
else /* out of memory on an ancillary chunk; skip the chunk */
|
||||||
# else /* !READ_UNKNOWN_CHUNKS */
|
#else /* !READ_UNKNOWN_CHUNKS */
|
||||||
/* or, no support for reading unknown chunks, so just skip it. */
|
/* or, no support for reading unknown chunks, so just skip it. */
|
||||||
PNG_UNUSED(info_ptr)
|
PNG_UNUSED(info_ptr)
|
||||||
# endif /* !READ_UNKNOWN_CHUNKS */
|
#endif /* !READ_UNKNOWN_CHUNKS */
|
||||||
png_crc_finish(png_ptr, png_ptr->chunk_length);
|
png_crc_finish(png_ptr, png_ptr->chunk_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,12 +267,12 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
/* The loop was ended by IDAT or IEND, but if an IEND was seen the read code
|
/* The loop was ended by IDAT or IEND, but if an IEND was seen the read code
|
||||||
* (png_handle_position in pngrutil.c) should have errored out, therefore:
|
* (png_handle_position in pngrutil.c) should have errored out, therefore:
|
||||||
*/
|
*/
|
||||||
# ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
affirm(png_ptr->chunk_name == png_IDAT && ((png_ptr->known_unknown)&1U));
|
affirm(png_ptr->chunk_name == png_IDAT && ((png_ptr->known_unknown)&1U));
|
||||||
# else
|
#else
|
||||||
debug(png_ptr->chunk_name == png_IDAT);
|
debug(png_ptr->chunk_name == png_IDAT);
|
||||||
impossible("unknown IDAT");
|
impossible("unknown IDAT");
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
/* And the code cannot have left it unread; it must have called one of the
|
/* And the code cannot have left it unread; it must have called one of the
|
||||||
* handlers, so we are skipping IDAT.
|
* handlers, so we are skipping IDAT.
|
||||||
@ -431,10 +431,12 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
* parameter to png_combine_row is true, meaning overwrite all the
|
* parameter to png_combine_row is true, meaning overwrite all the
|
||||||
* pixels belong to this and *later* passes.
|
* pixels belong to this and *later* passes.
|
||||||
*/
|
*/
|
||||||
# ifdef PNG_READ_DEINTERLACE_SUPPORTED
|
#ifdef PNG_READ_DEINTERLACE_SUPPORTED
|
||||||
if (!png_ptr->do_interlace)
|
if (!png_ptr->do_interlace)
|
||||||
# endif
|
|
||||||
continue;
|
continue;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
display_row:
|
display_row:
|
||||||
if (dsp_row != NULL)
|
if (dsp_row != NULL)
|
||||||
@ -446,10 +448,12 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
/* row not in pass and no appropriate data; skip this row, nothing
|
/* row not in pass and no appropriate data; skip this row, nothing
|
||||||
* more need be done, except the read_row_fn:
|
* more need be done, except the read_row_fn:
|
||||||
*/
|
*/
|
||||||
# ifdef PNG_READ_DEINTERLACE_SUPPORTED
|
#ifdef PNG_READ_DEINTERLACE_SUPPORTED
|
||||||
if (!png_ptr->do_interlace)
|
if (!png_ptr->do_interlace)
|
||||||
# endif
|
|
||||||
continue;
|
continue;
|
||||||
|
#else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
row_fn:
|
row_fn:
|
||||||
if (png_ptr->read_row_fn != NULL)
|
if (png_ptr->read_row_fn != NULL)
|
||||||
@ -613,7 +617,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
* png_struct::zstream_error if necessary.
|
* png_struct::zstream_error if necessary.
|
||||||
*/
|
*/
|
||||||
# ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
# ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
if (!(png_ptr->known_unknown & 1U))
|
if (!(png_ptr->known_unknown & 1U))
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
if (png_ptr->zowner == png_IDAT)
|
if (png_ptr->zowner == png_IDAT)
|
||||||
@ -667,18 +671,18 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
# ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* IDAT is unknown, the chunk that terminated the loop must be an IDAT
|
/* IDAT is unknown, the chunk that terminated the loop must be an IDAT
|
||||||
* and it has been processed. Get a new chunk header.
|
* and it has been processed. Get a new chunk header.
|
||||||
*/
|
*/
|
||||||
if (png_ptr->chunk_name == png_IDAT)
|
if (png_ptr->chunk_name == png_IDAT)
|
||||||
png_read_chunk_header(png_ptr);
|
png_read_chunk_header(png_ptr);
|
||||||
|
|
||||||
else
|
else
|
||||||
png_app_error(png_ptr,
|
png_app_error(png_ptr,
|
||||||
"Missing call to png_read_info with unknown IDAT");
|
"Missing call to png_read_info with unknown IDAT");
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if ((png_ptr->mode & PNG_HAVE_IEND) == 0) for (;;)
|
if ((png_ptr->mode & PNG_HAVE_IEND) == 0) for (;;)
|
||||||
@ -827,7 +831,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
|
|||||||
static int /* PRIVATE */
|
static int /* PRIVATE */
|
||||||
png_gt(size_t a, size_t b)
|
png_gt(size_t a, size_t b)
|
||||||
{
|
{
|
||||||
return a > b;
|
return a > b;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define png_gt(a,b) ((a) > (b))
|
# define png_gt(a,b) ((a) > (b))
|
||||||
@ -919,11 +923,9 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, int transforms,
|
|||||||
png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported");
|
png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We don't handle background color or gamma transformation or quantizing.
|
/* We don't handle background color, gamma transformation, or quantizing. */
|
||||||
*/
|
|
||||||
|
|
||||||
/* Invert monochrome files to have 0 as white and 1 as black
|
/* Invert monochrome files to have 0 as white and 1 as black */
|
||||||
*/
|
|
||||||
if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
|
if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
|
||||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||||
png_set_invert_mono(png_ptr);
|
png_set_invert_mono(png_ptr);
|
||||||
@ -2912,7 +2914,6 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
default:
|
default:
|
||||||
png_error(png_ptr, "invalid PNG color type");
|
png_error(png_ptr, "invalid PNG color type");
|
||||||
/*NOT REACHED*/
|
/*NOT REACHED*/
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now deal with the output processing */
|
/* Now deal with the output processing */
|
||||||
|
13
pngset.c
13
pngset.c
@ -524,13 +524,14 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((num_palette > 0 && palette == NULL) ||
|
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||||
(num_palette == 0
|
if ((num_palette > 0 && palette == NULL) || (num_palette == 0 &&
|
||||||
# ifdef PNG_MNG_FEATURES_SUPPORTED
|
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0))
|
||||||
&& (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
|
|
||||||
# endif /* MNG_FEATURES */
|
|
||||||
))
|
|
||||||
png_error(png_ptr, "Invalid palette");
|
png_error(png_ptr, "Invalid palette");
|
||||||
|
#else
|
||||||
|
if ((num_palette > 0 && palette == NULL) || (num_palette == 0))
|
||||||
|
png_error(png_ptr, "Invalid palette");
|
||||||
|
#endif /* MNG_FEATURES */
|
||||||
|
|
||||||
/* It may not actually be necessary to set png_ptr->palette here;
|
/* It may not actually be necessary to set png_ptr->palette here;
|
||||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user