[devel] Adjusted some whitespace in pngset.c

This commit is contained in:
Glenn Randers-Pehrson 2010-10-23 08:48:51 -05:00
parent c508081afc
commit 62333ba0cb

View File

@ -47,10 +47,10 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
#ifdef PNG_CHECK_cHRM_SUPPORTED # ifdef PNG_CHECK_cHRM_SUPPORTED
if (png_check_cHRM_fixed(png_ptr, if (png_check_cHRM_fixed(png_ptr,
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
#endif # endif
{ {
info_ptr->x_white = white_x; info_ptr->x_white = white_x;
info_ptr->y_white = white_y; info_ptr->y_white = white_y;
@ -64,7 +64,7 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
} }
} }
#ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
void PNGAPI void PNGAPI
png_set_cHRM(png_structp png_ptr, png_infop info_ptr, png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double white_x, double white_y, double red_x, double red_y, double white_x, double white_y, double red_x, double red_y,
@ -80,7 +80,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
png_fixed(png_ptr, blue_x, "cHRM Blue X"), png_fixed(png_ptr, blue_x, "cHRM Blue X"),
png_fixed(png_ptr, blue_y, "cHRM Blue Y")); png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
} }
#endif /* PNG_FLOATING_POINT_SUPPORTED */ # endif /* PNG_FLOATING_POINT_SUPPORTED */
#endif /* PNG_cHRM_SUPPORTED */ #endif /* PNG_cHRM_SUPPORTED */
@ -111,14 +111,14 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
} }
} }
#ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
void PNGAPI void PNGAPI
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{ {
png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma,
"png_set_gAMA")); "png_set_gAMA"));
} }
#endif # endif
#endif #endif
#ifdef PNG_hIST_SUPPORTED #ifdef PNG_hIST_SUPPORTED
@ -142,11 +142,13 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
} }
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
/* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
* version 1.2.1 * version 1.2.1
*/ */
png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)); PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16));
if (png_ptr->hist == NULL) if (png_ptr->hist == NULL)
{ {
png_warning(png_ptr, "Insufficient memory for hIST chunk data"); png_warning(png_ptr, "Insufficient memory for hIST chunk data");
@ -158,7 +160,6 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
info_ptr->hist = png_ptr->hist; info_ptr->hist = png_ptr->hist;
info_ptr->valid |= PNG_INFO_hIST; info_ptr->valid |= PNG_INFO_hIST;
info_ptr->free_me |= PNG_FREE_HIST; info_ptr->free_me |= PNG_FREE_HIST;
} }
#endif #endif
@ -201,8 +202,8 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
/* Check for potential overflow */ /* Check for potential overflow */
if (width > (PNG_UINT_32_MAX if (width >
>> 3) /* 8-byte RRGGBBAA pixels */ (PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */
- 48 /* bigrowbuf hack */ - 48 /* bigrowbuf hack */
- 1 /* filter byte */ - 1 /* filter byte */
- 7*8 /* rounding of width to multiple of 8 pixels */ - 7*8 /* rounding of width to multiple of 8 pixels */
@ -259,6 +260,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_error(png_ptr, "Invalid format for pCAL parameter"); png_error(png_ptr, "Invalid format for pCAL parameter");
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_purpose == NULL) if (info_ptr->pcal_purpose == NULL)
{ {
png_warning(png_ptr, "Insufficient memory for pCAL purpose"); png_warning(png_ptr, "Insufficient memory for pCAL purpose");
@ -278,11 +280,13 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
(unsigned long)length); (unsigned long)length);
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_units == NULL) if (info_ptr->pcal_units == NULL)
{ {
png_warning(png_ptr, "Insufficient memory for pCAL units"); png_warning(png_ptr, "Insufficient memory for pCAL units");
return; return;
} }
png_memcpy(info_ptr->pcal_units, units, length); png_memcpy(info_ptr->pcal_units, units, length);
info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
@ -381,7 +385,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
info_ptr->free_me |= PNG_FREE_SCAL; info_ptr->free_me |= PNG_FREE_SCAL;
} }
#ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
void PNGAPI void PNGAPI
png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,
double height) double height)
@ -391,8 +395,10 @@ png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,
/* Check the arguments. */ /* Check the arguments. */
if (width <= 0) if (width <= 0)
png_warning(png_ptr, "Invalid sCAL width ignored"); png_warning(png_ptr, "Invalid sCAL width ignored");
else if (height <= 0) else if (height <= 0)
png_warning(png_ptr, "Invalid sCAL height ignored"); png_warning(png_ptr, "Invalid sCAL height ignored");
else else
{ {
/* Convert 'width' and 'height' to ASCII. */ /* Convert 'width' and 'height' to ASCII. */
@ -407,9 +413,9 @@ png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,
png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
} }
} }
#endif # endif
#ifdef PNG_FIXED_POINT_SUPPORTED # ifdef PNG_FIXED_POINT_SUPPORTED
void PNGAPI void PNGAPI
png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit, png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,
png_fixed_point width, png_fixed_point height) png_fixed_point width, png_fixed_point height)
@ -419,8 +425,10 @@ png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,
/* Check the arguments. */ /* Check the arguments. */
if (width <= 0) if (width <= 0)
png_warning(png_ptr, "Invalid sCAL width ignored"); png_warning(png_ptr, "Invalid sCAL width ignored");
else if (height <= 0) else if (height <= 0)
png_warning(png_ptr, "Invalid sCAL height ignored"); png_warning(png_ptr, "Invalid sCAL height ignored");
else else
{ {
/* Convert 'width' and 'height' to ASCII. */ /* Convert 'width' and 'height' to ASCII. */
@ -433,7 +441,7 @@ png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,
png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
} }
} }
#endif # endif
#endif #endif
#ifdef PNG_pHYs_SUPPORTED #ifdef PNG_pHYs_SUPPORTED
@ -536,11 +544,11 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
png_set_sRGB(png_ptr, info_ptr, intent); png_set_sRGB(png_ptr, info_ptr, intent);
#ifdef PNG_gAMA_SUPPORTED # ifdef PNG_gAMA_SUPPORTED
png_set_gAMA_fixed(png_ptr, info_ptr, 45455L); png_set_gAMA_fixed(png_ptr, info_ptr, 45455L);
#endif # endif
#ifdef PNG_cHRM_SUPPORTED # ifdef PNG_cHRM_SUPPORTED
png_set_cHRM_fixed(png_ptr, info_ptr, png_set_cHRM_fixed(png_ptr, info_ptr,
/* color x y */ /* color x y */
/* white */ 31270L, 32900L, /* white */ 31270L, 32900L,
@ -548,7 +556,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
/* green */ 30000L, 60000L, /* green */ 30000L, 60000L,
/* blue */ 15000L, 6000L /* blue */ 15000L, 6000L
); );
#endif /* cHRM */ # endif /* cHRM */
} }
#endif /* sRGB */ #endif /* sRGB */
@ -570,11 +578,13 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(name)+1; length = png_strlen(name)+1;
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length); new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
if (new_iccp_name == NULL) if (new_iccp_name == NULL)
{ {
png_warning(png_ptr, "Insufficient memory to process iCCP chunk"); png_warning(png_ptr, "Insufficient memory to process iCCP chunk");
return; return;
} }
png_memcpy(new_iccp_name, name, length); png_memcpy(new_iccp_name, name, length);
new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen); new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen);
@ -693,7 +703,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
} }
else else
#ifdef PNG_iTXt_SUPPORTED # ifdef PNG_iTXt_SUPPORTED
{ {
/* Set iTXt data */ /* Set iTXt data */
@ -709,22 +719,22 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
else else
lang_key_len = 0; lang_key_len = 0;
} }
#else /* PNG_iTXt_SUPPORTED */ # else /* PNG_iTXt_SUPPORTED */
{ {
png_warning(png_ptr, "iTXt chunk not supported"); png_warning(png_ptr, "iTXt chunk not supported");
continue; continue;
} }
#endif # endif
if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
{ {
text_length = 0; text_length = 0;
#ifdef PNG_iTXt_SUPPORTED # ifdef PNG_iTXt_SUPPORTED
if (text_ptr[i].compression > 0) if (text_ptr[i].compression > 0)
textp->compression = PNG_ITXT_COMPRESSION_NONE; textp->compression = PNG_ITXT_COMPRESSION_NONE;
else else
#endif # endif
textp->compression = PNG_TEXT_COMPRESSION_NONE; textp->compression = PNG_TEXT_COMPRESSION_NONE;
} }
@ -773,7 +783,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
*(textp->text + text_length) = '\0'; *(textp->text + text_length) = '\0';
#ifdef PNG_iTXt_SUPPORTED # ifdef PNG_iTXt_SUPPORTED
if (textp->compression > 0) if (textp->compression > 0)
{ {
textp->text_length = 0; textp->text_length = 0;
@ -781,7 +791,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
} }
else else
#endif # endif
{ {
textp->text_length = text_length; textp->text_length = text_length;
textp->itxt_length = 0; textp->itxt_length = 0;
@ -874,6 +884,7 @@ png_set_sPLT(png_structp png_ptr,
* entries - array of png_sPLT_t structures * entries - array of png_sPLT_t structures
* to be added to the list of palettes * to be added to the list of palettes
* in the info structure. * in the info structure.
*
* nentries - number of palette structures to be * nentries - number of palette structures to be
* added. * added.
*/ */
@ -980,6 +991,7 @@ png_set_unknown_chunks(png_structp png_ptr,
png_memcpy(to->name, from->name, png_sizeof(from->name)); png_memcpy(to->name, from->name, png_sizeof(from->name));
to->name[png_sizeof(to->name)-1] = '\0'; to->name[png_sizeof(to->name)-1] = '\0';
to->size = from->size; to->size = from->size;
/* Note our location in the read or write sequence */ /* Note our location in the read or write sequence */
to->location = (png_byte)(png_ptr->mode & 0xff); to->location = (png_byte)(png_ptr->mode & 0xff);
@ -1061,12 +1073,13 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep
return; return;
} }
if (chunk_list == NULL) if (chunk_list == NULL)
return; return;
old_num_chunks = png_ptr->num_chunk_list; old_num_chunks = png_ptr->num_chunk_list;
new_list=(png_bytep)png_malloc(png_ptr, new_list=(png_bytep)png_malloc(png_ptr,
(png_size_t) (png_size_t)(5*(num_chunks + old_num_chunks)));
(5*(num_chunks + old_num_chunks)));
if (png_ptr->chunk_list != NULL) if (png_ptr->chunk_list != NULL)
{ {
@ -1129,16 +1142,19 @@ png_set_compression_buffer_size(png_structp png_ptr, png_size_t size)
return; return;
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
if (size > ZLIB_IO_MAX) if (size > ZLIB_IO_MAX)
{ {
png_warning(png_ptr, "Attempt to set buffer size beyond max ignored"); png_warning(png_ptr, "Attempt to set buffer size beyond max ignored");
png_ptr->zbuf_size = ZLIB_IO_MAX; png_ptr->zbuf_size = ZLIB_IO_MAX;
size = ZLIB_IO_MAX; /* must fit */ size = ZLIB_IO_MAX; /* must fit */
} }
else else
png_ptr->zbuf_size = (uInt)size; png_ptr->zbuf_size = (uInt)size;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
/* The following ensures a relatively safe failure if this gets called while /* The following ensures a relatively safe failure if this gets called while
* the buffer is actually in use. * the buffer is actually in use.
*/ */