summaryrefslogtreecommitdiff
path: root/pngdebug.h
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2010-03-09 22:28:33 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2010-03-09 22:28:33 -0600
commit632a84eff7a52bcdf60d6c5dbc4f1677f289e34e (patch)
tree687588edbc0bf13b7a53366f43a1ecf7f9304ffb /pngdebug.h
parent31f92b0ffa1f472f049af7a6207867d786004d5a (diff)
downloadlibpng-632a84eff7a52bcdf60d6c5dbc4f1677f289e34e.tar.gz
[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.
Diffstat (limited to 'pngdebug.h')
-rw-r--r--pngdebug.h47
1 files changed, 31 insertions, 16 deletions
diff --git a/pngdebug.h b/pngdebug.h
index 81c598f39..bf23853ac 100644
--- a/pngdebug.h
+++ b/pngdebug.h
@@ -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 */