[devel] Eliminated dependence of pngtest.c on the private pngdebug.h file.
This commit is contained in:
parent
f70645c592
commit
31f92b0ffa
1
ANNOUNCE
1
ANNOUNCE
@ -92,6 +92,7 @@ version 1.5.0beta13 [March 9, 2010]
|
|||||||
Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3
|
Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3
|
||||||
Moved the 'config.h' support from pngconf.h to pngpriv.h
|
Moved the 'config.h' support from pngconf.h to pngpriv.h
|
||||||
Removed PNGAPI from the png_longjmp_ptr typedef.
|
Removed PNGAPI from the png_longjmp_ptr typedef.
|
||||||
|
Eliminated dependence of pngtest.c on the private pngdebug.h file.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
3
CHANGES
3
CHANGES
@ -2567,6 +2567,9 @@ version 1.5.0beta13 [March 9, 2010]
|
|||||||
PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||||
is defined.
|
is defined.
|
||||||
Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3
|
Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3
|
||||||
|
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.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
64
pngtest.c
64
pngtest.c
@ -46,7 +46,15 @@
|
|||||||
# define PNG_DEBUG 0
|
# define PNG_DEBUG 0
|
||||||
#endif
|
#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
|
#if !PNG_DEBUG
|
||||||
# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */
|
# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */
|
||||||
@ -508,7 +516,7 @@ png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
|||||||
/* Make sure the caller isn't assuming zeroed memory. */
|
/* Make sure the caller isn't assuming zeroed memory. */
|
||||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||||
if (verbose)
|
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);
|
pinfo->pointer);
|
||||||
return (png_voidp)(pinfo->pointer);
|
return (png_voidp)(pinfo->pointer);
|
||||||
}
|
}
|
||||||
@ -558,7 +566,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
|||||||
|
|
||||||
/* Finally free the data. */
|
/* Finally free the data. */
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("Freeing %x\n", ptr);
|
printf("Freeing %p\n", ptr);
|
||||||
png_free_default(png_ptr, ptr);
|
png_free_default(png_ptr, ptr);
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
}
|
}
|
||||||
@ -678,7 +686,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
return (1);
|
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
|
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||||
read_ptr =
|
read_ptr =
|
||||||
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
|
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
|
||||||
@ -716,7 +724,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
pngtest_warning);
|
pngtest_warning);
|
||||||
#endif
|
#endif
|
||||||
#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);
|
read_info_ptr = png_create_info_struct(read_ptr);
|
||||||
end_info_ptr = png_create_info_struct(read_ptr);
|
end_info_ptr = png_create_info_struct(read_ptr);
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
@ -725,7 +733,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
png_debug(0, "Setting jmpbuf for read struct");
|
pngtest_debug("Setting jmpbuf for read struct");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(png_jmpbuf))
|
if (setjmp(png_jmpbuf))
|
||||||
#else
|
#else
|
||||||
@ -749,7 +757,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_debug(0, "Setting jmpbuf for write struct");
|
pngtest_debug("Setting jmpbuf for write struct");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(png_jmpbuf))
|
if (setjmp(png_jmpbuf))
|
||||||
#else
|
#else
|
||||||
@ -772,7 +780,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Initializing input and output streams");
|
pngtest_debug("Initializing input and output streams");
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
png_init_io(read_ptr, fpin);
|
png_init_io(read_ptr, fpin);
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
@ -832,10 +840,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
NULL, 0);
|
NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Reading info struct");
|
pngtest_debug("Reading info struct");
|
||||||
png_read_info(read_ptr, read_info_ptr);
|
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;
|
int interlace_type, compression_type, filter_type;
|
||||||
|
|
||||||
@ -1022,7 +1030,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
|
|
||||||
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
|
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);
|
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1092,7 +1100,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#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:
|
/* If we wanted, we could write info in two steps:
|
||||||
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||||
@ -1135,12 +1143,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SINGLE_ROWBUF_ALLOC
|
#ifdef SINGLE_ROWBUF_ALLOC
|
||||||
png_debug(0, "Allocating row buffer...");
|
pngtest_debug("Allocating row buffer...");
|
||||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||||
png_get_rowbytes(read_ptr, read_info_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 */
|
#endif /* SINGLE_ROWBUF_ALLOC */
|
||||||
png_debug(0, "Writing row data");
|
pngtest_debug("Writing row data");
|
||||||
|
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
@ -1159,14 +1167,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
for (pass = 0; pass < num_pass; pass++)
|
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++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
#ifndef SINGLE_ROWBUF_ALLOC
|
#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,
|
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||||
png_get_rowbytes(read_ptr, read_info_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));
|
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
|
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
|
||||||
@ -1186,7 +1194,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif /* PNG_WRITE_SUPPORTED */
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|
||||||
#ifndef SINGLE_ROWBUF_ALLOC
|
#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);
|
png_free(read_ptr, row_buf);
|
||||||
row_buf = NULL;
|
row_buf = NULL;
|
||||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||||
@ -1200,7 +1208,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
||||||
#endif
|
#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);
|
png_read_end(read_ptr, end_info_ptr);
|
||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
@ -1210,7 +1218,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
|
|
||||||
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
|
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);
|
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1271,26 +1279,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Destroying data structs");
|
pngtest_debug("Destroying data structs");
|
||||||
#ifdef SINGLE_ROWBUF_ALLOC
|
#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);
|
png_free(read_ptr, row_buf);
|
||||||
row_buf = NULL;
|
row_buf = NULL;
|
||||||
#endif /* SINGLE_ROWBUF_ALLOC */
|
#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);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#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_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);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
#endif
|
#endif
|
||||||
png_debug(0, "Destruction complete.");
|
pngtest_debug("Destruction complete.");
|
||||||
|
|
||||||
FCLOSE(fpin);
|
FCLOSE(fpin);
|
||||||
FCLOSE(fpout);
|
FCLOSE(fpout);
|
||||||
|
|
||||||
png_debug(0, "Opening files for comparison");
|
pngtest_debug("Opening files for comparison");
|
||||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "Could not find file %s\n", inname);
|
fprintf(STDERR, "Could not find file %s\n", inname);
|
||||||
|
Loading…
Reference in New Issue
Block a user