[devel] Make use of whitespace consistent in pngget.c and pngwutil.c

This commit is contained in:
Glenn Randers-Pehrson 2010-03-06 07:34:28 -06:00
parent da30135c4c
commit 16908a1d78
2 changed files with 298 additions and 291 deletions

View File

@ -768,8 +768,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{ {
png_debug1(1, "in %s retrieval function", png_debug1(1, "in %s retrieval function",
(png_ptr->chunk_name[0] == '\0' ? "text" (png_ptr->chunk_name[0] == '\0' ? "text" :
: (png_const_charp)png_ptr->chunk_name)); (png_const_charp)png_ptr->chunk_name));
if (text_ptr != NULL) if (text_ptr != NULL)
*text_ptr = info_ptr->text; *text_ptr = info_ptr->text;
@ -903,8 +903,7 @@ png_get_chunk_cache_max (png_structp png_ptr)
png_alloc_size_t PNGAPI png_alloc_size_t PNGAPI
png_get_chunk_malloc_max (png_structp png_ptr) png_get_chunk_malloc_max (png_structp png_ptr)
{ {
return (png_ptr? return (png_ptr? png_ptr->user_chunk_malloc_max : 0);
png_ptr->user_chunk_malloc_max : 0);
} }
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */

View File

@ -436,8 +436,10 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
case 2: case 2:
case 4: case 4:
case 8: case 8:
case 16: png_ptr->channels = 1; break; case 16:
default: png_error(png_ptr, png_ptr->channels = 1; break;
default:
png_error(png_ptr,
"Invalid bit depth for grayscale image"); "Invalid bit depth for grayscale image");
} }
break; break;
@ -452,8 +454,11 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
case 1: case 1:
case 2: case 2:
case 4: case 4:
case 8: png_ptr->channels = 1; break; case 8:
default: png_error(png_ptr, "Invalid bit depth for paletted image"); png_ptr->channels = 1;
break;
default:
png_error(png_ptr, "Invalid bit depth for paletted image");
} }
break; break;
case PNG_COLOR_TYPE_GRAY_ALPHA: case PNG_COLOR_TYPE_GRAY_ALPHA:
@ -572,11 +577,14 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->zlib_mem_level, png_ptr->zlib_strategy); png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
if (ret != Z_OK) if (ret != Z_OK)
{ {
if (ret == Z_VERSION_ERROR) png_error(png_ptr, if (ret == Z_VERSION_ERROR)
png_error(png_ptr,
"zlib failed to initialize compressor -- version error"); "zlib failed to initialize compressor -- version error");
if (ret == Z_STREAM_ERROR) png_error(png_ptr, if (ret == Z_STREAM_ERROR)
png_error(png_ptr,
"zlib failed to initialize compressor -- stream error"); "zlib failed to initialize compressor -- stream error");
if (ret == Z_MEM_ERROR) png_error(png_ptr, if (ret == Z_MEM_ERROR)
png_error(png_ptr,
"zlib failed to initialize compressor -- mem error"); "zlib failed to initialize compressor -- mem error");
png_error(png_ptr, "zlib failed to initialize compressor"); png_error(png_ptr, "zlib failed to initialize compressor");
} }
@ -1502,7 +1510,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
(png_size_t)(key_len + 1)); (png_size_t)(key_len + 1));
/* Set the compression flag */ /* Set the compression flag */
if (compression == PNG_ITXT_COMPRESSION_NONE || \ if (compression == PNG_ITXT_COMPRESSION_NONE ||
compression == PNG_TEXT_COMPRESSION_NONE) compression == PNG_TEXT_COMPRESSION_NONE)
cbuf[0] = 0; cbuf[0] = 0;
else /* compression == PNG_ITXT_COMPRESSION_zTXt */ else /* compression == PNG_ITXT_COMPRESSION_zTXt */
@ -1573,7 +1581,8 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
(png_alloc_size_t)(nparams * png_sizeof(png_uint_32))); (png_alloc_size_t)(nparams * png_sizeof(png_uint_32)));
/* Find the length of each parameter, making sure we don't count the /* Find the length of each parameter, making sure we don't count the
null terminator for the last parameter. */ * null terminator for the last parameter.
*/
for (i = 0; i < nparams; i++) for (i = 0; i < nparams; i++)
{ {
params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
@ -2061,8 +2070,8 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
dp = row; dp = row;
/* Find out how many bytes each pixel takes up */ /* Find out how many bytes each pixel takes up */
pixel_bytes = (row_info->pixel_depth >> 3); pixel_bytes = (row_info->pixel_depth >> 3);
/* Loop through the row, only looking at the pixels that
matter */ /* Loop through the row, only looking at the pixels that matter */
for (i = png_pass_start[pass]; i < row_width; for (i = png_pass_start[pass]; i < row_width;
i += png_pass_inc[pass]) i += png_pass_inc[pass])
{ {
@ -2154,8 +2163,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
/* We don't need to test the 'no filter' case if this is the only filter /* We don't need to test the 'no filter' case if this is the only filter
* that has been chosen, as it doesn't actually do anything to the data. * that has been chosen, as it doesn't actually do anything to the data.
*/ */
if ((filter_to_do & PNG_FILTER_NONE) && if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE)
filter_to_do != PNG_FILTER_NONE)
{ {
png_bytep rp; png_bytep rp;
png_uint_32 sum = 0; png_uint_32 sum = 0;