[devel] Make all png_debug macros into *unterminated* statements

or expressions (i.e. a trailing ';' must always be added) and correct
the format statements in various png_debug messages.
This commit is contained in:
Glenn Randers-Pehrson 2010-03-09 22:28:33 -06:00
parent 31f92b0ffa
commit 632a84eff7
5 changed files with 56 additions and 35 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.0beta13 - March 9, 2010
Libpng 1.5.0beta13 - March 10, 2010
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@ -84,7 +84,7 @@ version 1.5.0beta12 [March 9, 2010]
and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler).
Created new pngdebug.h and moved debug definitions there.
version 1.5.0beta13 [March 9, 2010]
version 1.5.0beta13 [March 10, 2010]
Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice.
Revise the "#ifdef" blocks in png_inflate() so it will compile when neither
PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
@ -93,6 +93,9 @@ version 1.5.0beta13 [March 9, 2010]
Moved the 'config.h' support from pngconf.h to pngpriv.h
Removed PNGAPI from the png_longjmp_ptr typedef.
Eliminated dependence of pngtest.c on the private pngdebug.h file.
Make all png_debug macros into *unterminated* statements or
expressions (i.e. a trailing ';' must always be added) and correct
the format statements in various png_debug messages.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -2561,7 +2561,7 @@ version 1.5.0beta12 [March 9, 2010]
and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler).
Created new pngdebug.h and moved debug definitions there.
version 1.5.0beta13 [March 9, 2010]
version 1.5.0beta13 [March 10, 2010]
Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice.
Revise the "#ifdef" blocks in png_inflate() so it will compile when neither
PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
@ -2570,6 +2570,9 @@ version 1.5.0beta13 [March 9, 2010]
Moved the 'config.h' support from pngconf.h to pngpriv.h
Removed PNGAPI from the png_longjmp_ptr typedef.
Eliminated dependence of pngtest.c on the private pngdebug.h file.
Make all png_debug macros into *unterminated* statements or
expressions (i.e. a trailing ';' must always be added) and correct
the format statements in various png_debug messages.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -5,7 +5,7 @@
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng version 1.5.0 - March 9, 2010
* Last changed in libpng version 1.5.0 - March 10, 2010
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -16,6 +16,21 @@
* numbers for PNG_DEBUG mean more debugging information. This has
* only been added since version 0.95 so it is not implemented throughout
* libpng yet, but more support will be added as needed.
*
* png_debug[1-2]?(level, message ,arg{0-2})
* Expands to a statement (either a simple expression or a compound
* do..while(0) statement) that outputs a message with parameter
* substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG
* is undefined, 0 or 1 every png_debug expands to a simple expression
* (actually ((void)0)).
*
* level: level of detail of message, starting at 0. A level 'n'
* message is preceded by 'n' tab characters (not implemented
* on Microsoft compilers unless PNG_DEBUG_FILE is also
* defined, to allow debug DLL compilation with no standard IO).
* message: a printf(3) style text string. A trailing '\n' is added
* to the message.
* arg: 0 to 2 arguments for printf(3) style substitution in message.
*/
#ifndef PNGDEBUG_H
#define PNGDEBUG_H
@ -50,61 +65,61 @@
# ifdef __STDC__
# ifndef png_debug
# define png_debug(l,m) \
{ \
do { \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
}
} while (0)
# endif
# ifndef png_debug1
# define png_debug1(l,m,p1) \
{ \
do { \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
}
} while (0)
# endif
# ifndef png_debug2
# define png_debug2(l,m,p1,p2) \
{ \
do { \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
}
} while (0)
# endif
# else /* __STDC __ */
# ifndef png_debug
# define png_debug(l,m) \
{ \
do { \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format); \
}
} while (0)
# endif
# ifndef png_debug1
# define png_debug1(l,m,p1) \
{ \
do { \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format,p1); \
}
} while (0)
# endif
# ifndef png_debug2
# define png_debug2(l,m,p1,p2) \
{ \
do { \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format,p1,p2); \
}
} while (0)
# endif
# endif /* __STDC __ */
# endif /* (PNG_DEBUG > 1) */
@ -113,12 +128,12 @@
# endif /* (PNG_DEBUG > 0) */
#endif /* PNG_DEBUG */
#ifndef png_debug
# define png_debug(l, m)
# define png_debug(l, m) ((void)0)
#endif
#ifndef png_debug1
# define png_debug1(l, m, p1)
# define png_debug1(l, m, p1) ((void)0)
#endif
#ifndef png_debug2
# define png_debug2(l, m, p1, p2)
# define png_debug2(l, m, p1, p2) ((void)0)
#endif
#endif /* PNGDEBUG_H */

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.4.1 [March 9, 2010]
* Last changed in libpng 1.4.1 [March 10, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -89,7 +89,7 @@ png_read_chunk_header(png_structp png_ptr)
/* Put the chunk name into png_ptr->chunk_name */
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
png_debug2(0, "Reading %s chunk, length = %lu",
png_debug2(0, "Reading %s chunk, length = %u",
png_ptr->chunk_name, length);
/* Reset the crc and run it over the chunk name */
@ -481,7 +481,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
png_debug1(3, "channels = %d", png_ptr->channels);
png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes);
png_debug1(3, "rowbytes = %u", png_ptr->rowbytes);
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
}
@ -1669,7 +1669,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)",
png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)",
length + 1);
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
@ -1809,7 +1809,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)",
png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
length + 1);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
@ -2909,7 +2909,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
{
png_debug(1, "in png_read_filter_row");
png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter);
png_debug2(2, "row = %u, filter = %d", png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
@ -3357,12 +3357,12 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %lu,", png_ptr->width);
png_debug1(3, "height = %lu,", png_ptr->height);
png_debug1(3, "iwidth = %lu,", png_ptr->iwidth);
png_debug1(3, "num_rows = %lu,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu",
png_debug1(3, "width = %u,", png_ptr->width);
png_debug1(3, "height = %u,", png_ptr->height);
png_debug1(3, "iwidth = %u,", png_ptr->iwidth);
png_debug1(3, "num_rows = %u,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %u,", png_ptr->rowbytes);
png_debug1(3, "irowbytes = %u",
PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
png_ptr->flags |= PNG_FLAG_ROW_INIT;

View File

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.5.0 [March 9, 2010]
* Last changed in libpng 1.5.0 [March 10, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -659,7 +659,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %ld, pass %d)",
png_debug2(1, "in png_write_row (row %u, pass %d)",
png_ptr->row_number, png_ptr->pass);
/* Initialize transformations and other stuff if first time */
@ -776,11 +776,11 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_ptr->row_info.width);
png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width);
png_debug1(3, "row_info->width = %u", png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %lu", png_ptr->row_info.rowbytes);
png_debug1(3, "row_info->rowbytes = %u", png_ptr->row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);