From d7afc8c14f379f1e7dcf91d9c57cb9b2d1f2d926 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Tue, 2 Feb 2021 22:00:42 +0000 Subject: Use TIFF_SSIZE_FORMAT for formatting tmsize_t --- libtiff/tif_aux.c | 2 +- libtiff/tif_config.h.cmake.in | 14 +++++++++++--- libtiff/tif_dirread.c | 2 +- libtiff/tif_dumpmode.c | 2 +- libtiff/tif_fax3.c | 4 ++-- libtiff/tif_luv.c | 6 +++--- libtiff/tif_packbits.c | 4 ++-- libtiff/tif_read.c | 14 +++++++------- tools/tiff2pdf.c | 31 +++++++++++++++---------------- tools/tiff2ps.c | 14 +++++++------- tools/tiff2rgba.c | 4 ++-- tools/tiffcp.c | 4 ++-- tools/tiffcrop.c | 2 +- 13 files changed, 55 insertions(+), 48 deletions(-) diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c index 3910e61c..140f26c7 100644 --- a/libtiff/tif_aux.c +++ b/libtiff/tif_aux.c @@ -109,7 +109,7 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer, if (cp == NULL) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%"PRId64" elements of %"PRId64" bytes each)", + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", what, nmemb, elem_size); } diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in index 2b3d8d43..d239a6b7 100644 --- a/libtiff/tif_config.h.cmake.in +++ b/libtiff/tif_config.h.cmake.in @@ -107,12 +107,12 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "@PACKAGE_VERSION@" +/* Size of size_t */ +#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@ + /* Default size of the strip in bytes (when strip chopping enabled) */ #define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@ -/* Signed size type formatter */ -#define TIFF_SSIZE_FORMAT @TIFF_SSIZE_FORMAT@ - /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME @@ -140,6 +140,14 @@ /* Number of bits in a file offset, on hosts where this is settable. */ #define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@ +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +#elif SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId32 +#else +# error "Unsupported size_t size; please submit a bug report" +#endif + /* Define to `long int' if does not define. */ #undef off_t diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 1543c3f4..11f94cf4 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -809,7 +809,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%"PRId64" elements of %"PRId64" bytes each)", + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", "TIFFReadDirEntryArray", (tmsize_t) 1, already_read + to_read); return TIFFReadDirEntryErrAlloc; diff --git a/libtiff/tif_dumpmode.c b/libtiff/tif_dumpmode.c index 8171ac4a..f1d3c4ad 100644 --- a/libtiff/tif_dumpmode.c +++ b/libtiff/tif_dumpmode.c @@ -79,7 +79,7 @@ DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) (void) s; if (tif->tif_rawcc < cc) { TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %"PRIu32", expected a request for at most %"PRId64" bytes, got a request for %"PRId64" bytes", +"Not enough data for scanline %"PRIu32", expected a request for at most %"TIFF_SSIZE_FORMAT" bytes, got a request for %"TIFF_SSIZE_FORMAT" bytes", tif->tif_row, tif->tif_rawcc, cc); diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c index 736daa24..a61362af 100644 --- a/libtiff/tif_fax3.c +++ b/libtiff/tif_fax3.c @@ -1462,7 +1462,7 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %"PRId64" bytes available, %d bits needed", + "Buffer overrun detected : %"TIFF_SSIZE_FORMAT" bytes available, %d bits needed", occ, lastx); return -1; } @@ -1484,7 +1484,7 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %"PRId64" bytes available, %d bits needed", + "Buffer overrun detected : %"TIFF_SSIZE_FORMAT" bytes available, %d bits needed", occ, lastx); return -1; } diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c index de650b31..13765eab 100644 --- a/libtiff/tif_luv.c +++ b/libtiff/tif_luv.c @@ -232,7 +232,7 @@ LogL16Decode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } if (i != npixels) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %"PRIu32" (short %"PRId64" pixels)", + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", tif->tif_row, npixels - i); tif->tif_rawcp = (uint8_t*) bp; @@ -288,7 +288,7 @@ LogLuvDecode24(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) tif->tif_rawcc = cc; if (i != npixels) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %"PRIu32" (short %"PRId64" pixels)", + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", tif->tif_row, npixels - i); return (0); @@ -354,7 +354,7 @@ LogLuvDecode32(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } if (i != npixels) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %"PRIu32" (short %"PRId64" pixels)", + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", tif->tif_row, npixels - i); tif->tif_rawcp = (uint8_t*) bp; diff --git a/libtiff/tif_packbits.c b/libtiff/tif_packbits.c index 010c09bf..76569ad7 100644 --- a/libtiff/tif_packbits.c +++ b/libtiff/tif_packbits.c @@ -238,7 +238,7 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) if( occ < (tmsize_t)n ) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %"PRId64" bytes to avoid buffer overrun", + "Discarding %"TIFF_SSIZE_FORMAT" bytes to avoid buffer overrun", (tmsize_t)n - occ); n = (long)occ; } @@ -257,7 +257,7 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) if (occ < (tmsize_t)(n + 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %"PRId64" bytes to avoid buffer overrun", + "Discarding %"TIFF_SSIZE_FORMAT" bytes to avoid buffer overrun", (tmsize_t)n - occ + 1); n = (long)occ - 1; } diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c index 8b174d9a..a4c60b4f 100644 --- a/libtiff/tif_read.c +++ b/libtiff/tif_read.c @@ -133,8 +133,8 @@ static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size, if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %"PRIu32"; got %"PRId64" bytes, " - "expected %"PRId64, + "Read error at scanline %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, " + "expected %"TIFF_SSIZE_FORMAT, tif->tif_row, already_read, size); @@ -143,7 +143,7 @@ static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size, { TIFFErrorExt(tif->tif_clientdata, module, "Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; " - "got %"PRId64" bytes, expected %"PRId64"", + "got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT"", tif->tif_row, tif->tif_col, strip_or_tile, @@ -599,7 +599,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, cc = TIFFReadFile(tif, buf, size); if (cc != size) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + "Read error at scanline %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, tif->tif_row, cc, size); @@ -627,7 +627,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, } if (n!=size) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %"PRIu32", strip %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + "Read error at scanline %"PRIu32", strip %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, tif->tif_row, strip, n, @@ -1043,7 +1043,7 @@ TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* cc = TIFFReadFile(tif, buf, size); if (cc != size) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %"PRIu32", col %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + "Read error at row %"PRIu32", col %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, tif->tif_row, tif->tif_col, cc, @@ -1063,7 +1063,7 @@ TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* n=size; if (n!=size) { TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, +"Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, tif->tif_row, tif->tif_col, tile, diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 2f3317e2..4cdf0f90 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -24,9 +24,6 @@ * OF THIS SOFTWARE. */ -#include "tif_config.h" -#include "libport.h" - #include #include #include @@ -49,6 +46,8 @@ #include "tiffiop.h" #include "tiffio.h" +#include "tif_config.h" +#include "libport.h" #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -2262,7 +2261,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if (buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for " "t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -2531,7 +2530,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2569,7 +2568,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2579,7 +2578,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ samplebuffer = (unsigned char*) _TIFFmalloc(stripsize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2619,7 +2618,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2654,7 +2653,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_datasize * t2p->tiff_samplesperpixel); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2685,7 +2684,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_width*t2p->tiff_length*4); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2882,7 +2881,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3044,7 +3043,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for " "t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3078,7 +3077,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3089,7 +3088,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ samplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3130,7 +3129,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -4206,7 +4205,7 @@ tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){ char buffer[32]; int buflen=0; - buflen=snprintf(buffer, sizeof(buffer), "%"PRId64, len); + buflen=snprintf(buffer, sizeof(buffer), "%"TIFF_SSIZE_FORMAT, len); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n", 1); diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c index 9a093d25..cc5ef955 100644 --- a/tools/tiff2ps.c +++ b/tools/tiff2ps.c @@ -247,7 +247,7 @@ static void usage(int); static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of %" PRId64 " bytes is forbidden. Limit is %" PRId64 ".\n", + fprintf(stderr, "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", s, maxMalloc); fprintf(stderr, " use -M option to change limit.\n"); return NULL; @@ -2212,7 +2212,7 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) } buf_data = (unsigned char *)limitMalloc(chunk_size); if (!buf_data) { - TIFFError(filename, "Can't alloc %"PRId64" bytes for %s.", + TIFFError(filename, "Can't alloc %"TIFF_SSIZE_FORMAT" bytes for %s.", chunk_size, tiled_image ? "tiles" : "strips"); return(FALSE); } @@ -2390,8 +2390,8 @@ PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case PHOTOMETRIC_PALETTE: fprintf(fd, "%s", RGBcolorimage); PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); - fprintf(fd, "/scanLine %"PRId64" string def\n", - ps_bytesperrow * 3L); + fprintf(fd, "/scanLine %"TIFF_SSIZE_FORMAT" string def\n", + ps_bytesperrow * 3); fprintf(fd, "%"PRIu32" %"PRIu32" 8\n", w, h); fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", @@ -2403,7 +2403,7 @@ PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: PhotoshopBanner(fd, w, h, 1, 1, imageOp); - fprintf(fd, "/scanLine %"PRId64" string def\n", + fprintf(fd, "/scanLine %"TIFF_SSIZE_FORMAT" string def\n", ps_bytesperrow); fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", w, h, bitspersample); @@ -2423,7 +2423,7 @@ PSColorContigPreamble(FILE* fd, uint32_t w, uint32_t h, int nc) { ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); - fprintf(fd, "/line %"PRId64" string def\n", ps_bytesperrow); + fprintf(fd, "/line %"TIFF_SSIZE_FORMAT" string def\n", ps_bytesperrow); fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", w, h, bitspersample); fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", @@ -2439,7 +2439,7 @@ PSColorSeparatePreamble(FILE* fd, uint32_t w, uint32_t h, int nc) PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); for (i = 0; i < nc; i++) - fprintf(fd, "/line%d %"PRId64" string def\n", + fprintf(fd, "/line%d %"TIFF_SSIZE_FORMAT" string def\n", i, ps_bytesperrow); fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", w, h, bitspersample); diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c index e6202d69..e0dbcc45 100644 --- a/tools/tiff2rgba.c +++ b/tools/tiff2rgba.c @@ -411,7 +411,7 @@ cvt_whole_image( TIFF *in, TIFF *out ) } if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) { TIFFError(TIFFFileName(in), - "Raster size %zu over memory limit (%" PRId64 "), try -b option.", + "Raster size %zu over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.", pixel_count * sizeof(uint32_t), maxMalloc); return 0; } @@ -543,7 +543,7 @@ tiffcvt(TIFF* in, TIFF* out) if (maxMalloc != 0 && TIFFStripSize(in) > maxMalloc) { TIFFError(TIFFFileName(in), - "Strip Size %" PRId64 " over memory limit (%" PRId64 ")", + "Strip Size %" TIFF_SSIZE_FORMAT " over memory limit (%" TIFF_SSIZE_FORMAT ")", TIFFStripSize(in), maxMalloc); return 0; } diff --git a/tools/tiffcp.c b/tools/tiffcp.c index f6b44813..e29ed333 100644 --- a/tools/tiffcp.c +++ b/tools/tiffcp.c @@ -107,7 +107,7 @@ static int pageInSeq = 0; static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of %" PRId64 " bytes is forbidden. Limit is %" PRId64 ".\n", + fprintf(stderr, "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", s, maxMalloc); fprintf(stderr, " use -m option to change limit.\n"); return NULL; @@ -1099,7 +1099,7 @@ DECLAREcpFunc(cpDecodedStrips) return 1; } else { TIFFError(TIFFFileName(in), - "Error, can't allocate memory buffer of size %"PRId64 + "Error, can't allocate memory buffer of size %"TIFF_SSIZE_FORMAT " to read strips", stripsize); return 0; } diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c index 7751e866..06a2c148 100644 --- a/tools/tiffcrop.c +++ b/tools/tiffcrop.c @@ -865,7 +865,7 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, if (tbytes < tilesize && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at row %"PRIu32" col %"PRIu32", Read %"PRId64" bytes of %"PRId64, + "Error, can't read tile at row %"PRIu32" col %"PRIu32", Read %"TIFF_SSIZE_FORMAT" bytes of %"TIFF_SSIZE_FORMAT, col, row, tbytes, tilesize); status = 0; _TIFFfree(tilebuf); -- cgit v1.2.1 From c5820961e65b5dd54777c97c4b2a2347d6515570 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Tue, 2 Feb 2021 23:29:14 +0000 Subject: Align Autoconf tif_config.h and CMake tif_config.cmake.in --- .gitignore | 1 - CMakeLists.txt | 24 ++----- configure.ac | 2 +- libtiff/tif_config.h.cmake.in | 46 +++++------- libtiff/tif_config.h.in | 159 ++++++++++++++++++++++++++++++++++++++++++ libtiff/tif_config.vc.h | 2 + tools/tiffcrop.c | 5 +- 7 files changed, 186 insertions(+), 53 deletions(-) create mode 100644 libtiff/tif_config.h.in diff --git a/.gitignore b/.gitignore index ad4d4e3c..45562baa 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ libtiff/mkg3states libtiff/stamp-h1 libtiff/stamp-h2 libtiff/tif_config.h -libtiff/tif_config.h.in libtiff/tiffconf.h libtool m4/libtool.m4 diff --git a/CMakeLists.txt b/CMakeLists.txt index d058d67d..e3fdbd26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,24 +214,12 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(unistd.h HAVE_UNISTD_H) -# Check if sys/time.h and time.h allow use together -check_c_source_compiles(" -#include -#include -int main(void){return 0;}" - TIME_WITH_SYS_TIME) - -# Check if struct tm is in sys/time.h -check_c_source_compiles(" -#include -#include - -int main(void){ - struct tm tm; - int *p = &tm.tm_sec; - return !p; -}" - TM_IN_SYS_TIME) +check_symbol_exists(optarg "getopt.h" HAVE_DECL_OPTARG) +if (HAVE_DECL_OPTARG) + set(HAVE_DECL_OPTARG 1) +else() + set(HAVE_DECL_OPTARG 0) +endif() # Disable deprecated features to ensure clean build add_definitions(-DTIFF_DISABLE_DEPRECATED) diff --git a/configure.ac b/configure.ac index 0e09fbc3..dcbfbe15 100644 --- a/configure.ac +++ b/configure.ac @@ -1021,7 +1021,7 @@ dnl --------------------------------------------------------------------------- AC_SUBST(LIBDIR) -AC_CONFIG_HEADERS([libtiff/tif_config.h libtiff/tiffconf.h]) +AC_CONFIG_HEADERS([config.h libtiff/tif_config.h libtiff/tiffconf.h]) AC_CONFIG_FILES([Makefile \ build/Makefile \ diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in index d239a6b7..2b65d243 100644 --- a/libtiff/tif_config.h.cmake.in +++ b/libtiff/tif_config.h.cmake.in @@ -1,6 +1,8 @@ /* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */ /* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */ +#include "tiffconf.h" + /* Support CCITT Group 3 & 4 algorithms */ #cmakedefine CCITT_SUPPORT 1 @@ -20,9 +22,15 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ASSERT_H 1 +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */ +#cmakedefine HAVE_DECL_OPTARG 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FCNTL_H 1 +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#cmakedefine HAVE_FSEEKO 1 + /* Define to 1 if you have the `getopt' function. */ #cmakedefine HAVE_GETOPT 1 @@ -56,15 +64,9 @@ /* Define to 1 if you have the `setmode' function. */ #cmakedefine HAVE_SETMODE 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRINGS_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TIME_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 @@ -72,7 +74,7 @@ #cmakedefine HAVE_UNISTD_H 1 /* 8/12 bit libjpeg dual mode enabled */ -#cmakedefine JPEG_DUAL_MODE_8_12 1 +#cmakedefine JPEG_DUAL_MODE_8_12 1 1 /* 12bit libjpeg primary include file with path */ #define LIBJPEG_12_PATH @LIBJPEG_12_PATH@ @@ -80,12 +82,6 @@ /* Support LZMA2 compression */ #cmakedefine LZMA_SUPPORT 1 -/* Support ZSTD compression */ -#cmakedefine ZSTD_SUPPORT 1 - -/* Support WEBP compression */ -#cmakedefine WEBP_SUPPORT 1 - /* Name of package */ #define PACKAGE "@PACKAGE_NAME@" @@ -113,18 +109,19 @@ /* Default size of the strip in bytes (when strip chopping enabled) */ #define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@ -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your declares `struct tm'. */ -#cmakedefine TM_IN_SYS_TIME 1 - /* define to use win32 IO system */ #cmakedefine USE_WIN32_FILEIO 1 /* Version number of package */ #define VERSION "@PACKAGE_VERSION@" +/* Support WEBP compression */ +#cmakedefine WEBP_SUPPORT 1 + +/* Support ZSTD compression */ +#cmakedefine ZSTD_SUPPORT 1 + + /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD @@ -137,19 +134,10 @@ # endif #endif -/* Number of bits in a file offset, on hosts where this is settable. */ -#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@ - #if SIZEOF_SIZE_T == 8 # define TIFF_SSIZE_FORMAT PRId64 -#elif SIZEOF_SIZE_T == 8 +#elif SIZEOF_SIZE_T == 4 # define TIFF_SSIZE_FORMAT PRId32 #else # error "Unsupported size_t size; please submit a bug report" #endif - -/* Define to `long int' if does not define. */ -#undef off_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t diff --git a/libtiff/tif_config.h.in b/libtiff/tif_config.h.in new file mode 100644 index 00000000..6a543463 --- /dev/null +++ b/libtiff/tif_config.h.in @@ -0,0 +1,159 @@ +/* libtiff/tif_config.h.in. Not generated, but originated from autoheader. */ + +#include "tiffconf.h" + +/* Support CCITT Group 3 & 4 algorithms */ +#undef CCITT_SUPPORT + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#undef CHECK_JPEG_YCBCR_SUBSAMPLING + +/* enable partial strip reading for large strips (experimental) */ +#undef CHUNKY_STRIP_READ_SUPPORT + +/* Support C++ stream API (requires C++ compiler) */ +#undef CXX_SUPPORT + +/* enable deferred strip/tile offset/size loading */ +#undef DEFER_STRILE_LOAD + +/* Define to 1 if you have the header file. */ +#undef HAVE_ASSERT_H + +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. + */ +#undef HAVE_DECL_OPTARG + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the `getopt' function. */ +#undef HAVE_GETOPT + +/* Define to 1 if you have the header file. */ +#undef HAVE_GLUT_GLUT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_GL_GLUT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_GL_GLU_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_GL_GL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IO_H + +/* Define to 1 if you have the `jbg_newlen' function. */ +#undef HAVE_JBG_NEWLEN + +/* Define to 1 if you have the `mmap' function. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENGL_GLU_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENGL_GL_H + +/* Define to 1 if you have the `setmode' function. */ +#undef HAVE_SETMODE + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* 8/12 bit libjpeg dual mode enabled */ +#undef JPEG_DUAL_MODE_8_12 + +/* 12bit libjpeg primary include file with path */ +#undef LIBJPEG_12_PATH + +/* Support LZMA2 compression */ +#undef LZMA_SUPPORT + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* The size of `size_t', as computed by sizeof. */ +#undef SIZEOF_SIZE_T + +/* Default size of the strip in bytes (when strip chopping enabled) */ +#undef STRIP_SIZE_DEFAULT + +/* define to use win32 IO system */ +#undef USE_WIN32_FILEIO + +/* Version number of package */ +#undef VERSION + +/* Support webp compression */ +#undef WEBP_SUPPORT + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Support zstd compression */ +#undef ZSTD_SUPPORT + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +#undef _LARGEFILE_SOURCE + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +#elif SIZEOF_SIZE_T == 4 +# define TIFF_SSIZE_FORMAT PRId32 +#else +# error "Unsupported size_t size; please submit a bug report" +#endif \ No newline at end of file diff --git a/libtiff/tif_config.vc.h b/libtiff/tif_config.vc.h index fafc422e..8413c826 100644 --- a/libtiff/tif_config.vc.h +++ b/libtiff/tif_config.vc.h @@ -1,6 +1,8 @@ #ifndef _TIF_CONFIG_H_ #define _TIF_CONFIG_H_ +#include "tiffconf.h" + /* Define to 1 if you have the header file. */ #define HAVE_ASSERT_H 1 diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c index 06a2c148..c793d8e3 100644 --- a/tools/tiffcrop.c +++ b/tools/tiffcrop.c @@ -114,6 +114,7 @@ static char tiffcrop_rev_date[] = "12-13-2010"; #include #include +#include #include #include #include @@ -125,10 +126,6 @@ static char tiffcrop_rev_date[] = "12-13-2010"; # include #endif -#ifdef HAVE_STDINT_H -# include -#endif - #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif -- cgit v1.2.1 From 39fa8a04ee96853ab4cc8e51ca14bec7dfb570fb Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Wed, 3 Feb 2021 10:41:47 +0000 Subject: Add TIFF_SIZE_FORMAT for portable use of %z MinGW64 does support %z, but it issues a compiler warning. --- libtiff/tif_config.h.cmake.in | 9 +++++++++ libtiff/tif_config.h.in | 11 ++++++++++- libtiff/tif_lzma.c | 2 +- libtiff/tif_webp.c | 2 +- tools/rgb2ycbcr.c | 2 +- tools/tiff2pdf.c | 10 +++++----- tools/tiff2rgba.c | 4 ++-- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in index 2b65d243..44d1240f 100644 --- a/libtiff/tif_config.h.cmake.in +++ b/libtiff/tif_config.h.cmake.in @@ -134,10 +134,19 @@ # endif #endif +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif #if SIZEOF_SIZE_T == 8 # define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif #elif SIZEOF_SIZE_T == 4 # define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif #else # error "Unsupported size_t size; please submit a bug report" #endif diff --git a/libtiff/tif_config.h.in b/libtiff/tif_config.h.in index 6a543463..b15b2b04 100644 --- a/libtiff/tif_config.h.in +++ b/libtiff/tif_config.h.in @@ -150,10 +150,19 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif #if SIZEOF_SIZE_T == 8 # define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif #elif SIZEOF_SIZE_T == 4 # define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif #else # error "Unsupported size_t size; please submit a bug report" -#endif \ No newline at end of file +#endif diff --git a/libtiff/tif_lzma.c b/libtiff/tif_lzma.c index a5770569..fc046475 100644 --- a/libtiff/tif_lzma.c +++ b/libtiff/tif_lzma.c @@ -213,7 +213,7 @@ LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } while (sp->stream.avail_out > 0); if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %"PRIu32" (short %zu bytes)", + "Not enough data at scanline %"PRIu32" (short %"TIFF_SIZE_FORMAT" bytes)", tif->tif_row, sp->stream.avail_out); return 0; } diff --git a/libtiff/tif_webp.c b/libtiff/tif_webp.c index 31412c84..50ffdce6 100644 --- a/libtiff/tif_webp.c +++ b/libtiff/tif_webp.c @@ -79,7 +79,7 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size, if ( (tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize ) { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer too small by %zu bytes.", + "Buffer too small by %"TIFF_SIZE_FORMAT" bytes.", (size_t) (tif->tif_rawcc + data_size - tif->tif_rawdatasize)); return 0; } else { diff --git a/tools/rgb2ycbcr.c b/tools/rgb2ycbcr.c index de23594b..0407cd69 100644 --- a/tools/rgb2ycbcr.c +++ b/tools/rgb2ycbcr.c @@ -313,7 +313,7 @@ tiffcvt(TIFF* in, TIFF* out) "raster buffer"); if (raster == 0) { TIFFError(TIFFFileName(in), - "Failed to allocate buffer (%zu elements of %zu each)", + "Failed to allocate buffer (%"TIFF_SIZE_FORMAT" elements of %"TIFF_SIZE_FORMAT" each)", pixel_count, sizeof(uint32_t)); return (0); diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 4cdf0f90..7d0ab678 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -955,7 +955,7 @@ T2P* t2p_init() if(t2p==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %zu bytes of memory for t2p_init", + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_init", sizeof(T2P)); return( (T2P*) NULL ); } @@ -1079,7 +1079,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(t2p->tiff_pages==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %zu bytes of memory for tiff_pages array, %s", + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for tiff_pages array, %s", sizeof(T2P_PAGE) * directorycount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1090,7 +1090,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(t2p->tiff_tiles==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %zu bytes of memory for tiff_tiles array, %s", + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for tiff_tiles array, %s", sizeof(T2P_TILES) * directorycount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1263,7 +1263,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if( t2p->tiff_tiles[i].tiles_tiles == NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %zu bytes of memory for t2p_read_tiff_init, %s", + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_read_tiff_init, %s", sizeof(T2P_TILE) * t2p->tiff_tiles[i].tiles_tilecount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -5558,7 +5558,7 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ if(t2p->pdf_xrefoffsets==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %zu bytes of memory for t2p_write_pdf", + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_write_pdf", sizeof(uint32_t) * t2p->pdf_xrefcount); t2p->t2p_error = T2P_ERR_ERROR; return(written); diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c index e0dbcc45..e1495f14 100644 --- a/tools/tiff2rgba.c +++ b/tools/tiff2rgba.c @@ -411,7 +411,7 @@ cvt_whole_image( TIFF *in, TIFF *out ) } if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) { TIFFError(TIFFFileName(in), - "Raster size %zu over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.", + "Raster size %"TIFF_SIZE_FORMAT" over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.", pixel_count * sizeof(uint32_t), maxMalloc); return 0; } @@ -421,7 +421,7 @@ cvt_whole_image( TIFF *in, TIFF *out ) raster = (uint32_t*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32_t), "raster buffer"); if (raster == 0) { - TIFFError(TIFFFileName(in), "Failed to allocate buffer (%zu elements of %zu each)", + TIFFError(TIFFFileName(in), "Failed to allocate buffer (%"TIFF_SIZE_FORMAT" elements of %"TIFF_SIZE_FORMAT" each)", pixel_count, sizeof(uint32_t)); return (0); } -- cgit v1.2.1 From 7b0da6ca6011d8f4a8d8cfc032360fe564cd2774 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Wed, 3 Feb 2021 20:22:58 +0000 Subject: NMake fixes for size type formatting --- libtiff/Makefile.vc | 2 +- libtiff/tif_config.vc.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libtiff/Makefile.vc b/libtiff/Makefile.vc index 5aac3310..7d79e132 100644 --- a/libtiff/Makefile.vc +++ b/libtiff/Makefile.vc @@ -78,7 +78,7 @@ OBJ = \ all: libtiff.lib $(DLLNAME) -tif_config.h: tif_config.vc.h +tif_config.h: tif_config.vc.h tiffconf.h copy tif_config.vc.h tif_config.h tiffconf.h: tiffconf.vc.h diff --git a/libtiff/tif_config.vc.h b/libtiff/tif_config.vc.h index 8413c826..8a1b7de8 100644 --- a/libtiff/tif_config.vc.h +++ b/libtiff/tif_config.vc.h @@ -58,6 +58,9 @@ #endif +/* Size type formatter */ +#define TIFF_SIZE_FORMAT "zu" + /* Set the native cpu bit order */ #define HOST_FILLORDER FILLORDER_LSB2MSB -- cgit v1.2.1 From ce494741c3e80b58abc96495fb6b07b160df9cd4 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Thu, 4 Feb 2021 23:57:28 +0000 Subject: Add additional TIFF_SSIZE_FORMAT uses --- libtiff/tif_jbig.c | 4 ++-- libtiff/tif_pixarlog.c | 2 +- tools/tiff2pdf.c | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c index 093ff7f0..74086338 100644 --- a/libtiff/tif_jbig.c +++ b/libtiff/tif_jbig.c @@ -101,13 +101,13 @@ static int JBIGDecode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s) if( (tmsize_t)decodedSize < size ) { TIFFWarningExt(tif->tif_clientdata, "JBIG", - "Only decoded %lu bytes, whereas %"PRId64" requested", + "Only decoded %lu bytes, whereas %"TIFF_SSIZE_FORMAT" requested", decodedSize, size); } else if( (tmsize_t)decodedSize > size ) { TIFFErrorExt(tif->tif_clientdata, "JBIG", - "Decoded %lu bytes, whereas %"PRId64" were requested", + "Decoded %lu bytes, whereas %"TIFF_SSIZE_FORMAT" were requested", decodedSize, size); jbg_dec_free(&decoder); return 0; diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c index 9686b7c5..87c67097 100644 --- a/libtiff/tif_pixarlog.c +++ b/libtiff/tif_pixarlog.c @@ -846,7 +846,7 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) if (nsamples % llen) { TIFFWarningExt(tif->tif_clientdata, module, "stride %d is not a multiple of sample count, " - "%"PRId64", data truncated.", llen, nsamples); + "%"TIFF_SSIZE_FORMAT", data truncated.", llen, nsamples); nsamples -= nsamples % llen; } diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 7d0ab678..6e956da4 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -2296,7 +2296,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer == NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2328,7 +2328,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2404,7 +2404,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2460,7 +2460,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2909,7 +2909,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -2946,7 +2946,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -2994,7 +2994,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); -- cgit v1.2.1