[devel] Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr

in pngtest.c
This commit is contained in:
Glenn Randers-Pehrson 2010-01-01 18:31:26 -06:00
parent a58818a079
commit a0e0c6c8e7
3 changed files with 33 additions and 17 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.4.0rc07 - January 1, 2010 Libpng 1.4.0rc08 - January 2, 2010
This is not intended to be a public release. It will be replaced 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. within a few weeks by a public version or by another test version.
@ -9,20 +9,20 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a Source files with LF line endings (for Unix/Linux) and with a
"configure" script "configure" script
1.4.0rc07.tar.xz (LZMA-compressed, recommended) 1.4.0rc08.tar.xz (LZMA-compressed, recommended)
1.4.0rc07.tar.gz 1.4.0rc08.tar.gz
1.4.0rc07.tar.bz2 1.4.0rc08.tar.bz2
Source files with CRLF line endings (for Windows), without the Source files with CRLF line endings (for Windows), without the
"configure" script "configure" script
lp140r07.zip lp140r08.zip
lp140r07.7z lp140r08.7z
Other information: Other information:
1.4.0rc07-README.txt 1.4.0rc08-README.txt
1.4.0rc07-LICENSE.txt 1.4.0rc08-LICENSE.txt
Changes since the last public release (1.2.10): Changes since the last public release (1.2.10):
@ -764,7 +764,11 @@ version 1.4.0rc07 [January 1, 2010]
Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c
Update copyright year to 2010. Update copyright year to 2010.
version 1.4.0 [January 1, 2010] version 1.4.0rc08 [January 2, 2010]
Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr
in pngtest.c
version 1.4.0 [January 2, 2010]
No changes. No changes.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net

View File

@ -2451,7 +2451,11 @@ version 1.4.0rc07 [January 1, 2010]
Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c
Update copyright year to 2010. Update copyright year to 2010.
version 1.4.0 [January 1, 2010] version 1.4.0rc08 [January 2, 2010]
Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr
in pngtest.c
version 1.4.0 [January 2, 2010]
No changes. No changes.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net

View File

@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* Last changed in libpng 1.4.0 [January 1, 2010] * Last changed in libpng 1.4.0 [January 2, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson * Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -267,12 +267,17 @@ static int wrote_question = 0;
static void static void
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_size_t check; png_size_t check = 0;
png_voidp io_ptr;
/* fread() returns 0 on error, so it is OK to store this in a png_size_t /* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns. * instead of an int, which is what fread() actually returns.
*/ */
check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr); io_ptr = png_get_io_ptr(png_ptr);
if (io_ptr != NULL)
{
check = fread(data, 1, length, (png_FILE_p)io_ptr);
}
if (check != length) if (check != length)
{ {
@ -412,9 +417,12 @@ static void
pngtest_warning(png_structp png_ptr, png_const_charp message) pngtest_warning(png_structp png_ptr, png_const_charp message)
{ {
PNG_CONST char *name = "UNKNOWN (ERROR!)"; PNG_CONST char *name = "UNKNOWN (ERROR!)";
if (png_ptr != NULL && png_ptr->error_ptr != NULL) char *test;
name = png_ptr->error_ptr; test = png_get_error_ptr(png_ptr);
fprintf(STDERR, "%s: libpng warning: %s\n", name, message); if (test == NULL)
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
else
fprintf(STDERR, "%s: libpng warning: %s\n", test, message);
} }
/* This is the default error handling function. Note that replacements for /* This is the default error handling function. Note that replacements for
@ -1619,4 +1627,4 @@ main(int argc, char *argv[])
} }
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_4_0rc07 your_png_h_is_not_version_1_4_0rc07; typedef version_1_4_0rc08 your_png_h_is_not_version_1_4_0rc08;