[devel] Eliminated dependence of pngtest.c on the private pngdebug.h file.
diff --git a/pngtest.c b/pngtest.c
index 0db40a9..f24130a 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -46,7 +46,15 @@
# define PNG_DEBUG 0
#endif
-#include "pngdebug.h"
+#if PNG_DEBUG > 1
+# define pngtest_debug(m) ((void)fprintf(stderr, m "\n"))
+# define pngtest_debug1(m,p1) ((void)fprintf(stderr, m "\n", p1))
+# define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2))
+#else
+# define pngtest_debug(m) ((void)0)
+# define pngtest_debug1(m,p1) ((void)0)
+# define pngtest_debug2(m,p1,p2) ((void)0)
+#endif
#if !PNG_DEBUG
# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */
@@ -508,7 +516,7 @@
/* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size);
if (verbose)
- printf("png_malloc %lu bytes at %x\n", (unsigned long)size,
+ printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
pinfo->pointer);
return (png_voidp)(pinfo->pointer);
}
@@ -558,7 +566,7 @@
/* Finally free the data. */
if (verbose)
- printf("Freeing %x\n", ptr);
+ printf("Freeing %p\n", ptr);
png_free_default(png_ptr, ptr);
ptr = NULL;
}
@@ -678,7 +686,7 @@
return (1);
}
- png_debug(0, "Allocating read and write structures");
+ pngtest_debug("Allocating read and write structures");
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
read_ptr =
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
@@ -716,7 +724,7 @@
pngtest_warning);
#endif
#endif
- png_debug(0, "Allocating read_info, write_info and end_info structures");
+ pngtest_debug("Allocating read_info, write_info and end_info structures");
read_info_ptr = png_create_info_struct(read_ptr);
end_info_ptr = png_create_info_struct(read_ptr);
#ifdef PNG_WRITE_SUPPORTED
@@ -725,7 +733,7 @@
#endif
#ifdef PNG_SETJMP_SUPPORTED
- png_debug(0, "Setting jmpbuf for read struct");
+ pngtest_debug("Setting jmpbuf for read struct");
#ifdef USE_FAR_KEYWORD
if (setjmp(png_jmpbuf))
#else
@@ -749,7 +757,7 @@
#endif
#ifdef PNG_WRITE_SUPPORTED
- png_debug(0, "Setting jmpbuf for write struct");
+ pngtest_debug("Setting jmpbuf for write struct");
#ifdef USE_FAR_KEYWORD
if (setjmp(png_jmpbuf))
#else
@@ -772,7 +780,7 @@
#endif
#endif
- png_debug(0, "Initializing input and output streams");
+ pngtest_debug("Initializing input and output streams");
#ifdef PNG_STDIO_SUPPORTED
png_init_io(read_ptr, fpin);
# ifdef PNG_WRITE_SUPPORTED
@@ -832,10 +840,10 @@
NULL, 0);
#endif
- png_debug(0, "Reading info struct");
+ pngtest_debug("Reading info struct");
png_read_info(read_ptr, read_info_ptr);
- png_debug(0, "Transferring info struct");
+ pngtest_debug("Transferring info struct");
{
int interlace_type, compression_type, filter_type;
@@ -1022,7 +1030,7 @@
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
{
- png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text);
+ pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
}
}
@@ -1092,7 +1100,7 @@
#endif
#ifdef PNG_WRITE_SUPPORTED
- png_debug(0, "Writing info struct");
+ pngtest_debug("Writing info struct");
/* If we wanted, we could write info in two steps:
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
@@ -1135,12 +1143,12 @@
#endif
#ifdef SINGLE_ROWBUF_ALLOC
- png_debug(0, "Allocating row buffer...");
+ pngtest_debug("Allocating row buffer...");
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
- png_debug1(0, "0x%08lx", (unsigned long)row_buf);
+ pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
#endif /* SINGLE_ROWBUF_ALLOC */
- png_debug(0, "Writing row data");
+ pngtest_debug("Writing row data");
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
defined(PNG_WRITE_INTERLACING_SUPPORTED)
@@ -1159,14 +1167,14 @@
#endif
for (pass = 0; pass < num_pass; pass++)
{
- png_debug1(0, "Writing row data for pass %d", pass);
+ pngtest_debug1("Writing row data for pass %d", pass);
for (y = 0; y < height; y++)
{
#ifndef SINGLE_ROWBUF_ALLOC
- png_debug2(0, "Allocating row buffer (pass %d, y = %ld)...", pass, y);
+ pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
- png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf,
+ pngtest_debug2("\t0x%08lx (%u bytes)", (unsigned long)row_buf,
png_get_rowbytes(read_ptr, read_info_ptr));
#endif /* !SINGLE_ROWBUF_ALLOC */
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
@@ -1186,7 +1194,7 @@
#endif /* PNG_WRITE_SUPPORTED */
#ifndef SINGLE_ROWBUF_ALLOC
- png_debug2(0, "Freeing row buffer (pass %d, y = %ld)", pass, y);
+ pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
png_free(read_ptr, row_buf);
row_buf = NULL;
#endif /* !SINGLE_ROWBUF_ALLOC */
@@ -1200,7 +1208,7 @@
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
#endif
- png_debug(0, "Reading and writing end_info data");
+ pngtest_debug("Reading and writing end_info data");
png_read_end(read_ptr, end_info_ptr);
#ifdef PNG_TEXT_SUPPORTED
@@ -1210,7 +1218,7 @@
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
{
- png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text);
+ pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
}
}
@@ -1271,26 +1279,26 @@
}
#endif
- png_debug(0, "Destroying data structs");
+ pngtest_debug("Destroying data structs");
#ifdef SINGLE_ROWBUF_ALLOC
- png_debug(1, "destroying row_buf for read_ptr");
+ pngtest_debug("destroying row_buf for read_ptr");
png_free(read_ptr, row_buf);
row_buf = NULL;
#endif /* SINGLE_ROWBUF_ALLOC */
- png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr");
+ pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr");
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED
- png_debug(1, "destroying write_end_info_ptr");
+ pngtest_debug("destroying write_end_info_ptr");
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
- png_debug(1, "destroying write_ptr, write_info_ptr");
+ pngtest_debug("destroying write_ptr, write_info_ptr");
png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
- png_debug(0, "Destruction complete.");
+ pngtest_debug("Destruction complete.");
FCLOSE(fpin);
FCLOSE(fpout);
- png_debug(0, "Opening files for comparison");
+ pngtest_debug("Opening files for comparison");
if ((fpin = fopen(inname, "rb")) == NULL)
{
fprintf(STDERR, "Could not find file %s\n", inname);