diff options
Diffstat (limited to 'contrib/libtests/pngunknown.c')
-rw-r--r-- | contrib/libtests/pngunknown.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c index 12eab7258..dfa9d10a1 100644 --- a/contrib/libtests/pngunknown.c +++ b/contrib/libtests/pngunknown.c @@ -1,7 +1,7 @@ /* pngunknown.c - test the read side unknown chunk handling * - * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 2021 Cosmin Truta * Copyright (c) 2015,2017 Glenn Randers-Pehrson * Written by John Cunningham Bowler * @@ -56,7 +56,7 @@ defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) #if PNG_LIBPNG_VER < 10500 -/* This deliberately lacks the PNG_CONST. */ +/* This deliberately lacks the const. */ typedef png_byte *png_const_bytep; /* This is copied from 1.5.1 png.h: */ @@ -85,7 +85,7 @@ typedef png_byte *png_const_bytep; #define PNG_WRITE_16BIT_SUPPORTED #define PNG_READ_16BIT_SUPPORTED -/* This comes from pnglibconf.h afer 1.5: */ +/* This comes from pnglibconf.h after 1.5: */ #define PNG_FP_1 100000 #define PNG_GAMMA_THRESHOLD_FIXED\ ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1)) @@ -370,7 +370,9 @@ find_by_flag(png_uint_32 flag) { int i = NINFO; - while (--i >= 0) if (chunk_info[i].flag == flag) return i; + while (--i >= 0) + if (chunk_info[i].flag == flag) + return i; fprintf(stderr, "pngunknown: internal error\n"); exit(4); @@ -547,27 +549,30 @@ read_callback(png_structp pp, png_unknown_chunkp pc) case PNG_HANDLE_CHUNK_AS_DEFAULT: case PNG_HANDLE_CHUNK_NEVER: - discard = 1/*handled; discard*/; + discard = 1; /*handled; discard*/ break; case PNG_HANDLE_CHUNK_IF_SAFE: case PNG_HANDLE_CHUNK_ALWAYS: - discard = 0/*not handled; keep*/; + discard = 0; /*not handled; keep*/ break; } /* Also store information about this chunk in the display, the relevant flag * is set if the chunk is to be kept ('not handled'.) */ - if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */ + if (chunk >= 0) { - png_uint_32 flag = chunk_info[chunk].flag; + if (!discard) /* stupidity to stop a GCC warning */ + { + png_uint_32 flag = chunk_info[chunk].flag; - if (pc->location & PNG_AFTER_IDAT) - d->after_IDAT |= flag; + if (pc->location & PNG_AFTER_IDAT) + d->after_IDAT |= flag; - else - d->before_IDAT |= flag; + else + d->before_IDAT |= flag; + } } /* However if there is no support to store unknown chunks don't ask libpng to @@ -841,8 +846,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/, { png_uint_32 y; - for (y=0; y<height; ++y) if (PNG_ROW_IN_INTERLACE_PASS(y, ipass)) - png_read_row(d->png_ptr, NULL, NULL); + for (y=0; y<height; ++y) + if (PNG_ROW_IN_INTERLACE_PASS(y, ipass)) + png_read_row(d->png_ptr, NULL, NULL); } } } /* interlaced */ @@ -1091,15 +1097,15 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv, static const char *standard_tests[] = { - "discard", "default=discard", 0, - "save", "default=save", 0, - "if-safe", "default=if-safe", 0, - "vpAg", "vpAg=if-safe", 0, - "sTER", "sTER=if-safe", 0, - "IDAT", "default=discard", "IDAT=save", 0, - "sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save", - "sBIT=save", "sRGB=save", "eXIf=save", 0, - 0/*end*/ + "discard", "default=discard", NULL, + "save", "default=save", NULL, + "if-safe", "default=if-safe", NULL, + "vpAg", "vpAg=if-safe", NULL, + "sTER", "sTER=if-safe", NULL, + "IDAT", "default=discard", "IDAT=save", NULL, + "sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save", + "sBIT=save", "sRGB=save", "eXIf=save", NULL, + NULL /*end*/ }; static PNG_NORETURN void @@ -1115,7 +1121,7 @@ int main(int argc, const char **argv) { FILE *fp; - png_uint_32 default_flags[4/*valid,unknown{before,after}*/]; + png_uint_32 default_flags[4]; /*valid,unknown{before,after}*/ int strict = 0, default_tests = 0; const char *count_argv = "default=save"; const char *touch_file = NULL; @@ -1153,8 +1159,9 @@ main(int argc, const char **argv) /* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc * optimization which causes warnings with -Wstrict-overflow! */ - else if (default_tests) if (argc != 1) - usage(d.program, "extra arguments"); + else if (default_tests) + if (argc != 1) + usage(d.program, "extra arguments"); /* The name of the test file is the last argument; remove it. */ d.file = argv[--argc]; @@ -1216,7 +1223,11 @@ main(int argc, const char **argv) const char *result; int arg_count = 0; - while (*next) ++next, ++arg_count; + while (*next != NULL) + { + ++next; + ++arg_count; + } perform_one_test_safe(fp, arg_count, test, default_flags, &d, this_test); |