Skip to content

Commit

Permalink
chore: Clean up the conditional compilation that targeted libpng-1.7
Browse files Browse the repository at this point in the history
In commit 96bc902 we forked the new
branch for libpng-1.8, but we left some of the preprocessor conditions
targeted at libpng-1.7 unresolved. Some of those were resolved in the
subsequent commits.

In this commit we are cleaning up the remaining ones.
  • Loading branch information
ctruta committed Sep 25, 2024
1 parent 12877b1 commit bd09503
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions contrib/libtests/pngimage.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* pngimage.c
*
* Copyright (c) 2021 Cosmin Truta
* Copyright (c) 2021-2024 Cosmin Truta
* Copyright (c) 2015,2016 John Cunningham Bowler
*
* This code is released under the libpng license.
Expand Down Expand Up @@ -46,7 +46,7 @@
# define SKIP 0
#endif

//#if PNG_LIBPNG_VER < 10700
#if PNG_LIBPNG_VER != 10700
/* READ_PNG and WRITE_PNG were not defined, so: */
# ifdef PNG_INFO_IMAGE_SUPPORTED
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
Expand All @@ -56,7 +56,7 @@
# define PNG_WRITE_PNG_SUPPORTED
# endif /* WRITE */
# endif /* INFO_IMAGE */
//#endif /* pre 1.7.0 */
#endif

#ifdef PNG_READ_PNG_SUPPORTED
/* If a transform is valid on both read and write this implies that if the
Expand Down
6 changes: 3 additions & 3 deletions contrib/libtests/pngstest.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* pngstest.c
*
* Copyright (c) 2021 Cosmin Truta
* Copyright (c) 2021-2024 Cosmin Truta
* Copyright (c) 2013-2017 John Cunningham Bowler
*
* This code is released under the libpng license.
Expand Down Expand Up @@ -360,10 +360,10 @@ print_opts(png_uint_32 opts)
printf(" --sRGB-16bit");
if (opts & NO_RESEED)
printf(" --noreseed");
//#if PNG_LIBPNG_VER < 10700 /* else on by default */
#if PNG_LIBPNG_VER != 10700 /* else on by default */
if (opts & GBG_ERROR)
printf(" --fault-gbg-warning");
//#endif
#endif
}

#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */
Expand Down
6 changes: 3 additions & 3 deletions contrib/libtests/pngunknown.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* pngunknown.c - test the read side unknown chunk handling
*
* Copyright (c) 2021 Cosmin Truta
* Copyright (c) 2021-2024 Cosmin Truta
* Copyright (c) 2015,2017 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
Expand Down Expand Up @@ -98,7 +98,7 @@ typedef png_byte *png_const_bytep;
# define png_const_structp png_structp
#endif

//#if PNG_LIBPNG_VER < 10700
#if PNG_LIBPNG_VER != 10700
/* Copied from libpng 1.7.0 png.h */
#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2))

Expand Down Expand Up @@ -143,7 +143,7 @@ typedef png_byte *png_const_bytep;
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))

//#endif /* PNG_LIBPNG_VER < 10700 */
#endif

#ifdef __cplusplus
# define this not_the_cpp_this
Expand Down
26 changes: 13 additions & 13 deletions contrib/tools/pngcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# include "../../png.h"
#endif

//#if PNG_LIBPNG_VER < 10700
#if PNG_LIBPNG_VER != 10700
/* READ_PNG and WRITE_PNG were not defined, so: */
# ifdef PNG_INFO_IMAGE_SUPPORTED
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
Expand All @@ -63,7 +63,7 @@
# define PNG_WRITE_PNG_SUPPORTED
# endif /* WRITE */
# endif /* INFO_IMAGE */
//#endif /* pre 1.7.0 */
#endif

#if (defined(PNG_READ_PNG_SUPPORTED)) && (defined(PNG_WRITE_PNG_SUPPORTED))
#include <stdarg.h>
Expand Down Expand Up @@ -400,11 +400,11 @@ struct display
png_alloc_size_t read_size;
png_structp read_pp;
png_infop ip;
//# if PNG_LIBPNG_VER < 10700 && defined PNG_TEXT_SUPPORTED
# if PNG_LIBPNG_VER != 10700 && defined PNG_TEXT_SUPPORTED
png_textp text_ptr; /* stash of text chunks */
int num_text;
int text_stashed;
//# endif /* pre 1.7 */
# endif

# ifdef PNG_PNGCP_TIMING_SUPPORTED
struct timespec read_time;
Expand Down Expand Up @@ -489,11 +489,11 @@ display_init(struct display *dp)
dp->ip = NULL;
dp->write_pp = NULL;
dp->min_windowBits = -1; /* this is an OPTIND, so -1 won't match anything */
//# if PNG_LIBPNG_VER < 10700 && defined PNG_TEXT_SUPPORTED
# if PNG_LIBPNG_VER != 10700 && defined PNG_TEXT_SUPPORTED
dp->text_ptr = NULL;
dp->num_text = 0;
dp->text_stashed = 0;
//# endif /* pre 1.7 */
# endif
}

static void
Expand Down Expand Up @@ -531,7 +531,7 @@ display_clean(struct display *dp)
display_clean_write(dp, 1/*freeinfo*/);
dp->output_file = NULL;

//# if PNG_LIBPNG_VER < 10700 && defined PNG_TEXT_SUPPORTED
# if PNG_LIBPNG_VER != 10700 && defined PNG_TEXT_SUPPORTED
/* This is actually created and used by the write code, but only
* once; it has to be retained for subsequent writes of the same file.
*/
Expand All @@ -542,7 +542,7 @@ display_clean(struct display *dp)
free(dp->text_ptr);
dp->text_ptr = NULL;
}
//# endif /* pre 1.7 */
# endif

/* leave the filename for error detection */
dp->results = 0; /* reset for next time */
Expand Down Expand Up @@ -635,7 +635,7 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
}
}

//#if PNG_LIBPNG_VER < 10700 && defined PNG_TEXT_SUPPORTED
#if PNG_LIBPNG_VER != 10700 && defined PNG_TEXT_SUPPORTED
static void
text_stash(struct display *dp)
{
Expand Down Expand Up @@ -687,10 +687,10 @@ text_restore(struct display *dp)

#define text_restore(dp) if (dp->text_stashed) text_restore(dp)

//#else
//#define text_stash(dp) ((void)0)
//#define text_restore(dp) ((void)0)
//#endif /* pre 1.7 */
#else
#define text_stash(dp) ((void)0)
#define text_restore(dp) ((void)0)
#endif

/* OPTIONS:
*
Expand Down
4 changes: 2 additions & 2 deletions contrib/tools/pngfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
# define aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */

//#if PNG_LIBPNG_VER < 10700
#if PNG_LIBPNG_VER != 10700
/* Chunk tags (copied from pngpriv.h) */
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
#define PNG_U32(b1,b2,b3,b4) \
Expand Down Expand Up @@ -117,7 +117,7 @@
#define png_tIME PNG_U32(116, 73, 77, 69)
#define png_tRNS PNG_U32(116, 82, 78, 83)
#define png_zTXt PNG_U32(122, 84, 88, 116)
//#endif
#endif

/* The 8-byte signature as a pair of 32-bit quantities */
#define sig1 PNG_U32(137, 80, 78, 71)
Expand Down

0 comments on commit bd09503

Please sign in to comment.