提交 d29033f2 编写于 作者: G Glenn Randers-Pehrson

[master] Added macros to detect use of deprecated features.

  Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and
    PNG_ALLOCATED macros to detect deprecated direct access to the
    png_struct or info_struct members and other deprecated usage in
    applications (John Bowler).
  Added -DPNG_CONFIGURE_LIBPNG to the makefile CFLAGS, to prevent warnings
    about direct access to png structs by libpng functions while building
    libpng.
  Removed three direct references to read_info_ptr members in pngtest.c
    that were detected by the new PNG_DEPSTRUCT macro.
  Moved the png_debug macro definitions and the png_read_destroy(),
    png_write_destroy() and png_far_to_near() prototypes from png.h
    to pngpriv.h (John Bowler)
  Moved the synopsis lines for png_read_destroy(), png_write_destroy()
    png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3.
上级 047c34b7
......@@ -605,13 +605,36 @@ version 1.4.0beta91 [November 3, 2009]
Patched ltmain.sh for wince support.
Added PNG_CONVERT_tIME_SUPPORTED macro.
version 1.4.0beta92 [November 7, 2009]
version 1.4.0beta92 [November 4, 2009]
Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED
Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED
Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead
of from 1.2.41)
of differences from 1.2.41 to 1.4.0)
version 1.4.0beta93 [November 7, 2009]
Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and
PNG_ALLOCATED macros to detect deprecated direct access to the
png_struct or info_struct members and other deprecated usage in
applications (John Bowler).
Added -DPNG_CONFIGURE_LIBPNG to the makefile CFLAGS, to prevent warnings
about direct access to png structs by libpng functions while building
libpng.
Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS.
They need to be tested, especially those using compilers other than gcc.
Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG".
They should work but still need to be updated to remove
references to pnggccrd.c or pngvcrd.c and ASM building.
Added README.txt to the beos, cbuilder5, netware, and xcode projects warning
that they need to be updated, to remove references to pnggccrd.c and
pngvcrd.c and to depend on pngpriv.h
Removed three direct references to read_info_ptr members in pngtest.c
that were detected by the new PNG_DEPSTRUCT macro.
Moved the png_debug macro definitions and the png_read_destroy(),
png_write_destroy() and png_far_to_near() prototypes from png.h
to pngpriv.h (John Bowler)
Moved the synopsis lines for png_read_destroy(), png_write_destroy()
png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
......
......@@ -2295,9 +2295,31 @@ version 1.4.0beta92 [November 4, 2009]
Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED
Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED
Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead
of from 1.2.41)
of differences from 1.2.41 to 1.4.0)
version 1.4.0beta93 [November 7, 2009]
Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and
PNG_ALLOCATED macros to detect deprecated direct access to the
png_struct or info_struct members and other deprecated usage in
applications (John Bowler).
Added -DPNG_CONFIGURE_LIBPNG to the makefile CFLAGS, to prevent warnings
about direct access to png structs by libpng functions while building
libpng.
Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS.
They need to be tested, especially those using compilers other than gcc.
Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG".
They should work but still need to be updated to remove
references to pnggccrd.c or pngvcrd.c and ASM building.
Added README.txt to the beos, cbuilder5, netware, and xcode projects warning
that they need to be updated, to remove references to pnggccrd.c and
pngvcrd.c and to depend on pngpriv.h
Removed three direct references to read_info_ptr members in pngtest.c
that were detected by the new PNG_DEPSTRUCT macro.
Moved the png_debug macro definitions and the png_read_destroy(),
png_write_destroy() and png_far_to_near() prototypes from png.h
to pngpriv.h (John Bowler)
Moved the synopsis lines for png_read_destroy(), png_write_destroy()
png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
......
此差异已折叠。
......@@ -1286,6 +1286,41 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
#endif
/* Support for compiler specific function attributes. These are used
* so that where compiler support is available incorrect use of API
* functions in png.h will generate compiler warnings.
*/
#ifdef __GNUC__
# define PNG_DEPRECATED __attribute__((__deprecated__))
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
# define PNG_NORETURN __attribute__((__noreturn__))
# define PNG_ALLOCATED __attribute__((__malloc__))
# ifndef PNG_CONFIGURE_LIBPNG
/* This specifically protects structure members that should only be
* accessed from within the library, therefore should be empty during
* a library build.
*/
# define PNG_DEPSTRUCT __attribute__((__deprecated__))
# endif
#endif
#ifndef PNG_DEPRECATED
# define PNG_DEPRECATED /* use of this function is deprecated */
#endif
#ifndef PNG_USE_RESULT
# define PNG_USE_RESULT /* the result of this function must be checked */
#endif
#ifndef PNG_NORETURN
# define PNG_NORETURN /* this function does not return */
#endif
#ifndef PNG_ALLOCATED
# define PNG_ALLOCATED /* the result of the function is new memory */
#endif
#ifndef PNG_DEPSTRUCT
# define PNG_DEPSTRUCT /* access to this struct member is deprecated */
#endif
/* Users may want to use these so they are not private. Any library
* functions that are passed far data must be model-independent.
*/
......
......@@ -22,7 +22,7 @@
static void /* PRIVATE */
png_default_error PNGARG((png_structp png_ptr,
png_const_charp error_message));
png_const_charp error_message)) PNG_NORETURN;
#ifdef PNG_WARNINGS_SUPPORTED
static void /* PRIVATE */
png_default_warning PNGARG((png_structp png_ptr,
......@@ -285,9 +285,9 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
longjmp(png_ptr->jmpbuf, 1);
# endif
}
#else
PNG_ABORT();
#endif
/* Here if not setjmp support or if png_ptr is null. */
PNG_ABORT();
#ifndef PNG_CONSOLE_IO_SUPPORTED
error_message = error_message; /* Make compiler happy */
#endif
......
......@@ -831,6 +831,129 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
int color_type, int interlace_type, int compression_type,
int filter_type));
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
png_infop end_info_ptr));
/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
extern void png_write_destroy PNGARG((png_structp png_ptr));
#ifdef USE_FAR_KEYWORD /* memory model conversion function */
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
#endif /* USE_FAR_KEYWORD */
/* Define PNG_DEBUG at compile time for debugging information. Higher
* 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.
*/
#ifdef PNG_DEBUG
#if (PNG_DEBUG > 0)
#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
#include <crtdbg.h>
#if (PNG_DEBUG > 1)
#ifndef _DEBUG
# define _DEBUG
#endif
#ifndef png_debug
#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
#endif
#ifndef png_debug1
#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
#endif
#ifndef png_debug2
#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
#endif
#endif
#else /* PNG_DEBUG_FILE || !_MSC_VER */
#ifndef PNG_DEBUG_FILE
#define PNG_DEBUG_FILE stderr
#endif /* PNG_DEBUG_FILE */
#if (PNG_DEBUG > 1)
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
* non-ISO compilers
*/
# ifdef __STDC__
# ifndef png_debug
# define png_debug(l,m) \
{ \
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":"")))); \
}
# endif
# ifndef png_debug1
# define png_debug1(l,m,p1) \
{ \
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); \
}
# endif
# ifndef png_debug2
# define png_debug2(l,m,p1,p2) \
{ \
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); \
}
# endif
# else /* __STDC __ */
# ifndef png_debug
# define png_debug(l,m) \
{ \
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); \
}
# endif
# ifndef png_debug1
# define png_debug1(l,m,p1) \
{ \
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); \
}
# endif
# ifndef png_debug2
# define png_debug2(l,m,p1,p2) \
{ \
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); \
}
# endif
# endif /* __STDC __ */
#endif /* (PNG_DEBUG > 1) */
#endif /* _MSC_VER */
#endif /* (PNG_DEBUG > 0) */
#endif /* PNG_DEBUG */
#ifndef png_debug
#define png_debug(l, m)
#endif
#ifndef png_debug1
#define png_debug1(l, m, p1)
#endif
#ifndef png_debug2
#define png_debug2(l, m, p1, p2)
#endif
#if 0
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
#endif
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
#ifdef __cplusplus
......
......@@ -1052,11 +1052,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
&trans_color))
{
int sample_max = (1 << read_info_ptr->bit_depth);
int sample_max = (1 << bit_depth);
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
if (!((read_info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
if (!((color_type == PNG_COLOR_TYPE_GRAY &&
(int)trans_color->gray > sample_max) ||
(read_info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
(color_type == PNG_COLOR_TYPE_RGB &&
((int)trans_color->red > sample_max ||
(int)trans_color->green > sample_max ||
(int)trans_color->blue > sample_max))))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册