[libpng17] Merge pngvalid.c with libpng-1.6.14beta04.

This commit is contained in:
Glenn Randers-Pehrson 2014-09-27 19:30:35 -05:00
parent d7078c52e2
commit 776d1768aa

View File

@ -30,6 +30,20 @@
# include <config.h> # include <config.h>
#endif #endif
#ifdef HAVE_FEENABLEEXCEPT /* from config.h, if included */
# include <fenv.h>
#endif
#ifndef FE_DIVBYZERO
# define FE_DIVBYZERO 0
#endif
#ifndef FE_INVALID
# define FE_INVALID 0
#endif
#ifndef FE_OVERFLOW
# define FE_OVERFLOW 0
#endif
/* Define the following to use this test against your installed libpng, rather /* Define the following to use this test against your installed libpng, rather
* than the one being built here: * than the one being built here:
*/ */
@ -39,13 +53,6 @@
# include "../../png.h" # include "../../png.h"
#endif #endif
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
# ifdef HAVE_FEENABLEEXCEPT /* from config.h, if included */
# include <fenv.h>
# endif
#endif
#ifdef PNG_ZLIB_HEADER #ifdef PNG_ZLIB_HEADER
# include PNG_ZLIB_HEADER # include PNG_ZLIB_HEADER
#else #else
@ -689,7 +696,7 @@ static png_uint_32
random_32(void) random_32(void)
{ {
for(;;) for (;;)
{ {
png_byte mark[4]; png_byte mark[4];
png_uint_32 result; png_uint_32 result;
@ -9965,11 +9972,9 @@ static void signal_handler(int signum)
pos = safecat(msg, sizeof msg, pos, "abort"); pos = safecat(msg, sizeof msg, pos, "abort");
break; break;
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
case SIGFPE: case SIGFPE:
pos = safecat(msg, sizeof msg, pos, "floating point exception"); pos = safecat(msg, sizeof msg, pos, "floating point exception");
break; break;
#endif
case SIGILL: case SIGILL:
pos = safecat(msg, sizeof msg, pos, "illegal instruction"); pos = safecat(msg, sizeof msg, pos, "illegal instruction");
@ -10035,21 +10040,18 @@ int main(int argc, char **argv)
/* Add appropriate signal handlers, just the ANSI specified ones: */ /* Add appropriate signal handlers, just the ANSI specified ones: */
signal(SIGABRT, signal_handler); signal(SIGABRT, signal_handler);
signal(SIGFPE, signal_handler);
signal(SIGILL, signal_handler); signal(SIGILL, signal_handler);
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
signal(SIGSEGV, signal_handler); signal(SIGSEGV, signal_handler);
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED #ifdef HAVE_FEENABLEEXCEPT
signal(SIGFPE, signal_handler);
# ifdef HAVE_FEENABLEEXCEPT
/* Only required to enable FP exceptions on platforms where they start off /* Only required to enable FP exceptions on platforms where they start off
* disabled; this is not necessary but if it is not done pngvalid will likely * disabled; this is not necessary but if it is not done pngvalid will likely
* end up ignoring FP conditions that other platforms fault. * end up ignoring FP conditions that other platforms fault.
*/ */
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
# endif
#endif #endif
modifier_init(&pm); modifier_init(&pm);