diff options
author | Cosmin Truta <ctruta@gmail.com> | 2024-02-05 21:03:57 +0200 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2024-02-05 21:31:23 +0200 |
commit | cc8006c48d90cca8bf380fa69469b08f4edb00c5 (patch) | |
tree | 7c49e2ff64d637496902be61c389d0901b4eeb25 | |
parent | aa9023bbd06d150fdd45c7bdef8759722721a5fe (diff) | |
download | libpng-cc8006c48d90cca8bf380fa69469b08f4edb00c5.tar.gz |
test: Add consistency checks for the `PNG_LIBPNG_VER*` numbers
Trigger a compile-time error in pngtest.c if there is any disagreement
among `PNG_LIBPNG_VER`, `PNG_LIBPNG_VER_MAJOR`, `PNG_LIBPNG_VER_MINOR`,
etc.
-rw-r--r-- | pngtest.c | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -45,8 +45,19 @@ #include "png.h" -/* KEEPME in libpng-1.6.x */ -#define STDERR stdout +/* Generate a compiler error if there is an old png.h in the search path. */ +typedef png_libpng_version_1_6_43_git Your_png_h_is_not_version_1_6_43_git; + +/* Ensure that all version numbers in png.h are consistent with one another. */ +#if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \ + PNG_LIBPNG_VER_MINOR * 100 + \ + PNG_LIBPNG_VER_RELEASE) || \ + (PNG_LIBPNG_VER_SONUM != PNG_LIBPNG_VER_MAJOR * 10 + \ + PNG_LIBPNG_VER_MINOR) || \ + (PNG_LIBPNG_VER_DLLNUM != PNG_LIBPNG_VER_MAJOR * 10 + \ + PNG_LIBPNG_VER_MINOR) +# error "Inconsistent version numbers in png.h" +#endif /* In version 1.6.1, we added support for the configure test harness, which * uses 77 to indicate a skipped test. On the other hand, in cmake build tests, @@ -58,7 +69,6 @@ # define SKIP 0 #endif - /* Known chunks that exist in pngtest.png must be supported, or pngtest will * fail simply as a result of re-ordering them. This may be fixed in the next * generation of libpng. @@ -93,6 +103,11 @@ typedef FILE * png_FILE_p; #endif +/* This hack was introduced for historical reasons, and we are + * still keeping it in libpng-1.6.x for compatibility reasons. + */ +#define STDERR stdout + #ifndef PNG_DEBUG # define PNG_DEBUG 0 #endif @@ -1786,12 +1801,11 @@ main(int argc, char *argv[]) fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); #endif - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) + if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING) != 0) { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); + fprintf(STDERR, "Warning: mismatching versions of png.h and png.c\n"); + fprintf(STDERR, " png.h version string: %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, " png.c version string: %s\n\n", png_libpng_ver); ++ierror; } @@ -2088,6 +2102,3 @@ main(void) return SKIP; } #endif - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_43_git Your_png_h_is_not_version_1_6_43_git; |